@greensecurity/javascript-sdk 0.45.0-beta.7 → 0.45.0-beta.9

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 (86) hide show
  1. package/README.md +4 -1
  2. package/dist/commonjs/__tests__/invoices.test.js +18 -0
  3. package/dist/commonjs/__tests__/invoices.test.js.map +1 -1
  4. package/dist/commonjs/__tests__/vendors.test.js +1 -1
  5. package/dist/commonjs/__tests__/vendors.test.js.map +1 -1
  6. package/dist/commonjs/__tests__/zones.test.js +30 -2
  7. package/dist/commonjs/__tests__/zones.test.js.map +1 -1
  8. package/dist/commonjs/funcs/invoicesConvertQuote.d.ts +33 -0
  9. package/dist/commonjs/funcs/invoicesConvertQuote.d.ts.map +1 -0
  10. package/dist/commonjs/funcs/invoicesConvertQuote.js +138 -0
  11. package/dist/commonjs/funcs/invoicesConvertQuote.js.map +1 -0
  12. package/dist/commonjs/lib/config.d.ts +2 -2
  13. package/dist/commonjs/lib/config.js +2 -2
  14. package/dist/commonjs/models/operations/convertquote.d.ts +46 -0
  15. package/dist/commonjs/models/operations/convertquote.d.ts.map +1 -0
  16. package/dist/commonjs/models/operations/convertquote.js +69 -0
  17. package/dist/commonjs/models/operations/convertquote.js.map +1 -0
  18. package/dist/commonjs/models/operations/createinvoice.d.ts +85 -0
  19. package/dist/commonjs/models/operations/createinvoice.d.ts.map +1 -1
  20. package/dist/commonjs/models/operations/createinvoice.js +56 -1
  21. package/dist/commonjs/models/operations/createinvoice.js.map +1 -1
  22. package/dist/commonjs/models/operations/index.d.ts +1 -0
  23. package/dist/commonjs/models/operations/index.d.ts.map +1 -1
  24. package/dist/commonjs/models/operations/index.js +1 -0
  25. package/dist/commonjs/models/operations/index.js.map +1 -1
  26. package/dist/commonjs/react-query/index.d.ts +1 -0
  27. package/dist/commonjs/react-query/index.d.ts.map +1 -1
  28. package/dist/commonjs/react-query/index.js +1 -0
  29. package/dist/commonjs/react-query/index.js.map +1 -1
  30. package/dist/commonjs/react-query/invoicesConvertQuote.d.ts +42 -0
  31. package/dist/commonjs/react-query/invoicesConvertQuote.d.ts.map +1 -0
  32. package/dist/commonjs/react-query/invoicesConvertQuote.js +60 -0
  33. package/dist/commonjs/react-query/invoicesConvertQuote.js.map +1 -0
  34. package/dist/commonjs/sdk/invoices.d.ts +20 -0
  35. package/dist/commonjs/sdk/invoices.d.ts.map +1 -1
  36. package/dist/commonjs/sdk/invoices.js +23 -0
  37. package/dist/commonjs/sdk/invoices.js.map +1 -1
  38. package/dist/esm/__tests__/invoices.test.js +18 -0
  39. package/dist/esm/__tests__/invoices.test.js.map +1 -1
  40. package/dist/esm/__tests__/vendors.test.js +1 -1
  41. package/dist/esm/__tests__/vendors.test.js.map +1 -1
  42. package/dist/esm/__tests__/zones.test.js +30 -2
  43. package/dist/esm/__tests__/zones.test.js.map +1 -1
  44. package/dist/esm/funcs/invoicesConvertQuote.d.ts +33 -0
  45. package/dist/esm/funcs/invoicesConvertQuote.d.ts.map +1 -0
  46. package/dist/esm/funcs/invoicesConvertQuote.js +102 -0
  47. package/dist/esm/funcs/invoicesConvertQuote.js.map +1 -0
  48. package/dist/esm/lib/config.d.ts +2 -2
  49. package/dist/esm/lib/config.js +2 -2
  50. package/dist/esm/models/operations/convertquote.d.ts +46 -0
  51. package/dist/esm/models/operations/convertquote.d.ts.map +1 -0
  52. package/dist/esm/models/operations/convertquote.js +31 -0
  53. package/dist/esm/models/operations/convertquote.js.map +1 -0
  54. package/dist/esm/models/operations/createinvoice.d.ts +85 -0
  55. package/dist/esm/models/operations/createinvoice.d.ts.map +1 -1
  56. package/dist/esm/models/operations/createinvoice.js +55 -0
  57. package/dist/esm/models/operations/createinvoice.js.map +1 -1
  58. package/dist/esm/models/operations/index.d.ts +1 -0
  59. package/dist/esm/models/operations/index.d.ts.map +1 -1
  60. package/dist/esm/models/operations/index.js +1 -0
  61. package/dist/esm/models/operations/index.js.map +1 -1
  62. package/dist/esm/react-query/index.d.ts +1 -0
  63. package/dist/esm/react-query/index.d.ts.map +1 -1
  64. package/dist/esm/react-query/index.js +1 -0
  65. package/dist/esm/react-query/index.js.map +1 -1
  66. package/dist/esm/react-query/invoicesConvertQuote.d.ts +42 -0
  67. package/dist/esm/react-query/invoicesConvertQuote.d.ts.map +1 -0
  68. package/dist/esm/react-query/invoicesConvertQuote.js +55 -0
  69. package/dist/esm/react-query/invoicesConvertQuote.js.map +1 -0
  70. package/dist/esm/sdk/invoices.d.ts +20 -0
  71. package/dist/esm/sdk/invoices.d.ts.map +1 -1
  72. package/dist/esm/sdk/invoices.js +23 -0
  73. package/dist/esm/sdk/invoices.js.map +1 -1
  74. package/jsr.json +1 -1
  75. package/package.json +1 -1
  76. package/src/__tests__/invoices.test.ts +21 -0
  77. package/src/__tests__/vendors.test.ts +1 -1
  78. package/src/__tests__/zones.test.ts +30 -2
  79. package/src/funcs/invoicesConvertQuote.ts +190 -0
  80. package/src/lib/config.ts +2 -2
  81. package/src/models/operations/convertquote.ts +94 -0
  82. package/src/models/operations/createinvoice.ts +124 -0
  83. package/src/models/operations/index.ts +1 -0
  84. package/src/react-query/index.ts +1 -0
  85. package/src/react-query/invoicesConvertQuote.ts +124 -0
  86. package/src/sdk/invoices.ts +31 -0
