@greensecurity/javascript-sdk 0.30.17 → 0.30.21

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 (102) hide show
  1. package/README.md +3 -0
  2. package/bin/mcp-server.js +227 -41
  3. package/bin/mcp-server.js.map +11 -8
  4. package/dist/commonjs/__tests__/vendors.test.js +21 -2
  5. package/dist/commonjs/__tests__/vendors.test.js.map +1 -1
  6. package/dist/commonjs/__tests__/webhooks.test.js +1 -1
  7. package/dist/commonjs/__tests__/webhooks.test.js.map +1 -1
  8. package/dist/commonjs/funcs/vendorsPurchaseScrubCredits.d.ts +17 -0
  9. package/dist/commonjs/funcs/vendorsPurchaseScrubCredits.d.ts.map +1 -0
  10. package/dist/commonjs/funcs/vendorsPurchaseScrubCredits.js +121 -0
  11. package/dist/commonjs/funcs/vendorsPurchaseScrubCredits.js.map +1 -0
  12. package/dist/commonjs/lib/config.d.ts +3 -3
  13. package/dist/commonjs/lib/config.js +3 -3
  14. package/dist/commonjs/mcp-server/mcp-server.js +1 -1
  15. package/dist/commonjs/mcp-server/server.d.ts.map +1 -1
  16. package/dist/commonjs/mcp-server/server.js +3 -1
  17. package/dist/commonjs/mcp-server/server.js.map +1 -1
  18. package/dist/commonjs/mcp-server/tools/vendorsPurchaseScrubCredits.d.ts +8 -0
  19. package/dist/commonjs/mcp-server/tools/vendorsPurchaseScrubCredits.d.ts.map +1 -0
  20. package/dist/commonjs/mcp-server/tools/vendorsPurchaseScrubCredits.js +64 -0
  21. package/dist/commonjs/mcp-server/tools/vendorsPurchaseScrubCredits.js.map +1 -0
  22. package/dist/commonjs/models/components/invoice.d.ts +2 -0
  23. package/dist/commonjs/models/components/invoice.d.ts.map +1 -1
  24. package/dist/commonjs/models/components/invoice.js +4 -0
  25. package/dist/commonjs/models/components/invoice.js.map +1 -1
  26. package/dist/commonjs/models/operations/index.d.ts +1 -0
  27. package/dist/commonjs/models/operations/index.d.ts.map +1 -1
  28. package/dist/commonjs/models/operations/index.js +1 -0
  29. package/dist/commonjs/models/operations/index.js.map +1 -1
  30. package/dist/commonjs/models/operations/purchasescrubcredits.d.ts +91 -0
  31. package/dist/commonjs/models/operations/purchasescrubcredits.d.ts.map +1 -0
  32. package/dist/commonjs/models/operations/purchasescrubcredits.js +160 -0
  33. package/dist/commonjs/models/operations/purchasescrubcredits.js.map +1 -0
  34. package/dist/commonjs/react-query/index.d.ts +1 -0
  35. package/dist/commonjs/react-query/index.d.ts.map +1 -1
  36. package/dist/commonjs/react-query/index.js +1 -0
  37. package/dist/commonjs/react-query/index.js.map +1 -1
  38. package/dist/commonjs/react-query/vendorsPurchaseScrubCredits.d.ts +23 -0
  39. package/dist/commonjs/react-query/vendorsPurchaseScrubCredits.d.ts.map +1 -0
  40. package/dist/commonjs/react-query/vendorsPurchaseScrubCredits.js +47 -0
  41. package/dist/commonjs/react-query/vendorsPurchaseScrubCredits.js.map +1 -0
  42. package/dist/commonjs/sdk/vendors.d.ts +7 -0
  43. package/dist/commonjs/sdk/vendors.d.ts.map +1 -1
  44. package/dist/commonjs/sdk/vendors.js +10 -0
  45. package/dist/commonjs/sdk/vendors.js.map +1 -1
  46. package/dist/esm/__tests__/vendors.test.js +21 -2
  47. package/dist/esm/__tests__/vendors.test.js.map +1 -1
  48. package/dist/esm/__tests__/webhooks.test.js +1 -1
  49. package/dist/esm/__tests__/webhooks.test.js.map +1 -1
  50. package/dist/esm/funcs/vendorsPurchaseScrubCredits.d.ts +17 -0
  51. package/dist/esm/funcs/vendorsPurchaseScrubCredits.d.ts.map +1 -0
  52. package/dist/esm/funcs/vendorsPurchaseScrubCredits.js +85 -0
  53. package/dist/esm/funcs/vendorsPurchaseScrubCredits.js.map +1 -0
  54. package/dist/esm/lib/config.d.ts +3 -3
  55. package/dist/esm/lib/config.js +3 -3
  56. package/dist/esm/mcp-server/mcp-server.js +1 -1
  57. package/dist/esm/mcp-server/server.d.ts.map +1 -1
  58. package/dist/esm/mcp-server/server.js +3 -1
  59. package/dist/esm/mcp-server/server.js.map +1 -1
  60. package/dist/esm/mcp-server/tools/vendorsPurchaseScrubCredits.d.ts +8 -0
  61. package/dist/esm/mcp-server/tools/vendorsPurchaseScrubCredits.d.ts.map +1 -0
  62. package/dist/esm/mcp-server/tools/vendorsPurchaseScrubCredits.js +28 -0
  63. package/dist/esm/mcp-server/tools/vendorsPurchaseScrubCredits.js.map +1 -0
  64. package/dist/esm/models/components/invoice.d.ts +2 -0
  65. package/dist/esm/models/components/invoice.d.ts.map +1 -1
  66. package/dist/esm/models/components/invoice.js +4 -0
  67. package/dist/esm/models/components/invoice.js.map +1 -1
  68. package/dist/esm/models/operations/index.d.ts +1 -0
  69. package/dist/esm/models/operations/index.d.ts.map +1 -1
  70. package/dist/esm/models/operations/index.js +1 -0
  71. package/dist/esm/models/operations/index.js.map +1 -1
  72. package/dist/esm/models/operations/purchasescrubcredits.d.ts +91 -0
  73. package/dist/esm/models/operations/purchasescrubcredits.d.ts.map +1 -0
  74. package/dist/esm/models/operations/purchasescrubcredits.js +118 -0
  75. package/dist/esm/models/operations/purchasescrubcredits.js.map +1 -0
  76. package/dist/esm/react-query/index.d.ts +1 -0
  77. package/dist/esm/react-query/index.d.ts.map +1 -1
  78. package/dist/esm/react-query/index.js +1 -0
  79. package/dist/esm/react-query/index.js.map +1 -1
  80. package/dist/esm/react-query/vendorsPurchaseScrubCredits.d.ts +23 -0
  81. package/dist/esm/react-query/vendorsPurchaseScrubCredits.d.ts.map +1 -0
  82. package/dist/esm/react-query/vendorsPurchaseScrubCredits.js +42 -0
  83. package/dist/esm/react-query/vendorsPurchaseScrubCredits.js.map +1 -0
  84. package/dist/esm/sdk/vendors.d.ts +7 -0
  85. package/dist/esm/sdk/vendors.d.ts.map +1 -1
  86. package/dist/esm/sdk/vendors.js +10 -0
  87. package/dist/esm/sdk/vendors.js.map +1 -1
  88. package/jsr.json +1 -1
  89. package/package.json +1 -1
  90. package/src/__tests__/vendors.test.ts +24 -2
  91. package/src/__tests__/webhooks.test.ts +1 -1
  92. package/src/funcs/vendorsPurchaseScrubCredits.ts +176 -0
  93. package/src/lib/config.ts +3 -3
  94. package/src/mcp-server/mcp-server.ts +1 -1
  95. package/src/mcp-server/server.ts +3 -1
  96. package/src/mcp-server/tools/vendorsPurchaseScrubCredits.ts +37 -0
  97. package/src/models/components/invoice.ts +6 -0
  98. package/src/models/operations/index.ts +1 -0
  99. package/src/models/operations/purchasescrubcredits.ts +237 -0
  100. package/src/react-query/index.ts +1 -0
  101. package/src/react-query/vendorsPurchaseScrubCredits.ts +89 -0
  102. package/src/sdk/vendors.ts +18 -0
