@gr4vy/sdk 0.17.2 → 0.17.4

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 (80) hide show
  1. package/bin/mcp-server.js +147 -40
  2. package/bin/mcp-server.js.map +17 -16
  3. package/docs/sdks/checkoutsessions/README.md +6 -212
  4. package/docs/sdks/giftcards/README.md +9 -5
  5. package/docs/sdks/transactions/README.md +10 -6
  6. package/funcs/checkoutSessionsCreate.d.ts +2 -1
  7. package/funcs/checkoutSessionsCreate.d.ts.map +1 -1
  8. package/funcs/checkoutSessionsCreate.js +5 -7
  9. package/funcs/checkoutSessionsCreate.js.map +1 -1
  10. package/funcs/giftCardsList.d.ts +5 -2
  11. package/funcs/giftCardsList.d.ts.map +1 -1
  12. package/funcs/giftCardsList.js +27 -7
  13. package/funcs/giftCardsList.js.map +1 -1
  14. package/funcs/transactionsList.d.ts +5 -3
  15. package/funcs/transactionsList.d.ts.map +1 -1
  16. package/funcs/transactionsList.js +31 -8
  17. package/funcs/transactionsList.js.map +1 -1
  18. package/jsr.json +1 -1
  19. package/lib/config.d.ts +3 -3
  20. package/lib/config.js +3 -3
  21. package/mcp-server/mcp-server.js +1 -1
  22. package/mcp-server/server.js +1 -1
  23. package/mcp-server/tools/checkoutSessionsCreate.d.ts +2 -2
  24. package/mcp-server/tools/checkoutSessionsCreate.d.ts.map +1 -1
  25. package/mcp-server/tools/checkoutSessionsCreate.js +4 -3
  26. package/mcp-server/tools/checkoutSessionsCreate.js.map +1 -1
  27. package/mcp-server/tools/giftCardsList.js +1 -1
  28. package/mcp-server/tools/giftCardsList.js.map +1 -1
  29. package/mcp-server/tools/transactionsList.js +2 -2
  30. package/mcp-server/tools/transactionsList.js.map +1 -1
  31. package/models/components/basemodel.d.ts +25 -0
  32. package/models/components/basemodel.d.ts.map +1 -0
  33. package/models/components/basemodel.js +55 -0
  34. package/models/components/basemodel.js.map +1 -0
  35. package/models/components/index.d.ts +1 -0
  36. package/models/components/index.d.ts.map +1 -1
  37. package/models/components/index.js +1 -0
  38. package/models/components/index.js.map +1 -1
  39. package/models/operations/createcheckoutsession.d.ts +23 -2
  40. package/models/operations/createcheckoutsession.d.ts.map +1 -1
  41. package/models/operations/createcheckoutsession.js +40 -5
  42. package/models/operations/createcheckoutsession.js.map +1 -1
  43. package/models/operations/listgiftcards.d.ts +26 -0
  44. package/models/operations/listgiftcards.d.ts.map +1 -1
  45. package/models/operations/listgiftcards.js +37 -1
  46. package/models/operations/listgiftcards.js.map +1 -1
  47. package/models/operations/listtransactions.d.ts +25 -0
  48. package/models/operations/listtransactions.d.ts.map +1 -1
  49. package/models/operations/listtransactions.js +36 -1
  50. package/models/operations/listtransactions.js.map +1 -1
  51. package/package.json +5 -1
  52. package/sdk/checkoutsessions.d.ts +2 -1
  53. package/sdk/checkoutsessions.d.ts.map +1 -1
  54. package/sdk/checkoutsessions.js +2 -2
  55. package/sdk/checkoutsessions.js.map +1 -1
  56. package/sdk/giftcards.d.ts +5 -1
  57. package/sdk/giftcards.d.ts.map +1 -1
  58. package/sdk/giftcards.js +2 -1
  59. package/sdk/giftcards.js.map +1 -1
  60. package/sdk/transactions.d.ts +5 -2
  61. package/sdk/transactions.d.ts.map +1 -1
  62. package/sdk/transactions.js +3 -2
  63. package/sdk/transactions.js.map +1 -1
  64. package/src/funcs/checkoutSessionsCreate.ts +5 -7
  65. package/src/funcs/giftCardsList.ts +121 -51
  66. package/src/funcs/transactionsList.ts +117 -47
  67. package/src/lib/config.ts +3 -3
  68. package/src/mcp-server/mcp-server.ts +1 -1
  69. package/src/mcp-server/server.ts +1 -1
  70. package/src/mcp-server/tools/checkoutSessionsCreate.ts +4 -5
  71. package/src/mcp-server/tools/giftCardsList.ts +1 -1
  72. package/src/mcp-server/tools/transactionsList.ts +2 -2
  73. package/src/models/components/basemodel.ts +54 -0
  74. package/src/models/components/index.ts +1 -0
  75. package/src/models/operations/createcheckoutsession.ts +79 -8
  76. package/src/models/operations/listgiftcards.ts +67 -0
  77. package/src/models/operations/listtransactions.ts +66 -0
  78. package/src/sdk/checkoutsessions.ts +3 -2
  79. package/src/sdk/giftcards.ts +6 -2
  80. package/src/sdk/transactions.ts +6 -3
