@greensecurity/javascript-sdk 0.48.0-beta.9 → 0.48.0

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 (159) hide show
  1. package/README.md +1 -1
  2. package/dist/commonjs/__tests__/fhirconfigs.test.js +18 -0
  3. package/dist/commonjs/__tests__/fhirconfigs.test.js.map +1 -1
  4. package/dist/commonjs/__tests__/subscriptionPlanSelection.test.d.ts +2 -0
  5. package/dist/commonjs/__tests__/subscriptionPlanSelection.test.d.ts.map +1 -0
  6. package/dist/commonjs/__tests__/subscriptionPlanSelection.test.js +36 -0
  7. package/dist/commonjs/__tests__/subscriptionPlanSelection.test.js.map +1 -0
  8. package/dist/commonjs/__tests__/vendors.test.js +1 -1
  9. package/dist/commonjs/__tests__/webhooks.test.js +6 -5
  10. package/dist/commonjs/__tests__/webhooks.test.js.map +1 -1
  11. package/dist/commonjs/__tests__/zones.test.js +2 -9
  12. package/dist/commonjs/__tests__/zones.test.js.map +1 -1
  13. package/dist/commonjs/admin-funcs/doAdmin.d.ts +5 -4
  14. package/dist/commonjs/admin-funcs/doAdmin.d.ts.map +1 -1
  15. package/dist/commonjs/admin-funcs/doAdmin.js +10 -5
  16. package/dist/commonjs/admin-funcs/doAdmin.js.map +1 -1
  17. package/dist/commonjs/admin-funcs/subscriptionFinishScreeningQuestions.d.ts +3 -2
  18. package/dist/commonjs/admin-funcs/subscriptionFinishScreeningQuestions.d.ts.map +1 -1
  19. package/dist/commonjs/admin-funcs/subscriptionFinishScreeningQuestions.js +2 -1
  20. package/dist/commonjs/admin-funcs/subscriptionFinishScreeningQuestions.js.map +1 -1
  21. package/dist/commonjs/admin-funcs/subscriptionPlanSelection.d.ts +7 -0
  22. package/dist/commonjs/admin-funcs/subscriptionPlanSelection.d.ts.map +1 -0
  23. package/dist/commonjs/admin-funcs/subscriptionPlanSelection.js +45 -0
  24. package/dist/commonjs/admin-funcs/subscriptionPlanSelection.js.map +1 -0
  25. package/dist/commonjs/admin-funcs/subscriptionUpdateVendorType.d.ts +3 -2
  26. package/dist/commonjs/admin-funcs/subscriptionUpdateVendorType.d.ts.map +1 -1
  27. package/dist/commonjs/admin-funcs/subscriptionUpdateVendorType.js +2 -1
  28. package/dist/commonjs/admin-funcs/subscriptionUpdateVendorType.js.map +1 -1
  29. package/dist/commonjs/admin-funcs/zoneDevicesUpdate.d.ts +2 -0
  30. package/dist/commonjs/admin-funcs/zoneDevicesUpdate.d.ts.map +1 -1
  31. package/dist/commonjs/admin-funcs/zoneDevicesUpdate.js.map +1 -1
  32. package/dist/commonjs/funcs/invoicesConvertQuote.d.ts +1 -4
  33. package/dist/commonjs/funcs/invoicesConvertQuote.d.ts.map +1 -1
  34. package/dist/commonjs/funcs/invoicesConvertQuote.js +2 -6
  35. package/dist/commonjs/funcs/invoicesConvertQuote.js.map +1 -1
  36. package/dist/commonjs/funcs/vendorsCreateVendorCompany.d.ts +1 -1
  37. package/dist/commonjs/funcs/vendorsCreateVendorCompany.d.ts.map +1 -1
  38. package/dist/commonjs/funcs/vendorsCreateVendorCompany.js +1 -1
  39. package/dist/commonjs/funcs/vendorsCreateVendorCompany.js.map +1 -1
  40. package/dist/commonjs/lib/config.d.ts +4 -4
  41. package/dist/commonjs/lib/config.js +4 -4
  42. package/dist/commonjs/lib/config.js.map +1 -1
  43. package/dist/commonjs/models/components/fhirconfig.d.ts +12 -0
  44. package/dist/commonjs/models/components/fhirconfig.d.ts.map +1 -1
  45. package/dist/commonjs/models/components/fhirconfig.js +4 -0
  46. package/dist/commonjs/models/components/fhirconfig.js.map +1 -1
  47. package/dist/commonjs/models/components/invoice.d.ts +0 -5
  48. package/dist/commonjs/models/components/invoice.d.ts.map +1 -1
  49. package/dist/commonjs/models/components/invoice.js +0 -4
  50. package/dist/commonjs/models/components/invoice.js.map +1 -1
  51. package/dist/commonjs/models/operations/convertquote.d.ts +0 -21
  52. package/dist/commonjs/models/operations/convertquote.d.ts.map +1 -1
  53. package/dist/commonjs/models/operations/convertquote.js +1 -18
  54. package/dist/commonjs/models/operations/convertquote.js.map +1 -1
  55. package/dist/commonjs/models/operations/createinvoice.d.ts +0 -25
  56. package/dist/commonjs/models/operations/createinvoice.d.ts.map +1 -1
  57. package/dist/commonjs/models/operations/createinvoice.js +0 -10
  58. package/dist/commonjs/models/operations/createinvoice.js.map +1 -1
  59. package/dist/commonjs/react-query/invoicesConvertQuote.d.ts +1 -4
  60. package/dist/commonjs/react-query/invoicesConvertQuote.d.ts.map +1 -1
  61. package/dist/commonjs/react-query/invoicesConvertQuote.js +1 -4
  62. package/dist/commonjs/react-query/invoicesConvertQuote.js.map +1 -1
  63. package/dist/commonjs/react-query/vendorsCreateVendorCompany.d.ts +1 -1
  64. package/dist/commonjs/react-query/vendorsCreateVendorCompany.d.ts.map +1 -1
  65. package/dist/commonjs/react-query/vendorsCreateVendorCompany.js.map +1 -1
  66. package/dist/commonjs/sdk/invoices.d.ts +1 -4
  67. package/dist/commonjs/sdk/invoices.d.ts.map +1 -1
  68. package/dist/commonjs/sdk/invoices.js +1 -4
  69. package/dist/commonjs/sdk/invoices.js.map +1 -1
  70. package/dist/esm/__tests__/fhirconfigs.test.js +18 -0
  71. package/dist/esm/__tests__/fhirconfigs.test.js.map +1 -1
  72. package/dist/esm/__tests__/subscriptionPlanSelection.test.d.ts +2 -0
  73. package/dist/esm/__tests__/subscriptionPlanSelection.test.d.ts.map +1 -0
  74. package/dist/esm/__tests__/subscriptionPlanSelection.test.js +34 -0
  75. package/dist/esm/__tests__/subscriptionPlanSelection.test.js.map +1 -0
  76. package/dist/esm/__tests__/vendors.test.js +1 -1
  77. package/dist/esm/__tests__/webhooks.test.js +6 -5
  78. package/dist/esm/__tests__/webhooks.test.js.map +1 -1
  79. package/dist/esm/__tests__/zones.test.js +2 -9
  80. package/dist/esm/__tests__/zones.test.js.map +1 -1
  81. package/dist/esm/admin-funcs/doAdmin.d.ts +5 -4
  82. package/dist/esm/admin-funcs/doAdmin.d.ts.map +1 -1
  83. package/dist/esm/admin-funcs/doAdmin.js +10 -5
  84. package/dist/esm/admin-funcs/doAdmin.js.map +1 -1
  85. package/dist/esm/admin-funcs/subscriptionFinishScreeningQuestions.d.ts +3 -2
  86. package/dist/esm/admin-funcs/subscriptionFinishScreeningQuestions.d.ts.map +1 -1
  87. package/dist/esm/admin-funcs/subscriptionFinishScreeningQuestions.js +2 -1
  88. package/dist/esm/admin-funcs/subscriptionFinishScreeningQuestions.js.map +1 -1
  89. package/dist/esm/admin-funcs/subscriptionPlanSelection.d.ts +7 -0
  90. package/dist/esm/admin-funcs/subscriptionPlanSelection.d.ts.map +1 -0
  91. package/dist/esm/admin-funcs/subscriptionPlanSelection.js +9 -0
  92. package/dist/esm/admin-funcs/subscriptionPlanSelection.js.map +1 -0
  93. package/dist/esm/admin-funcs/subscriptionUpdateVendorType.d.ts +3 -2
  94. package/dist/esm/admin-funcs/subscriptionUpdateVendorType.d.ts.map +1 -1
  95. package/dist/esm/admin-funcs/subscriptionUpdateVendorType.js +2 -1
  96. package/dist/esm/admin-funcs/subscriptionUpdateVendorType.js.map +1 -1
  97. package/dist/esm/admin-funcs/zoneDevicesUpdate.d.ts +2 -0
  98. package/dist/esm/admin-funcs/zoneDevicesUpdate.d.ts.map +1 -1
  99. package/dist/esm/admin-funcs/zoneDevicesUpdate.js.map +1 -1
  100. package/dist/esm/funcs/invoicesConvertQuote.d.ts +1 -4
  101. package/dist/esm/funcs/invoicesConvertQuote.d.ts.map +1 -1
  102. package/dist/esm/funcs/invoicesConvertQuote.js +3 -7
  103. package/dist/esm/funcs/invoicesConvertQuote.js.map +1 -1
  104. package/dist/esm/funcs/vendorsCreateVendorCompany.d.ts +1 -1
  105. package/dist/esm/funcs/vendorsCreateVendorCompany.d.ts.map +1 -1
  106. package/dist/esm/funcs/vendorsCreateVendorCompany.js +1 -1
  107. package/dist/esm/funcs/vendorsCreateVendorCompany.js.map +1 -1
  108. package/dist/esm/lib/config.d.ts +4 -4
  109. package/dist/esm/lib/config.js +4 -4
  110. package/dist/esm/lib/config.js.map +1 -1
  111. package/dist/esm/models/components/fhirconfig.d.ts +12 -0
  112. package/dist/esm/models/components/fhirconfig.d.ts.map +1 -1
  113. package/dist/esm/models/components/fhirconfig.js +4 -0
  114. package/dist/esm/models/components/fhirconfig.js.map +1 -1
  115. package/dist/esm/models/components/invoice.d.ts +0 -5
  116. package/dist/esm/models/components/invoice.d.ts.map +1 -1
  117. package/dist/esm/models/components/invoice.js +0 -4
  118. package/dist/esm/models/components/invoice.js.map +1 -1
  119. package/dist/esm/models/operations/convertquote.d.ts +0 -21
  120. package/dist/esm/models/operations/convertquote.d.ts.map +1 -1
  121. package/dist/esm/models/operations/convertquote.js +0 -16
  122. package/dist/esm/models/operations/convertquote.js.map +1 -1
  123. package/dist/esm/models/operations/createinvoice.d.ts +0 -25
  124. package/dist/esm/models/operations/createinvoice.d.ts.map +1 -1
  125. package/dist/esm/models/operations/createinvoice.js +0 -10
  126. package/dist/esm/models/operations/createinvoice.js.map +1 -1
  127. package/dist/esm/react-query/invoicesConvertQuote.d.ts +1 -4
  128. package/dist/esm/react-query/invoicesConvertQuote.d.ts.map +1 -1
  129. package/dist/esm/react-query/invoicesConvertQuote.js +1 -4
  130. package/dist/esm/react-query/invoicesConvertQuote.js.map +1 -1
  131. package/dist/esm/react-query/vendorsCreateVendorCompany.d.ts +1 -1
  132. package/dist/esm/react-query/vendorsCreateVendorCompany.d.ts.map +1 -1
  133. package/dist/esm/react-query/vendorsCreateVendorCompany.js.map +1 -1
  134. package/dist/esm/sdk/invoices.d.ts +1 -4
  135. package/dist/esm/sdk/invoices.d.ts.map +1 -1
  136. package/dist/esm/sdk/invoices.js +1 -4
  137. package/dist/esm/sdk/invoices.js.map +1 -1
  138. package/jsr.json +1 -1
  139. package/package.json +1 -1
  140. package/src/__tests__/fhirconfigs.test.ts +18 -0
  141. package/src/__tests__/subscriptionPlanSelection.test.ts +53 -0
  142. package/src/__tests__/vendors.test.ts +1 -1
  143. package/src/__tests__/webhooks.test.ts +6 -5
  144. package/src/__tests__/zones.test.ts +2 -9
  145. package/src/admin-funcs/doAdmin.ts +24 -11
  146. package/src/admin-funcs/subscriptionFinishScreeningQuestions.ts +11 -3
  147. package/src/admin-funcs/subscriptionPlanSelection.ts +17 -0
  148. package/src/admin-funcs/subscriptionUpdateVendorType.ts +11 -3
  149. package/src/admin-funcs/zoneDevicesUpdate.ts +4 -0
  150. package/src/funcs/invoicesConvertQuote.ts +3 -7
  151. package/src/funcs/vendorsCreateVendorCompany.ts +4 -0
  152. package/src/lib/config.ts +4 -4
  153. package/src/models/components/fhirconfig.ts +12 -0
  154. package/src/models/components/invoice.ts +0 -9
  155. package/src/models/operations/convertquote.ts +0 -46
  156. package/src/models/operations/createinvoice.ts +0 -35
  157. package/src/react-query/invoicesConvertQuote.ts +1 -4
  158. package/src/react-query/vendorsCreateVendorCompany.ts +1 -0
  159. package/src/sdk/invoices.ts +1 -4