@@ -0,0 +1,124 @@
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 { invoicesConvertQuote } from "../funcs/invoicesConvertQuote.js";
12
+ import { combineSignals } from "../lib/primitives.js";
13
+ import { RequestOptions } from "../lib/sdks.js";
14
+ import { GreenSecurityError } from "../models/errors/greensecurityerror.js";
15
+ import {
16
+ ConnectionError,
17
+ InvalidRequestError,
18
+ RequestAbortedError,
19
+ RequestTimeoutError,
20
+ UnexpectedClientError,
21
+ } from "../models/errors/httpclienterrors.js";
22
+ import * as errors from "../models/errors/index.js";
23
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
24
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
25
+ import * as operations from "../models/operations/index.js";
26
+ import { unwrapAsync } from "../types/fp.js";
27
+ import { useGreenSecurityContext } from "./_context.js";
28
+ import { MutationHookOptions } from "./_types.js";
29
+
30
+ export type InvoicesConvertQuoteMutationVariables = {
31
+ request: operations.ConvertQuoteRequest;
32
+ options?: RequestOptions;
33
+ };
34
+
35
+ export type InvoicesConvertQuoteMutationData =
36
+ operations.ConvertQuoteConvertQuoteOk;
37
+
38
+ export type InvoicesConvertQuoteMutationError =
39
+ | errors.ApiErrorResponse
40
+ | GreenSecurityError
41
+ | ResponseValidationError
42
+ | ConnectionError
43
+ | RequestAbortedError
44
+ | RequestTimeoutError
45
+ | InvalidRequestError
46
+ | UnexpectedClientError
47
+ | SDKValidationError;
48
+
49
+ /**
50
+ * Convert a quote into an invoice
51
+ *
52
+ * @remarks
53
+ * Converts a quote into the real invoice its caller will be charged for, and
54
+ * returns the new invoice with its calculated totals. Any `VendorCredential`
55
+ * linked to the quote is re-pointed at the new invoice.
56
+ *
57
+ * The operation is idempotent: converting a quote that has already been
58
+ * processed returns the invoice previously created from it rather than
59
+ * creating a second one, so a retried request is safe.
60
+ *
61
+ * The referenced invoice must actually be a quote — a non-quote invoice id
62
+ * responds `400`. Requires a caller whose access scope permits creating
63
+ * invoices; a caller allowed to create the invoice but not to update the
64
+ * linked `VendorCredential` responds `401`.
65
+ *
66
+ * Takes no request body.
67
+ */
68
+ export function useInvoicesConvertQuoteMutation(
69
+ options?: MutationHookOptions<
70
+ InvoicesConvertQuoteMutationData,
71
+ InvoicesConvertQuoteMutationError,
72
+ InvoicesConvertQuoteMutationVariables
73
+ >,
74
+ ): UseMutationResult<
75
+ InvoicesConvertQuoteMutationData,
76
+ InvoicesConvertQuoteMutationError,
77
+ InvoicesConvertQuoteMutationVariables
78
+ > {
79
+ const client = useGreenSecurityContext();
80
+ return useMutation({
81
+ ...buildInvoicesConvertQuoteMutation(client, options),
82
+ ...options,
83
+ });
84
+ }
85
+
86
+ export function mutationKeyInvoicesConvertQuote(): MutationKey {
87
+ return ["@greensecurity/javascript-sdk", "invoices", "convertQuote"];
88
+ }
89
+
90
+ export function buildInvoicesConvertQuoteMutation(
91
+ client$: GreenSecurityCore,
92
+ hookOptions?: RequestOptions,
93
+ ): {
94
+ mutationKey: MutationKey;
95
+ mutationFn: (
96
+ variables: InvoicesConvertQuoteMutationVariables,
97
+ ) => Promise<InvoicesConvertQuoteMutationData>;
98
+ } {
99
+ return {
100
+ mutationKey: mutationKeyInvoicesConvertQuote(),
101
+ mutationFn: function invoicesConvertQuoteMutationFn({
102
+ request,
103
+ options,
104
+ }): Promise<InvoicesConvertQuoteMutationData> {
105
+ const mergedOptions = {
106
+ ...hookOptions,
107
+ ...options,
108
+ fetchOptions: {
109
+ ...hookOptions?.fetchOptions,
110
+ ...options?.fetchOptions,
111
+ signal: combineSignals(
112
+ hookOptions?.fetchOptions?.signal,
113
+ options?.fetchOptions?.signal,
114
+ ),
115
+ },
116
+ };
117
+ return unwrapAsync(invoicesConvertQuote(
118
+ client$,
119
+ request,
120
+ mergedOptions,
121
+ ));
122
+ },
123
+ };
124
+ }
@@ -2,6 +2,7 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  */
4
4
 