@@ -9,11 +9,75 @@ import { Result as SafeParseResult } from "../../types/fp.js";
9
9
  import * as components from "../components/index.js";
10
10
  import { SDKValidationError } from "../errors/sdkvalidationerror.js";
11
11
 
12
+ export type CreateCheckoutSessionBody =
13
+ | components.CheckoutSessionUpdate
14
+ | Array<components.BaseModel>;
15
+
12
16
  export type CreateCheckoutSessionRequest = {
13
17
  timeoutInSeconds?: number | undefined;
14
- checkoutSessionUpdate?: components.CheckoutSessionUpdate | null | undefined;
18
+ requestBody?:
19
+ | components.CheckoutSessionUpdate
20
+ | Array<components.BaseModel>
21
+ | null
22
+ | undefined;
15
23
  };
16
24
 
25
+ /** @internal */
26
+ export const CreateCheckoutSessionBody$inboundSchema: z.ZodType<
27
+ CreateCheckoutSessionBody,
28
+ z.ZodTypeDef,
29
+ unknown
30
+ > = z.union([
31
+ components.CheckoutSessionUpdate$inboundSchema,
32
+ z.array(components.BaseModel$inboundSchema),
33
+ ]);
34
+
35
+ /** @internal */
36
+ export type CreateCheckoutSessionBody$Outbound =
37
+ | components.CheckoutSessionUpdate$Outbound
38
+ | Array<components.BaseModel$Outbound>;
39
+
40
+ /** @internal */
41
+ export const CreateCheckoutSessionBody$outboundSchema: z.ZodType<
42
+ CreateCheckoutSessionBody$Outbound,
43
+ z.ZodTypeDef,
44
+ CreateCheckoutSessionBody
45
+ > = z.union([
46
+ components.CheckoutSessionUpdate$outboundSchema,
47
+ z.array(components.BaseModel$outboundSchema),
48
+ ]);
49
+
50
+ /**
51
+ * @internal
52
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
53
+ */
54
+ export namespace CreateCheckoutSessionBody$ {
55
+ /** @deprecated use `CreateCheckoutSessionBody$inboundSchema` instead. */
56
+ export const inboundSchema = CreateCheckoutSessionBody$inboundSchema;
57
+ /** @deprecated use `CreateCheckoutSessionBody$outboundSchema` instead. */
58
+ export const outboundSchema = CreateCheckoutSessionBody$outboundSchema;
59
+ /** @deprecated use `CreateCheckoutSessionBody$Outbound` instead. */
60
+ export type Outbound = CreateCheckoutSessionBody$Outbound;
61
+ }
62
+
63
+ export function createCheckoutSessionBodyToJSON(
64
+ createCheckoutSessionBody: CreateCheckoutSessionBody,
65
+ ): string {
66
+ return JSON.stringify(
67
+ CreateCheckoutSessionBody$outboundSchema.parse(createCheckoutSessionBody),
68
+ );
69
+ }
70
+
71
+ export function createCheckoutSessionBodyFromJSON(
72
+ jsonString: string,
73
+ ): SafeParseResult<CreateCheckoutSessionBody, SDKValidationError> {
74
+ return safeParse(
75
+ jsonString,
76
+ (x) => CreateCheckoutSessionBody$inboundSchema.parse(JSON.parse(x)),
77
+ `Failed to parse 'CreateCheckoutSessionBody' from JSON`,
78
+ );
79
+ }
80
+
17
81
  /** @internal */