@@ -0,0 +1,53 @@
1
+ import { describe, expect, it, vi } from "vitest";
2
+
3
+ const { doPostMock } = vi.hoisted(() => ({
4
+ doPostMock: vi.fn(() => Promise.resolve([{ ok: true }, { status: "complete" }])),
5
+ }));
6
+
7
+ vi.mock("../admin-funcs/doAdmin.js", () => ({
8
+ $doPost: doPostMock,
9
+ }));
10
+
11
+ import { subscriptionFinishScreeningQuestions } from "../admin-funcs/subscriptionFinishScreeningQuestions.js";
12
+ import { subscriptionPlanSelectionResponse$inboundSchema } from "../admin-funcs/subscriptionPlanSelection.js";
13
+ import { subscriptionUpdateVendorType } from "../admin-funcs/subscriptionUpdateVendorType.js";
14
+
15
+ // GSSD-7289: both steps answer whether the vendor has a plan to choose, and the SDK holds the
16
+ // server to it.
17
+ describe("subscription plan selection responses", () => {
18
+ it("validates finishing the screening questions against the plan selection schema", () => {
19
+ subscriptionFinishScreeningQuestions({ vendor_id: 7 });
20
+
21
+ expect(doPostMock).toHaveBeenCalledWith(
22
+ "/subscription/screening-questions",
23
+ { vendor_id: 7 },
24
+ undefined,
25
+ subscriptionPlanSelectionResponse$inboundSchema,
26
+ );
27
+ });
28
+
29
+ it("validates choosing a vendor type against the plan selection schema", () => {
30
+ subscriptionUpdateVendorType({ vendor_id: 7, vendor_type_id: [10] });
31
+
32
+ expect(doPostMock).toHaveBeenCalledWith(
33
+ "/subscription/vendor-type",
34
+ { vendor_id: 7, vendor_type_id: [10] },
35
+ undefined,
36
+ subscriptionPlanSelectionResponse$inboundSchema,
37
+ );
38
+ });
39
+
40
+ it("accepts a response that says whether a plan must be chosen, keeping other fields", () => {
41
+ const parsed = subscriptionPlanSelectionResponse$inboundSchema.parse({
42
+ success: true,
43
+ plan_selection_required: false,
44
+ extra: 1,
45
+ });
46
+
47
+ expect(parsed).toEqual({ success: true, plan_selection_required: false, extra: 1 });
48
+ });
49
+
50
+ it("rejects a response without plan_selection_required", () => {
51
+ expect(subscriptionPlanSelectionResponse$inboundSchema.safeParse({ success: true }).success).toBe(false);
52
+ });
53
+ });
@@ -121,7 +121,7 @@ test("Vendors List Vendor Credits", async () => {
121
121
  page: 1,
122
122
  useUrlParams: false,
123
123
  },
124
- creditBalance: 3896.88,
124
+ creditBalance: 5488.14,
125
125
  });