@@ -0,0 +1,237 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod";
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 PurchaseScrubCreditsRequestBody = {
12
+ payLater: boolean;
13
+ variantId: number;
14
+ };
15
+
16
+ export type PurchaseScrubCreditsRequest = {
17
+ /**
18
+ * Either the ID of the vendor rep or the keyword "me" to represent the current vendor.
19
+ */
20
+ vendorIdOrMe: string;
21
+ requestBody: PurchaseScrubCreditsRequestBody;
22
+ };
23
+
24
+ /**
25
+ * The request was successful, and the server has returned the requested resource in the response body.
26
+ */
27
+ export type PurchaseScrubCreditsResponseBody = {
28
+ invoiceId?: number | undefined;
29
+ creditBalance?: number | undefined;
30
+ };
31
+
32
+ /** @internal */
33
+ export const PurchaseScrubCreditsRequestBody$inboundSchema: z.ZodType<
34
+ PurchaseScrubCreditsRequestBody,
35
+ z.ZodTypeDef,
36
+ unknown
37
+ > = z.object({
38
+ pay_later: z.boolean(),
39
+ variant_id: z.number().int(),
40
+ }).transform((v) => {
41
+ return remap$(v, {
42
+ "pay_later": "payLater",
43
+ "variant_id": "variantId",
44
+ });
45
+ });
46
+
47
+ /** @internal */
48
+ export type PurchaseScrubCreditsRequestBody$Outbound = {
49
+ pay_later: boolean;
50
+ variant_id: number;
51
+ };
52
+
53
+ /** @internal */
54
+ export const PurchaseScrubCreditsRequestBody$outboundSchema: z.ZodType<
55
+ PurchaseScrubCreditsRequestBody$Outbound,
56
+ z.ZodTypeDef,
57
+ PurchaseScrubCreditsRequestBody
58
+ > = z.object({
59
+ payLater: z.boolean(),
60
+ variantId: z.number().int(),
61
+ }).transform((v) => {
62
+ return remap$(v, {
63
+ payLater: "pay_later",
64
+ variantId: "variant_id",
65
+ });
66
+ });
67
+
68
+ /**
69
+ * @internal
70
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
71
+ */
72
+ export namespace PurchaseScrubCreditsRequestBody$ {
73
+ /** @deprecated use `PurchaseScrubCreditsRequestBody$inboundSchema` instead. */
74
+ export const inboundSchema = PurchaseScrubCreditsRequestBody$inboundSchema;
75
+ /** @deprecated use `PurchaseScrubCreditsRequestBody$outboundSchema` instead. */
76
+ export const outboundSchema = PurchaseScrubCreditsRequestBody$outboundSchema;
77
+ /** @deprecated use `PurchaseScrubCreditsRequestBody$Outbound` instead. */
78
+ export type Outbound = PurchaseScrubCreditsRequestBody$Outbound;
79
+ }
80
+
81
+ export function purchaseScrubCreditsRequestBodyToJSON(
82
+ purchaseScrubCreditsRequestBody: PurchaseScrubCreditsRequestBody,
83
+ ): string {
84
+ return JSON.stringify(
85
+ PurchaseScrubCreditsRequestBody$outboundSchema.parse(
86
+ purchaseScrubCreditsRequestBody,
87
+ ),
88
+ );
89
+ }
90
+
91
+ export function purchaseScrubCreditsRequestBodyFromJSON(
92
+ jsonString: string,
93
+ ): SafeParseResult<PurchaseScrubCreditsRequestBody, SDKValidationError> {
94
+ return safeParse(
95
+ jsonString,
96
+ (x) => PurchaseScrubCreditsRequestBody$inboundSchema.parse(JSON.parse(x)),
97
+ `Failed to parse 'PurchaseScrubCreditsRequestBody' from JSON`,
98
+ );
99
+ }
100
+
101
+ /** @internal */
102
+ export const PurchaseScrubCreditsRequest$inboundSchema: z.ZodType<
103
+ PurchaseScrubCreditsRequest,
104
+ z.ZodTypeDef,
105
+ unknown
106
+ > = z.object({
107
+ vendor_id_or_me: z.string(),
108
+ RequestBody: z.lazy(() => PurchaseScrubCreditsRequestBody$inboundSchema),
109
+ }).transform((v) => {
110
+ return remap$(v, {
111
+ "vendor_id_or_me": "vendorIdOrMe",
112
+ "RequestBody": "requestBody",
113
+ });
114
+ });
115
+
116
+ /** @internal */
117
+ export type PurchaseScrubCreditsRequest$Outbound = {
118
+ vendor_id_or_me: string;
119
+ RequestBody: PurchaseScrubCreditsRequestBody$Outbound;
120
+ };
121
+
122
+ /** @internal */
123
+ export const PurchaseScrubCreditsRequest$outboundSchema: z.ZodType<
124
+ PurchaseScrubCreditsRequest$Outbound,
125
+ z.ZodTypeDef,
126
+ PurchaseScrubCreditsRequest
127
+ > = z.object({
128
+ vendorIdOrMe: z.string(),
129
+ requestBody: z.lazy(() => PurchaseScrubCreditsRequestBody$outboundSchema),
130
+ }).transform((v) => {
131
+ return remap$(v, {
132
+ vendorIdOrMe: "vendor_id_or_me",
133
+ requestBody: "RequestBody",
134
+ });
135
+ });
136
+
137
+ /**
138
+ * @internal
139
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
140
+ */
141
+ export namespace PurchaseScrubCreditsRequest$ {
142
+ /** @deprecated use `PurchaseScrubCreditsRequest$inboundSchema` instead. */
143
+ export const inboundSchema = PurchaseScrubCreditsRequest$inboundSchema;
144
+ /** @deprecated use `PurchaseScrubCreditsRequest$outboundSchema` instead. */
145
+ export const outboundSchema = PurchaseScrubCreditsRequest$outboundSchema;
146
+ /** @deprecated use `PurchaseScrubCreditsRequest$Outbound` instead. */
147
+ export type Outbound = PurchaseScrubCreditsRequest$Outbound;
148
+ }
149
+
150
+ export function purchaseScrubCreditsRequestToJSON(
151
+ purchaseScrubCreditsRequest: PurchaseScrubCreditsRequest,
152
+ ): string {
153
+ return JSON.stringify(
154
+ PurchaseScrubCreditsRequest$outboundSchema.parse(
155
+ purchaseScrubCreditsRequest,
156
+ ),
157
+ );
158
+ }
159
+
160
+ export function purchaseScrubCreditsRequestFromJSON(
161
+ jsonString: string,
162
+ ): SafeParseResult<PurchaseScrubCreditsRequest, SDKValidationError> {
163
+ return safeParse(
164
+ jsonString,
165
+ (x) => PurchaseScrubCreditsRequest$inboundSchema.parse(JSON.parse(x)),
166
+ `Failed to parse 'PurchaseScrubCreditsRequest' from JSON`,
167
+ );
168
+ }
169
+
170
+ /** @internal */
171
+ export const PurchaseScrubCreditsResponseBody$inboundSchema: z.ZodType<
172
+ PurchaseScrubCreditsResponseBody,
173
+ z.ZodTypeDef,
174
+ unknown
175
+ > = z.object({
176
+ invoice_id: z.number().int().optional(),
177
+ credit_balance: z.number().int().optional(),
178
+ }).transform((v) => {
179
+ return remap$(v, {
180
+ "invoice_id": "invoiceId",
181
+ "credit_balance": "creditBalance",
182
+ });
183
+ });
184
+
185
+ /** @internal */
186
+ export type PurchaseScrubCreditsResponseBody$Outbound = {
187
+ invoice_id?: number | undefined;
188
+ credit_balance?: number | undefined;
189
+ };
190
+
191
+ /** @internal */
192
+ export const PurchaseScrubCreditsResponseBody$outboundSchema: z.ZodType<
193
+ PurchaseScrubCreditsResponseBody$Outbound,
194
+ z.ZodTypeDef,
195
+ PurchaseScrubCreditsResponseBody
196
+ > = z.object({
197
+ invoiceId: z.number().int().optional(),
198
+ creditBalance: z.number().int().optional(),
199
+ }).transform((v) => {
200
+ return remap$(v, {
201
+ invoiceId: "invoice_id",
202
+ creditBalance: "credit_balance",
203
+ });
204
+ });
205
+
206
+ /**
207
+ * @internal
208
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
209
+ */
210
+ export namespace PurchaseScrubCreditsResponseBody$ {
211
+ /** @deprecated use `PurchaseScrubCreditsResponseBody$inboundSchema` instead. */
212
+ export const inboundSchema = PurchaseScrubCreditsResponseBody$inboundSchema;
213
+ /** @deprecated use `PurchaseScrubCreditsResponseBody$outboundSchema` instead. */
214
+ export const outboundSchema = PurchaseScrubCreditsResponseBody$outboundSchema;
215
+ /** @deprecated use `PurchaseScrubCreditsResponseBody$Outbound` instead. */
216
+ export type Outbound = PurchaseScrubCreditsResponseBody$Outbound;
217
+ }
218
+
219
+ export function purchaseScrubCreditsResponseBodyToJSON(
220
+ purchaseScrubCreditsResponseBody: PurchaseScrubCreditsResponseBody,
221
+ ): string {
222
+ return JSON.stringify(
223
+ PurchaseScrubCreditsResponseBody$outboundSchema.parse(
224
+ purchaseScrubCreditsResponseBody,
225
+ ),
226
+ );
227
+ }
228
+
229
+ export function purchaseScrubCreditsResponseBodyFromJSON(
230
+ jsonString: string,
231
+ ): SafeParseResult<PurchaseScrubCreditsResponseBody, SDKValidationError> {
232
+ return safeParse(
233
+ jsonString,
234
+ (x) => PurchaseScrubCreditsResponseBody$inboundSchema.parse(JSON.parse(x)),
235
+ `Failed to parse 'PurchaseScrubCreditsResponseBody' from JSON`,
236
+ );
237
+ }
@@ -33,6 +33,7 @@ export * from "./vendorsListVendorManagedByCompanies.js";
33
33
  export * from "./vendorsListVendorScrubDetails.js";