18
82
  export const CreateCheckoutSessionRequest$inboundSchema: z.ZodType<
19
83
  CreateCheckoutSessionRequest,
@@ -21,21 +85,25 @@ export const CreateCheckoutSessionRequest$inboundSchema: z.ZodType<
21
85
  unknown
22
86
  > = z.object({
23
87
  timeout_in_seconds: z.number().default(1),
24
- CheckoutSessionUpdate: z.nullable(
25
- components.CheckoutSessionUpdate$inboundSchema,
88
+ RequestBody: z.nullable(
89
+ z.union([
90
+ components.CheckoutSessionUpdate$inboundSchema,
91
+ z.array(components.BaseModel$inboundSchema),
92
+ ]),
26
93
  ).optional(),
27
94
  }).transform((v) => {
28
95
  return remap$(v, {
29
96
  "timeout_in_seconds": "timeoutInSeconds",
30
- "CheckoutSessionUpdate": "checkoutSessionUpdate",
97
+ "RequestBody": "requestBody",
31
98
  });
32
99
  });
33
100
 
34
101
  /** @internal */
35
102
  export type CreateCheckoutSessionRequest$Outbound = {
36
103
  timeout_in_seconds: number;
37
- CheckoutSessionUpdate?:
104
+ RequestBody?:
38
105
  | components.CheckoutSessionUpdate$Outbound
106
+ | Array<components.BaseModel$Outbound>
39
107
  | null
40
108
  | undefined;
41
109
  };
@@ -47,13 +115,16 @@ export const CreateCheckoutSessionRequest$outboundSchema: z.ZodType<
47
115
  CreateCheckoutSessionRequest
48
116
  > = z.object({
49
117
  timeoutInSeconds: z.number().default(1),
50
- checkoutSessionUpdate: z.nullable(
51
- components.CheckoutSessionUpdate$outboundSchema,
118
+ requestBody: z.nullable(
119
+ z.union([
120
+ components.CheckoutSessionUpdate$outboundSchema,
121
+ z.array(components.BaseModel$outboundSchema),
122
+ ]),
52
123
  ).optional(),
53
124
  }).transform((v) => {
54
125
  return remap$(v, {
55
126
  timeoutInSeconds: "timeout_in_seconds",
56
- checkoutSessionUpdate: "CheckoutSessionUpdate",
127
+ requestBody: "RequestBody",
57
128
  });
58
129
  });
59
130
 
@@ -6,6 +6,7 @@ import * as z from "zod";
6
6
  import { remap as remap$ } from "../../lib/primitives.js";
7
7
  import { safeParse } from "../../lib/schemas.js";
8
8
  import { Result as SafeParseResult } from "../../types/fp.js";
9
+ import * as components from "../components/index.js";
9
10
  import { SDKValidationError } from "../errors/sdkvalidationerror.js";
10
11
 
11
12
  export type ListGiftCardsRequest = {
@@ -15,6 +16,10 @@ export type ListGiftCardsRequest = {
15
16
  limit?: number | undefined;
16
17
  };
17
18
 
19
+ export type ListGiftCardsResponse = {
20
+ result: components.CollectionGiftCard;
21
+ };
22
+
18
23
  /** @internal */
19
24
  export const ListGiftCardsRequest$inboundSchema: z.ZodType<
20
25
  ListGiftCardsRequest,
@@ -87,3 +92,65 @@ export function listGiftCardsRequestFromJSON(
87
92
  `Failed to parse 'ListGiftCardsRequest' from JSON`,
88
93
  );
89
94
  }
95
+
96
+ /** @internal */
97
+ export const ListGiftCardsResponse$inboundSchema: z.ZodType<
98
+ ListGiftCardsResponse,
99
+ z.ZodTypeDef,
100
+ unknown
101
+ > = z.object({
102
+ Result: components.CollectionGiftCard$inboundSchema,
103
+ }).transform((v) => {
104
+ return remap$(v, {
105
+ "Result": "result",
106
+ });
107
+ });
108
+
109
+ /** @internal */
110
+ export type ListGiftCardsResponse$Outbound = {
111
+ Result: components.CollectionGiftCard$Outbound;
112
+ };
113
+
114
+ /** @internal */
115
+ export const ListGiftCardsResponse$outboundSchema: z.ZodType<
116
+ ListGiftCardsResponse$Outbound,
117
+ z.ZodTypeDef,
118
+ ListGiftCardsResponse
119
+ > = z.object({
120
+ result: components.CollectionGiftCard$outboundSchema,
121
+ }).transform((v) => {
122
+ return remap$(v, {
123
+ result: "Result",
124
+ });
125
+ });
126
+
127
+ /**
128
+ * @internal
129
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
130
+ */
131
+ export namespace ListGiftCardsResponse$ {
132
+ /** @deprecated use `ListGiftCardsResponse$inboundSchema` instead. */
133
+ export const inboundSchema = ListGiftCardsResponse$inboundSchema;
134
+ /** @deprecated use `ListGiftCardsResponse$outboundSchema` instead. */
135
+ export const outboundSchema = ListGiftCardsResponse$outboundSchema;
136
+ /** @deprecated use `ListGiftCardsResponse$Outbound` instead. */
137
+ export type Outbound = ListGiftCardsResponse$Outbound;
138
+ }
139
+
140
+ export function listGiftCardsResponseToJSON(
141
+ listGiftCardsResponse: ListGiftCardsResponse,
142
+ ): string {
143
+ return JSON.stringify(
144
+ ListGiftCardsResponse$outboundSchema.parse(listGiftCardsResponse),
145
+ );
146
+ }
147
+
148
+ export function listGiftCardsResponseFromJSON(
149
+ jsonString: string,
150
+ ): SafeParseResult<ListGiftCardsResponse, SDKValidationError> {
151
+ return safeParse(
152
+ jsonString,
153
+ (x) => ListGiftCardsResponse$inboundSchema.parse(JSON.parse(x)),
154
+ `Failed to parse 'ListGiftCardsResponse' from JSON`,
155
+ );
156
+ }
@@ -130,6 +130,10 @@ export type ListTransactionsRequest = {
130
130
  merchantInitiated?: boolean | null | undefined;
131
131
  };
132
132
 
133
+ export type ListTransactionsResponse = {
134
+ result: components.CollectionTransactionSummary;
135
+ };
136
+
133
137
  /** @internal */
134
138
  export const ListTransactionsRequest$inboundSchema: z.ZodType<
135
139
  ListTransactionsRequest,
@@ -369,3 +373,65 @@ export function listTransactionsRequestFromJSON(
369
373
  `Failed to parse 'ListTransactionsRequest' from JSON`,
370
374
  );
371
375
  }
376
+
377
+ /** @internal */
378
+ export const ListTransactionsResponse$inboundSchema: z.ZodType<
379
+ ListTransactionsResponse,
380
+ z.ZodTypeDef,
381
+ unknown
382
+ > = z.object({
383
+ Result: components.CollectionTransactionSummary$inboundSchema,
384
+ }).transform((v) => {
385
+ return remap$(v, {
386
+ "Result": "result",
387
+ });
388
+ });
389
+
390
+ /** @internal */
391
+ export type ListTransactionsResponse$Outbound = {
392
+ Result: components.CollectionTransactionSummary$Outbound;
393
+ };
394
+
395
+ /** @internal */
396
+ export const ListTransactionsResponse$outboundSchema: z.ZodType<
397
+ ListTransactionsResponse$Outbound,
398
+ z.ZodTypeDef,
399
+ ListTransactionsResponse
400
+ > = z.object({
401
+ result: components.CollectionTransactionSummary$outboundSchema,
402
+ }).transform((v) => {
403
+ return remap$(v, {
404
+ result: "Result",
405
+ });
406
+ });
407
+
408
+ /**
409
+ * @internal
410
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
411
+ */
412
+ export namespace ListTransactionsResponse$ {
413
+ /** @deprecated use `ListTransactionsResponse$inboundSchema` instead. */
414
+ export const inboundSchema = ListTransactionsResponse$inboundSchema;
415
+ /** @deprecated use `ListTransactionsResponse$outboundSchema` instead. */
416
+ export const outboundSchema = ListTransactionsResponse$outboundSchema;
417
+ /** @deprecated use `ListTransactionsResponse$Outbound` instead. */
418
+ export type Outbound = ListTransactionsResponse$Outbound;
419
+ }
420
+
421
+ export function listTransactionsResponseToJSON(
422
+ listTransactionsResponse: ListTransactionsResponse,
423
+ ): string {
424
+ return JSON.stringify(
425
+ ListTransactionsResponse$outboundSchema.parse(listTransactionsResponse),
426
+ );
427
+ }
428
+
429
+ export function listTransactionsResponseFromJSON(
430
+ jsonString: string,
431
+ ): SafeParseResult<ListTransactionsResponse, SDKValidationError> {
432
+ return safeParse(
433
+ jsonString,
434
+ (x) => ListTransactionsResponse$inboundSchema.parse(JSON.parse(x)),
435
+ `Failed to parse 'ListTransactionsResponse' from JSON`,
436
+ );
437
+ }
@@ -8,6 +8,7 @@ import { checkoutSessionsGet } from "../funcs/checkoutSessionsGet.js";
8
8
  import { checkoutSessionsUpdate } from "../funcs/checkoutSessionsUpdate.js";
9
9
  import { ClientSDK, RequestOptions } from "../lib/sdks.js";
10
10
  import * as components from "../models/components/index.js";
11
+ import * as operations from "../models/operations/index.js";
11
12
  import { unwrapAsync } from "../types/fp.js";
12
13
 
13
14
  export class CheckoutSessions extends ClientSDK {
@@ -18,13 +19,13 @@ export class CheckoutSessions extends ClientSDK {
18
19
  * Create a new checkout session.
19
20
  */
20
21
  async create(
21
- checkoutSessionUpdate?: components.CheckoutSessionUpdate | null | undefined,
22
+ requestBody?: operations.CreateCheckoutSessionBody | null | undefined,
22
23
  timeoutInSeconds?: number | undefined,
23
24
  options?: RequestOptions,
24
25
  ): Promise<components.CheckoutSession> {
25
26
  return unwrapAsync(checkoutSessionsCreate(
26
27
  this,
27
- checkoutSessionUpdate,
28
+ requestBody,
28
29
  timeoutInSeconds,
29
30
  options,
30
31
  ));
@@ -8,7 +8,9 @@ import { giftCardsGet } from "../funcs/giftCardsGet.js";
8
8
  import { giftCardsList } from "../funcs/giftCardsList.js";
9
9
  import { ClientSDK, RequestOptions } from "../lib/sdks.js";
10
10
  import * as components from "../models/components/index.js";
11
+ import * as operations from "../models/operations/index.js";
11
12
  import { unwrapAsync } from "../types/fp.js";
13
+ import { PageIterator, unwrapResultIterator } from "../types/operations.js";
12
14
  import { Balances } from "./balances.js";
13
15
 
14
16
  export class GiftCards extends ClientSDK {
@@ -84,8 +86,10 @@ export class GiftCards extends ClientSDK {
84
86
  cursor?: string | null | undefined,
85
87
  limit?: number | undefined,
86
88
  options?: RequestOptions,
87
- ): Promise<components.CollectionGiftCard> {
88
- return unwrapAsync(giftCardsList(
89
+ ): Promise<
90
+ PageIterator<operations.ListGiftCardsResponse, { cursor: string }>
91
+ > {
92
+ return unwrapResultIterator(giftCardsList(
89
93
  this,
90
94
  buyerExternalIdentifier,
91
95
  buyerId,
@@ -13,6 +13,7 @@ import { ClientSDK, RequestOptions } from "../lib/sdks.js";
13
13
  import * as components from "../models/components/index.js";
14
14
  import * as operations from "../models/operations/index.js";
15
15
  import { unwrapAsync } from "../types/fp.js";
16
+ import { PageIterator, unwrapResultIterator } from "../types/operations.js";
16
17
  import { Gr4vyTransactionsRefunds } from "./gr4vytransactionsrefunds.js";
17
18
 
18
19
  export class Transactions extends ClientSDK {
@@ -25,13 +26,15 @@ export class Transactions extends ClientSDK {
25
26
  * List transactions
26
27
  *
27
28
  * @remarks
28
- * List all transactions.
29
+ * List all transactions for a specific merchant account sorted by most recently created.
29
30
  */
30
31
  async list(
31
32
  request?: operations.ListTransactionsRequest | undefined,
32
33
  options?: RequestOptions,
33
- ): Promise<components.CollectionTransactionSummary> {
34
- return unwrapAsync(transactionsList(
34
+ ): Promise<
35
+ PageIterator<operations.ListTransactionsResponse, { cursor: string }>
36
+ > {
37
+ return unwrapResultIterator(transactionsList(
35
38
  this,
36
39
  request,
37
40
  options,