126
126
  });
127
127
 
@@ -20,7 +20,7 @@ test("Webhooks List All Webhook Endpoints", async () => {
20
20
  const testWebhookListForVendorUserResult = await greenSecurity.webhooks
21
21
  .listAllWebhookEndpoints({
22
22
  itemsPerPage: 25,
23
- desc: 0,
23
+ desc: true,
24
24
  sort: "",
25
25
  });
26
26
  expect(testWebhookListForVendorUserResult).toBeDefined();
@@ -62,10 +62,11 @@ test("Webhooks Updates The Webhook Endpoint With The Given Id", async () => {
62
62
  id: 220782,
63
63
  webhookEndpointUpdate: {
64
64
  webhookUrl: "https://example.com/webhook/incoming",
65
- subscriptions: [
66
- "Vendor.updated",
67
- "Vendor.created",
68
- ],
65
+ subscriptions: {
66
+ model: "Vendor",
67
+ action: "updated",
68
+ expands: "vendor.company,vendor.user",
69
+ },
69
70
  consumers: {
70
71
  systemId: 1,
71
72
  facilityId: 1,
@@ -39,14 +39,7 @@ test("Zones List Or Search Security Zones", async () => {
39
39
  facility: {},
40
40
  },
41
41
  {
42
- facility: {
43
- contacts: null,
44
- vendorGuestPolicy: {
45
- enabled: true,
46
- vendorGuestLimitAndOr: "and",
47
- vendorGuestRequireEmail: false,
48
- },
49
- },
42
+ facility: {},
50
43
  },
51
44
  ],
52
45
  });
@@ -65,7 +58,7 @@ test("Zones Security Zone Checkin", async () => {
65
58
 
66
59
  const result = await greenSecurity.zones.securityZoneCheckin({
67
60
  qrCode: "<value>",
68
- zoneId: 679291,
61
+ zoneId: 544883,
69
62
  });
70
63
  expect(result).toBeDefined();
71
64
  expect(result).toEqual({});
@@ -20,9 +20,11 @@ import { Result } from "../types/fp.js";
20
20
  import { getInternalCore } from "./initializeCore.js";
21
21
  import { encodeJSON } from "../lib/encodings.js";
22
22
 
23
- export type internalApiResult = APIPromise<
23
+ // An internal call whose response is validated against a schema for `T` (see $doPost's
24
+ // responseSchema). internalApiResult is the untyped default.
25
+ export type internalApiResultOf<T> = APIPromise<
24
26
  Result<
25
- Json,
27
+ T,
26
28
  | errors.ApiErrorResponse
27
29
  | GreenSecurityError
28
30
  | SDKValidationError
@@ -34,6 +36,8 @@ export type internalApiResult = APIPromise<
34
36
  >
35
37
  >;
36
38
 
39
+ export type internalApiResult = internalApiResultOf<Json>;
40
+
37
41
  // This creates a generic JSON schema that can be used to validate any JSON object
38
42
  const literalSchema = z.union([z.string(), z.number(), z.boolean(), z.null()]);
39
43
  type Literal = z.infer<typeof literalSchema>;
@@ -201,10 +205,10 @@ export async function $doGetSingle<T extends object>(
201
205
  return [result, { status: "complete", request: req, response }];
202
206
  }
203
207
 
204
- type BodyResult = Promise<
208
+ type BodyResult<T = Json> = Promise<
205
209
  [
206
210
  Result<
207
- Json,
211
+ T,
208
212
  | errors.ApiErrorResponse
209
213
  | GreenSecurityError
210
214
  | ResponseValidationError
@@ -222,13 +226,18 @@ type BodyResult = Promise<
222
226
  // Shared by the JSON and multipart requests below: everything except the method, how the body
223
227
  // is built and whether we name a Content-Type. A multipart body must NOT carry one, because only
224
228
  // fetch can append the boundary it generates.
225
- async function $doBodyRequest(
229
+ async function $doBodyRequest<R = Json>(
226
230
  method: "POST" | "PUT",
227
231
  route: string,
228
232
  body: BodyInit | undefined,
229
233
  contentTypeHeader: Record<string, string>,
230
234
  options?: RequestOptions,
231
- ): BodyResult {
235
+ responseSchema?: z.ZodType<R>,
236
+ ): BodyResult<R> {
237
+ // Without a schema the body is only checked to be JSON, which is every caller before typed
238
+ // responses existed.
239
+ const schema = (responseSchema ?? jsonSchema) as z.ZodType<R>;
240
+
232
241
  const client = getInternalCore();
233
242
  if (!client) {
234
243
  throw new Error("GreenSecurityCore client is not initialized.");
@@ -290,7 +299,7 @@ async function $doBodyRequest(
290
299
  };
291
300
 
292
301
  const [result] = await M.match<
293
- Json,
302
+ R,
294
303
  | errors.ApiErrorResponse
295
304
  | GreenSecurityError
296
305
  | ResponseValidationError
@@ -301,10 +310,10 @@ async function $doBodyRequest(
301
310
  | RequestTimeoutError
302
311
  | ConnectionError
303
312
  >(
304
- M.json(200, jsonSchema),
313
+ M.json(200, schema),
305
314
  // A REST create answers 201, which matches none of the cases below — an unmatched status is
306
315
  // an error, so the caller saw a failure for a request the server had accepted.
307
- M.json(201, jsonSchema),
316
+ M.json(201, schema),
308
317
  // 422 is a real answer here, not a surprise: the create returns it for a refused certificate
309
318
  // and for a model validation failure. Left out, it fell through to M.fail("4XX"), which
310
319
  // yields a generic APIError and hides the server's message from the form.
@@ -319,17 +328,21 @@ async function $doBodyRequest(
319
328
  return [result, { status: "complete", request: req, response }];
320
329
  }
321
330
 
322
- export async function $doPost<T extends object>(
331
+ // Pass responseSchema to validate and type the 200/201 body; a body that does not match it comes
332
+ // back as a ResponseValidationError instead of being handed to the caller.
333
+ export async function $doPost<T extends object, R = Json>(
323
334
  route: string,
324
335
  postData: T,
325
336
  options?: RequestOptions,
326
- ): BodyResult {
337
+ responseSchema?: z.ZodType<R>,
338
+ ): BodyResult<R> {
327
339
  return $doBodyRequest(
328
340
  "POST",
329
341
  route,
330
342
  encodeJSON("body", postData, { explode: true }),
331
343
  { "Content-Type": "application/json" },
332
344
  options,
345
+ responseSchema,
333
346
  );
334
347
  }
335
348
 
@@ -1,13 +1,21 @@
1
1
  import { APIPromise } from "../types/async.js";
2
- import { $doPost, internalApiResult } from "./doAdmin.js";
2
+ import { $doPost, internalApiResultOf } from "./doAdmin.js";
3
+ import {
4
+ subscriptionPlanSelectionResponse,
5
+ subscriptionPlanSelectionResponse$inboundSchema,
6
+ } from "./subscriptionPlanSelection.js";
3
7
 
4
8
  export type subscriptionFinishScreeningQuestionsRequest = {
5
9
  vendor_id: number;
6
10
  };
7
11
 
8
- export function subscriptionFinishScreeningQuestions(request: subscriptionFinishScreeningQuestionsRequest): internalApiResult {
12
+ export function subscriptionFinishScreeningQuestions(
13
+ request: subscriptionFinishScreeningQuestionsRequest,
14
+ ): internalApiResultOf<subscriptionPlanSelectionResponse> {
9
15
  return new APIPromise($doPost(
10
16
  "/subscription/screening-questions",
11
- request
17
+ request,
18
+ undefined,
19
+ subscriptionPlanSelectionResponse$inboundSchema,
12
20
  ));
13
21
  }
@@ -0,0 +1,17 @@
1
+ import * as z from "zod/v3";
2
+
3
+ // What finishing the screening questions or choosing a vendor type answers. GSSD-7289.
4
+ export type subscriptionPlanSelectionResponse = {
5
+ success: boolean;
6
+ // false when Standard is the vendor's only plan (e.g. Level 1, which cannot buy Emerald): the
7
+ // server has already selected it, so the plan step is skipped and the next step is the invoice.
8
+ plan_selection_required: boolean;
9
+ };
10
+
11
+ // Unknown fields pass through, so the server can add to the response without breaking callers.
12
+ export const subscriptionPlanSelectionResponse$inboundSchema: z.ZodType<subscriptionPlanSelectionResponse> = z
13
+ .object({
14
+ success: z.boolean(),
15
+ plan_selection_required: z.boolean(),
16
+ })
17
+ .passthrough();
@@ -1,14 +1,22 @@
1
1
  import { APIPromise } from "../types/async.js";
2
- import { $doPost, internalApiResult } from "./doAdmin.js";
2
+ import { $doPost, internalApiResultOf } from "./doAdmin.js";
3
+ import {
4
+ subscriptionPlanSelectionResponse,
5
+ subscriptionPlanSelectionResponse$inboundSchema,
6
+ } from "./subscriptionPlanSelection.js";
3
7
 
4
8
  export type subscriptionUpdateVendorTypeRequest = {
5
9
  vendor_id: number;
6
10
  vendor_type_id: number[];
7
11
  };
8
12
 
9
- export function subscriptionUpdateVendorType(request: subscriptionUpdateVendorTypeRequest): internalApiResult {
13
+ export function subscriptionUpdateVendorType(
14
+ request: subscriptionUpdateVendorTypeRequest,
15
+ ): internalApiResultOf<subscriptionPlanSelectionResponse> {
10
16
  return new APIPromise($doPost(
11
17
  "/subscription/vendor-type",
12
- request
18
+ request,
19
+ undefined,
20
+ subscriptionPlanSelectionResponse$inboundSchema,
13
21
  ));
14
22
  }
@@ -9,6 +9,10 @@ export type zoneDevicesUpdateRequest = {
9
9
  network_id?: number;
10
10
  connection_type?: zoneDeviceConnectionType;
11
11
  name?: string;
12
+ // Sent once the app has pushed the network's current settings to the gateway; only a network edit sets it.
13
+ needs_network_update?: false;
14
+ // The provisioning response's network_revision for the settings that were pushed; required with the clear.
15
+ network_revision?: string;
12
16
  };
13
17
 
14
18
  // Edits a gateway from the Gatekeeper device details screen. This only updates the record; the
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  import { GreenSecurityCore } from "../core.js";
6
- import { encodeJSON, encodeSimple } from "../lib/encodings.js";
6
+ import { encodeSimple } from "../lib/encodings.js";
7
7
  import { matchStatusCode } from "../lib/http.js";
8
8
  import * as M from "../lib/matchers.js";
9
9
  import { compactMap } from "../lib/primitives.js";
@@ -43,10 +43,7 @@ import { Result } from "../types/fp.js";
43
43
  * invoices; a caller allowed to create the invoice but not to update the
44
44
  * linked `VendorCredential` responds `401`.
45
45
  *
46
- * Optionally takes `send_to_company_manager`, for a quote linked to a
47
- * `VendorCredential`: send `true` when the vendor is sending the
48
- * converted invoice to their company managers to pay instead of paying
49
- * it themselves. It follows the same rules as on `POST /invoices`.
46
+ * Takes no request body.
50
47
  *
51
48
  * **Permissions.** Requires a valid token. This endpoint is not gated on a named permission—the caller's role and their relationship to the record decide what it returns.
52
49
  *
@@ -107,7 +104,7 @@ async function $do(
107
104
  return [parsed, { status: "invalid" }];
108
105
  }
109
106
  const payload = parsed.value;
110
- const body = encodeJSON("body", payload.RequestBody, { explode: true });
107
+ const body = null;
111
108
 
112
109
  const pathParams = {
113
110
  id: encodeSimple("id", payload.id, {
@@ -118,7 +115,6 @@ async function $do(
118
115
  const path = pathToFunc("/invoices/{id}/convert")(pathParams);
119
116
 
120
117
  const headers = new Headers(compactMap({
121
- "Content-Type": "application/json",
122
118
  Accept: "application/json",
123
119
  }));
124
120
 
@@ -50,6 +50,7 @@ export function vendorsCreateVendorCompany(
50
50
  Result<
51
51
  operations.CreateVendorCompanyCreateVendorCompanyOk,
52
52
  | errors.ApiErrorResponse
53
+ | errors.UnprocessableEntityOrValidationError
53
54
  | GreenSecurityError
54
55
  | ResponseValidationError
55
56
  | ConnectionError
@@ -76,6 +77,7 @@ async function $do(
76
77
  Result<
77
78
  operations.CreateVendorCompanyCreateVendorCompanyOk,
78
79
  | errors.ApiErrorResponse
80
+ | errors.UnprocessableEntityOrValidationError
79
81
  | GreenSecurityError
80
82
  | ResponseValidationError
81
83
  | ConnectionError
@@ -165,6 +167,7 @@ async function $do(
165
167
  const [result] = await M.match<
166
168
  operations.CreateVendorCompanyCreateVendorCompanyOk,
167
169
  | errors.ApiErrorResponse
170
+ | errors.UnprocessableEntityOrValidationError
168
171
  | GreenSecurityError
169
172
  | ResponseValidationError
170
173
  | ConnectionError
@@ -179,6 +182,7 @@ async function $do(
179
182
  operations.CreateVendorCompanyCreateVendorCompanyOk$inboundSchema,
180
183
  ),
181
184
  M.jsonErr([400, 401, 403, 404], errors.ApiErrorResponse$inboundSchema),
185
+ M.jsonErr(422, errors.UnprocessableEntityOrValidationError$inboundSchema),
182
186
  M.fail("4XX"),
183
187
  M.fail([500, "5XX"]),
184
188
  )(response, req, { extraFields: responseFields });
package/src/lib/config.ts CHANGED
@@ -79,9 +79,9 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
79
79
 
80
80
  export const SDK_METADATA = {
81
81
  language: "typescript",
82
- openapiDocVersion: "0.47.0",
83
- sdkVersion: "0.48.0-beta.9",
84
- genVersion: "2.950.13",
82
+ openapiDocVersion: "0.48.0",
83
+ sdkVersion: "0.48.0",
84
+ genVersion: "2.952.5",
85
85
  userAgent:
86
- "speakeasy-sdk/typescript 0.48.0-beta.9 2.950.13 0.47.0 @greensecurity/javascript-sdk",
86
+ "speakeasy-sdk/typescript 0.48.0 2.952.5 0.48.0 @greensecurity/javascript-sdk",
87
87
  } as const;
@@ -47,6 +47,10 @@ export type ProductionProfile = {
47
47
  * The private key used to sign token requests to the production FHIR instance.
48
48
  */
49
49
  privateKey?: string | undefined;
50
+ /**
51
+ * Extra HTTP headers to send with the token request and with every FHIR request to the production instance, as a map of header name to value. Merged over the headers the client sets itself, so an entry named `Authorization`, `Content-Type` or `Accept` replaces the default. Empty when the facility's gateway needs none, which is the usual case. A value may be a credential, so this field is only served to callers allowed to see this configuration's secrets.
52
+ */
53
+ customHeaders?: { [k: string]: string } | undefined;
50
54
  /**
51
55
  * Relative path of the self-hosted JSON Web Key (JWK) Set URL (JKU) serving this configuration's production public signing keys.
52
56
  */
@@ -97,6 +101,10 @@ export type NonProductionProfile = {
97
101
  * The private key used to sign token requests to the non-production FHIR instance.
98
102
  */
99
103
  privateKeyNp?: string | undefined;
104
+ /**
105
+ * Extra HTTP headers to send with the token request and with every FHIR request to the non-production instance, as a map of header name to value. Merged over the headers the client sets itself, so an entry named `Authorization`, `Content-Type` or `Accept` replaces the default. Empty when the facility's gateway needs none, which is the usual case. A value may be a credential, so this field is only served to callers allowed to see this configuration's secrets.
106
+ */
107
+ customHeadersNp?: { [k: string]: string } | undefined;
100
108
  /**
101
109
  * Relative path of the self-hosted JWK Set URL (JKU) serving this configuration's non-production public signing keys.
102
110
  */
@@ -221,6 +229,7 @@ export const ProductionProfile$inboundSchema: z.ZodType<
221
229
  patient_list_url: types.optional(types.string()),
222
230
  patient_list_id: types.optional(types.string()),
223
231
  private_key: types.optional(types.string()),
232
+ custom_headers: types.optional(z.record(types.string())),
224
233
  jku_path: types.optional(types.string()),
225
234
  jku_url: z.nullable(types.string()).optional(),
226
235
  signing_kid: z.nullable(types.string()).optional(),
@@ -234,6 +243,7 @@ export const ProductionProfile$inboundSchema: z.ZodType<
234
243
  "patient_list_url": "patientListUrl",
235
244
  "patient_list_id": "patientListId",
236
245
  "private_key": "privateKey",
246
+ "custom_headers": "customHeaders",
237
247
  "jku_path": "jkuPath",
238
248
  "jku_url": "jkuUrl",
239
249
  "signing_kid": "signingKid",
@@ -264,6 +274,7 @@ export const NonProductionProfile$inboundSchema: z.ZodType<
264
274
  patient_list_url_np: types.optional(types.string()),
265
275
  patient_list_id_np: types.optional(types.string()),
266
276
  private_key_np: types.optional(types.string()),
277
+ custom_headers_np: types.optional(z.record(types.string())),
267
278
  jku_path_np: types.optional(types.string()),
268
279
  jku_url_np: z.nullable(types.string()).optional(),
269
280
  signing_kid_np: z.nullable(types.string()).optional(),
@@ -277,6 +288,7 @@ export const NonProductionProfile$inboundSchema: z.ZodType<
277
288
  "patient_list_url_np": "patientListUrlNp",
278
289
  "patient_list_id_np": "patientListIdNp",
279
290
  "private_key_np": "privateKeyNp",
291
+ "custom_headers_np": "customHeadersNp",
280
292
  "jku_path_np": "jkuPathNp",
281
293
  "jku_url_np": "jkuUrlNp",
282
294
  "signing_kid_np": "signingKidNp",
@@ -141,10 +141,6 @@ export type Invoice = {
141
141
  * When the invoice was created.
142
142
  */
143
143
  dateCreated?: string | null | undefined;
144
- /**
145
- * When the vendor sent this invoice to their company managers to pay instead of paying it themselves (`send_to_company_manager` on `POST /invoices` or `POST /invoices/{id}/convert`). `null` if it was never sent, or if the vendor took it back or settled it themselves. It is kept on an invoice the managers paid, and on one that was later voided.
146
- */
147
- dateSentToCompanyManager?: string | null | undefined;
148
144
  /**
149
145
  * The date the invoice payment is due. `null` if no due date is set.
150
146
  */
@@ -397,7 +393,6 @@ export const Invoice$inboundSchema: z.ZodType<Invoice, z.ZodTypeDef, unknown> =
397
393
  date_processed: z.nullable(types.string()).optional(),
398
394
  date_paid: z.nullable(types.string()).optional(),
399
395
  date_created: z.nullable(types.string()).optional(),
400
- date_sent_to_company_manager: z.nullable(types.string()).optional(),
401
396
  date_due: z.nullable(types.string()).optional(),
402
397
  amount: z.nullable(types.number()).optional(),
403
398
  status: z.nullable(types.string()).optional(),
@@ -426,7 +421,6 @@ export const Invoice$inboundSchema: z.ZodType<Invoice, z.ZodTypeDef, unknown> =
426
421
  "date_processed": "dateProcessed",
427
422
  "date_paid": "datePaid",
428
423
  "date_created": "dateCreated",
429
- "date_sent_to_company_manager": "dateSentToCompanyManager",
430
424
  "date_due": "dateDue",
431
425
  "financial_status": "financialStatus",
432
426
  "amount_not_paid": "amountNotPaid",
@@ -445,7 +439,6 @@ export type Invoice$Outbound = {
445
439
  date_processed?: string | null | undefined;
446
440
  date_paid?: string | null | undefined;
447
441
  date_created?: string | null | undefined;
448
- date_sent_to_company_manager?: string | null | undefined;
449
442
  date_due?: string | null | undefined;
450
443
  amount?: number | null | undefined;
451
444
  status?: string | null | undefined;
@@ -478,7 +471,6 @@ export const Invoice$outboundSchema: z.ZodType<
478
471
  dateProcessed: z.nullable(z.string()).optional(),
479
472
  datePaid: z.nullable(z.string()).optional(),
480
473
  dateCreated: z.nullable(z.string()).optional(),
481
- dateSentToCompanyManager: z.nullable(z.string()).optional(),
482
474
  dateDue: z.nullable(z.string()).optional(),
483
475
  amount: z.nullable(z.number().int()).optional(),
484
476
  status: z.nullable(z.string()).optional(),
@@ -506,7 +498,6 @@ export const Invoice$outboundSchema: z.ZodType<
506
498
  dateProcessed: "date_processed",
507
499
  datePaid: "date_paid",
508
500
  dateCreated: "date_created",
509
- dateSentToCompanyManager: "date_sent_to_company_manager",
510
501
  dateDue: "date_due",
511
502
  financialStatus: "financial_status",
512
503
  amountNotPaid: "amount_not_paid",
@@ -9,25 +9,11 @@ import { Result as SafeParseResult } from "../../types/fp.js";
9
9
  import * as types from "../../types/primitives.js";
10
10
  import { SDKValidationError } from "../errors/sdkvalidationerror.js";
11
11
 
12
- /**
13
- * Whether the vendor is sending the converted invoice to their company managers.
14
- */
15
- export type ConvertQuoteRequestBody = {
16
- /**
17
- * Set to `true` when the vendor is sending the converted invoice to their company managers to pay instead of paying it themselves, and `false` to take it back. Recorded on the invoice as `date_sent_to_company_manager`; the managers are asked to pay once the credential is submitted. Omit the field to leave the invoice as it is. Ignored when no `VendorCredential` is linked to the quote, for an invoice with nothing left to pay, and when the caller is not the vendor. A vendor whose company has no active company manager who sends `true` is refused with `400` and the quote is not converted.
18
- */
19
- sendToCompanyManager?: boolean | undefined;
20
- };
21
-
22
12
  export type ConvertQuoteRequest = {
23
13
  /**
24
14
  * The identifier of the object.
25
15
  */
26
16
  id: number;
27
- /**
28
- * Whether the vendor is sending the converted invoice to their company managers.
29
- */
30
- requestBody?: ConvertQuoteRequestBody | undefined;
31
17
  };
32
18
 
33
19
  /**
@@ -57,36 +43,9 @@ export type ConvertQuoteConvertQuoteOk = {
57
43
  total?: number | null | undefined;
58
44
  };
59
45
 
60
- /** @internal */
61
- export type ConvertQuoteRequestBody$Outbound = {
62
- send_to_company_manager?: boolean | undefined;
63
- };
64
-
65
- /** @internal */
66
- export const ConvertQuoteRequestBody$outboundSchema: z.ZodType<
67
- ConvertQuoteRequestBody$Outbound,
68
- z.ZodTypeDef,
69
- ConvertQuoteRequestBody
70
- > = z.object({
71
- sendToCompanyManager: z.boolean().optional(),
72
- }).transform((v) => {
73
- return remap$(v, {
74
- sendToCompanyManager: "send_to_company_manager",
75
- });
76
- });
77
-
78
- export function convertQuoteRequestBodyToJSON(
79
- convertQuoteRequestBody: ConvertQuoteRequestBody,
80
- ): string {
81
- return JSON.stringify(
82
- ConvertQuoteRequestBody$outboundSchema.parse(convertQuoteRequestBody),
83
- );
84
- }
85
-
86
46
  /** @internal */
87
47
  export type ConvertQuoteRequest$Outbound = {
88
48
  id: number;
89
- RequestBody?: ConvertQuoteRequestBody$Outbound | undefined;
90
49
  };
91
50
 
92
51
  /** @internal */
@@ -96,11 +55,6 @@ export const ConvertQuoteRequest$outboundSchema: z.ZodType<
96
55
  ConvertQuoteRequest
97
56
  > = z.object({
98
57
  id: z.number().int(),
99
- requestBody: z.lazy(() => ConvertQuoteRequestBody$outboundSchema).optional(),
100
- }).transform((v) => {
101
- return remap$(v, {
102
- requestBody: "RequestBody",
103
- });
104
58
  });
105
59
 
106
60
  export function convertQuoteRequestToJSON(