34
34
  export * from "./vendorsListVendorScrubPackages.js";
35
35
  export * from "./vendorsListVendorScrubPurchases.js";
36
+ export * from "./vendorsPurchaseScrubCredits.js";
36
37
  export * from "./vendorsUpdateVendorDetails.js";
37
38
  export * from "./vendorsUpdateVendorManagedByCompany.js";
38
39
  export * from "./vendorsUpdateVendorScrubDetails.js";
@@ -0,0 +1,89 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import {
6
+ MutationKey,
7
+ useMutation,
8
+ UseMutationResult,
9
+ } from "@tanstack/react-query";
10
+ import { GreenSecurityCore } from "../core.js";
11
+ import { vendorsPurchaseScrubCredits } from "../funcs/vendorsPurchaseScrubCredits.js";
12
+ import { combineSignals } from "../lib/primitives.js";
13
+ import { RequestOptions } from "../lib/sdks.js";
14
+ import * as operations from "../models/operations/index.js";
15
+ import { unwrapAsync } from "../types/fp.js";
16
+ import { useGreenSecurityContext } from "./_context.js";
17
+ import { MutationHookOptions } from "./_types.js";
18
+
19
+ export type VendorsPurchaseScrubCreditsMutationVariables = {
20
+ request: operations.PurchaseScrubCreditsRequest;
21
+ options?: RequestOptions;
22
+ };
23
+
24
+ export type VendorsPurchaseScrubCreditsMutationData =
25
+ operations.PurchaseScrubCreditsResponseBody;
26
+
27
+ /**
28
+ * Purchase scrub credits
29
+ *
30
+ * @remarks
31
+ * Purchase scrub credits
32
+ */
33
+ export function useVendorsPurchaseScrubCreditsMutation(
34
+ options?: MutationHookOptions<
35
+ VendorsPurchaseScrubCreditsMutationData,
36
+ Error,
37
+ VendorsPurchaseScrubCreditsMutationVariables
38
+ >,
39
+ ): UseMutationResult<
40
+ VendorsPurchaseScrubCreditsMutationData,
41
+ Error,
42
+ VendorsPurchaseScrubCreditsMutationVariables
43
+ > {
44
+ const client = useGreenSecurityContext();
45
+ return useMutation({
46
+ ...buildVendorsPurchaseScrubCreditsMutation(client, options),
47
+ ...options,
48
+ });
49
+ }
50
+
51
+ export function mutationKeyVendorsPurchaseScrubCredits(): MutationKey {
52
+ return ["@greensecurity/javascript-sdk", "vendors", "purchaseScrubCredits"];
53
+ }
54
+
55
+ export function buildVendorsPurchaseScrubCreditsMutation(
56
+ client$: GreenSecurityCore,
57
+ hookOptions?: RequestOptions,
58
+ ): {
59
+ mutationKey: MutationKey;
60
+ mutationFn: (
61
+ variables: VendorsPurchaseScrubCreditsMutationVariables,
62
+ ) => Promise<VendorsPurchaseScrubCreditsMutationData>;
63
+ } {
64
+ return {
65
+ mutationKey: mutationKeyVendorsPurchaseScrubCredits(),
66
+ mutationFn: function vendorsPurchaseScrubCreditsMutationFn({
67
+ request,
68
+ options,
69
+ }): Promise<VendorsPurchaseScrubCreditsMutationData> {
70
+ const mergedOptions = {
71
+ ...hookOptions,
72
+ ...options,
73
+ fetchOptions: {
74
+ ...hookOptions?.fetchOptions,
75
+ ...options?.fetchOptions,
76
+ signal: combineSignals(
77
+ hookOptions?.fetchOptions?.signal,
78
+ options?.fetchOptions?.signal,
79
+ ),
80
+ },
81
+ };
82
+ return unwrapAsync(vendorsPurchaseScrubCredits(
83
+ client$,
84
+ request,
85
+ mergedOptions,
86
+ ));
87
+ },
88
+ };
89
+ }
@@ -18,6 +18,7 @@ import { vendorsListVendorManagedByCompanies } from "../funcs/vendorsListVendorM
18
18
  import { vendorsListVendorScrubDetails } from "../funcs/vendorsListVendorScrubDetails.js";