5
+ import { invoicesConvertQuote } from "../funcs/invoicesConvertQuote.js";
5
6
  import { invoicesCreateInvoice } from "../funcs/invoicesCreateInvoice.js";
6
7
  import {
7
8
  DownloadInvoicesExportAcceptEnum,
@@ -152,6 +153,36 @@ export class Invoices extends ClientSDK {
152
153
  ));
153
154
  }
154
155
 
156
+ /**
157
+ * Convert a quote into an invoice
158
+ *
159
+ * @remarks
160
+ * Converts a quote into the real invoice its caller will be charged for, and
161
+ * returns the new invoice with its calculated totals. Any `VendorCredential`
162
+ * linked to the quote is re-pointed at the new invoice.
163
+ *
164
+ * The operation is idempotent: converting a quote that has already been
165
+ * processed returns the invoice previously created from it rather than
166
+ * creating a second one, so a retried request is safe.
167
+ *
168
+ * The referenced invoice must actually be a quote — a non-quote invoice id
169
+ * responds `400`. Requires a caller whose access scope permits creating
170
+ * invoices; a caller allowed to create the invoice but not to update the
171
+ * linked `VendorCredential` responds `401`.
172
+ *
173
+ * Takes no request body.
174
+ */
175
+ async convertQuote(
176
+ request: operations.ConvertQuoteRequest,
177
+ options?: RequestOptions,
178
+ ): Promise<operations.ConvertQuoteConvertQuoteOk> {
179
+ return unwrapAsync(invoicesConvertQuote(
180
+ this,
181
+ request,
182
+ options,
183
+ ));
184
+ }
185
+
155
186
  /**
156
187
  * Export invoices to csv (async)
157
188
  *