19
19
  import { vendorsListVendorScrubPackages } from "../funcs/vendorsListVendorScrubPackages.js";
20
20
  import { vendorsListVendorScrubPurchases } from "../funcs/vendorsListVendorScrubPurchases.js";
21
+ import { vendorsPurchaseScrubCredits } from "../funcs/vendorsPurchaseScrubCredits.js";
21
22
  import { vendorsUpdateVendorDetails } from "../funcs/vendorsUpdateVendorDetails.js";
22
23
  import { vendorsUpdateVendorManagedByCompany } from "../funcs/vendorsUpdateVendorManagedByCompany.js";
23
24
  import { vendorsUpdateVendorScrubDetails } from "../funcs/vendorsUpdateVendorScrubDetails.js";
@@ -404,4 +405,21 @@ export class Vendors extends ClientSDK {
404
405
  options,
405
406
  ));
406
407
  }
408
+
409
+ /**
410
+ * Purchase scrub credits
411
+ *
412
+ * @remarks
413
+ * Purchase scrub credits
414
+ */
415
+ async purchaseScrubCredits(
416
+ request: operations.PurchaseScrubCreditsRequest,
417
+ options?: RequestOptions,
418
+ ): Promise<operations.PurchaseScrubCreditsResponseBody> {
419
+ return unwrapAsync(vendorsPurchaseScrubCredits(
420
+ this,
421
+ request,
422
+ options,
423
+ ));
424
+ }
407
425
  }