@greensecurity/javascript-sdk 0.43.1-beta.115 → 0.43.1-beta.116

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 (176) hide show
  1. package/README.md +6 -0
  2. package/dist/commonjs/__tests__/users.test.js +100 -0
  3. package/dist/commonjs/__tests__/users.test.js.map +1 -1
  4. package/dist/commonjs/__tests__/webhooks.test.js +1 -1
  5. package/dist/commonjs/__tests__/webhooks.test.js.map +1 -1
  6. package/dist/commonjs/__tests__/zones.test.js +14 -31
  7. package/dist/commonjs/__tests__/zones.test.js.map +1 -1
  8. package/dist/commonjs/funcs/usersUpdateUser.d.ts +26 -0
  9. package/dist/commonjs/funcs/usersUpdateUser.d.ts.map +1 -0
  10. package/dist/commonjs/funcs/usersUpdateUser.js +131 -0
  11. package/dist/commonjs/funcs/usersUpdateUser.js.map +1 -0
  12. package/dist/commonjs/funcs/usersUpdateUserProfilePicture.d.ts +20 -0
  13. package/dist/commonjs/funcs/usersUpdateUserProfilePicture.d.ts.map +1 -0
  14. package/dist/commonjs/funcs/usersUpdateUserProfilePicture.js +126 -0
  15. package/dist/commonjs/funcs/usersUpdateUserProfilePicture.js.map +1 -0
  16. package/dist/commonjs/funcs/vendorFieldsCreateVendorField.d.ts +3 -2
  17. package/dist/commonjs/funcs/vendorFieldsCreateVendorField.d.ts.map +1 -1
  18. package/dist/commonjs/funcs/vendorFieldsCreateVendorField.js +3 -2
  19. package/dist/commonjs/funcs/vendorFieldsCreateVendorField.js.map +1 -1
  20. package/dist/commonjs/lib/config.d.ts +2 -2
  21. package/dist/commonjs/lib/config.js +2 -2
  22. package/dist/commonjs/models/components/company.d.ts +5 -0
  23. package/dist/commonjs/models/components/company.d.ts.map +1 -1
  24. package/dist/commonjs/models/components/company.js +4 -0
  25. package/dist/commonjs/models/components/company.js.map +1 -1
  26. package/dist/commonjs/models/components/companyvendorfield.d.ts +16 -0
  27. package/dist/commonjs/models/components/companyvendorfield.d.ts.map +1 -0
  28. package/dist/commonjs/models/components/companyvendorfield.js +60 -0
  29. package/dist/commonjs/models/components/companyvendorfield.js.map +1 -0
  30. package/dist/commonjs/models/components/expand.d.ts +2 -0
  31. package/dist/commonjs/models/components/expand.d.ts.map +1 -1
  32. package/dist/commonjs/models/components/expand.js +2 -0
  33. package/dist/commonjs/models/components/expand.js.map +1 -1
  34. package/dist/commonjs/models/components/index.d.ts +1 -0
  35. package/dist/commonjs/models/components/index.d.ts.map +1 -1
  36. package/dist/commonjs/models/components/index.js +1 -0
  37. package/dist/commonjs/models/components/index.js.map +1 -1
  38. package/dist/commonjs/models/components/vendor.d.ts +1 -0
  39. package/dist/commonjs/models/components/vendor.d.ts.map +1 -1
  40. package/dist/commonjs/models/components/vendor.js +2 -0
  41. package/dist/commonjs/models/components/vendor.js.map +1 -1
  42. package/dist/commonjs/models/operations/index.d.ts +2 -0
  43. package/dist/commonjs/models/operations/index.d.ts.map +1 -1
  44. package/dist/commonjs/models/operations/index.js +2 -0
  45. package/dist/commonjs/models/operations/index.js.map +1 -1
  46. package/dist/commonjs/models/operations/updateuser.d.ts +74 -0
  47. package/dist/commonjs/models/operations/updateuser.d.ts.map +1 -0
  48. package/dist/commonjs/models/operations/updateuser.js +96 -0
  49. package/dist/commonjs/models/operations/updateuser.js.map +1 -0
  50. package/dist/commonjs/models/operations/updateuserprofilepicture.d.ts +70 -0
  51. package/dist/commonjs/models/operations/updateuserprofilepicture.d.ts.map +1 -0
  52. package/dist/commonjs/models/operations/updateuserprofilepicture.js +93 -0
  53. package/dist/commonjs/models/operations/updateuserprofilepicture.js.map +1 -0
  54. package/dist/commonjs/react-query/index.d.ts +2 -0
  55. package/dist/commonjs/react-query/index.d.ts.map +1 -1
  56. package/dist/commonjs/react-query/index.js +2 -0
  57. package/dist/commonjs/react-query/index.js.map +1 -1
  58. package/dist/commonjs/react-query/usersUpdateUser.d.ts +35 -0
  59. package/dist/commonjs/react-query/usersUpdateUser.d.ts.map +1 -0
  60. package/dist/commonjs/react-query/usersUpdateUser.js +53 -0
  61. package/dist/commonjs/react-query/usersUpdateUser.js.map +1 -0
  62. package/dist/commonjs/react-query/usersUpdateUserProfilePicture.d.ts +29 -0
  63. package/dist/commonjs/react-query/usersUpdateUserProfilePicture.d.ts.map +1 -0
  64. package/dist/commonjs/react-query/usersUpdateUserProfilePicture.js +47 -0
  65. package/dist/commonjs/react-query/usersUpdateUserProfilePicture.js.map +1 -0
  66. package/dist/commonjs/react-query/vendorFieldsCreateVendorField.d.ts +3 -2
  67. package/dist/commonjs/react-query/vendorFieldsCreateVendorField.d.ts.map +1 -1
  68. package/dist/commonjs/react-query/vendorFieldsCreateVendorField.js +3 -2
  69. package/dist/commonjs/react-query/vendorFieldsCreateVendorField.js.map +1 -1
  70. package/dist/commonjs/sdk/users.d.ts +20 -0
  71. package/dist/commonjs/sdk/users.d.ts.map +1 -1
  72. package/dist/commonjs/sdk/users.js +26 -0
  73. package/dist/commonjs/sdk/users.js.map +1 -1
  74. package/dist/commonjs/sdk/vendorfields.d.ts +3 -2
  75. package/dist/commonjs/sdk/vendorfields.d.ts.map +1 -1
  76. package/dist/commonjs/sdk/vendorfields.js +3 -2
  77. package/dist/commonjs/sdk/vendorfields.js.map +1 -1
  78. package/dist/esm/__tests__/users.test.js +100 -0
  79. package/dist/esm/__tests__/users.test.js.map +1 -1
  80. package/dist/esm/__tests__/webhooks.test.js +1 -1
  81. package/dist/esm/__tests__/webhooks.test.js.map +1 -1
  82. package/dist/esm/__tests__/zones.test.js +14 -31
  83. package/dist/esm/__tests__/zones.test.js.map +1 -1
  84. package/dist/esm/funcs/usersUpdateUser.d.ts +26 -0
  85. package/dist/esm/funcs/usersUpdateUser.d.ts.map +1 -0
  86. package/dist/esm/funcs/usersUpdateUser.js +95 -0
  87. package/dist/esm/funcs/usersUpdateUser.js.map +1 -0
  88. package/dist/esm/funcs/usersUpdateUserProfilePicture.d.ts +20 -0
  89. package/dist/esm/funcs/usersUpdateUserProfilePicture.d.ts.map +1 -0
  90. package/dist/esm/funcs/usersUpdateUserProfilePicture.js +90 -0
  91. package/dist/esm/funcs/usersUpdateUserProfilePicture.js.map +1 -0
  92. package/dist/esm/funcs/vendorFieldsCreateVendorField.d.ts +3 -2
  93. package/dist/esm/funcs/vendorFieldsCreateVendorField.d.ts.map +1 -1
  94. package/dist/esm/funcs/vendorFieldsCreateVendorField.js +3 -2
  95. package/dist/esm/funcs/vendorFieldsCreateVendorField.js.map +1 -1
  96. package/dist/esm/lib/config.d.ts +2 -2
  97. package/dist/esm/lib/config.js +2 -2
  98. package/dist/esm/models/components/company.d.ts +5 -0
  99. package/dist/esm/models/components/company.d.ts.map +1 -1
  100. package/dist/esm/models/components/company.js +4 -0
  101. package/dist/esm/models/components/company.js.map +1 -1
  102. package/dist/esm/models/components/companyvendorfield.d.ts +16 -0
  103. package/dist/esm/models/components/companyvendorfield.d.ts.map +1 -0
  104. package/dist/esm/models/components/companyvendorfield.js +23 -0
  105. package/dist/esm/models/components/companyvendorfield.js.map +1 -0
  106. package/dist/esm/models/components/expand.d.ts +2 -0
  107. package/dist/esm/models/components/expand.d.ts.map +1 -1
  108. package/dist/esm/models/components/expand.js +2 -0
  109. package/dist/esm/models/components/expand.js.map +1 -1
  110. package/dist/esm/models/components/index.d.ts +1 -0
  111. package/dist/esm/models/components/index.d.ts.map +1 -1
  112. package/dist/esm/models/components/index.js +1 -0
  113. package/dist/esm/models/components/index.js.map +1 -1
  114. package/dist/esm/models/components/vendor.d.ts +1 -0
  115. package/dist/esm/models/components/vendor.d.ts.map +1 -1
  116. package/dist/esm/models/components/vendor.js +2 -0
  117. package/dist/esm/models/components/vendor.js.map +1 -1
  118. package/dist/esm/models/operations/index.d.ts +2 -0
  119. package/dist/esm/models/operations/index.d.ts.map +1 -1
  120. package/dist/esm/models/operations/index.js +2 -0
  121. package/dist/esm/models/operations/index.js.map +1 -1
  122. package/dist/esm/models/operations/updateuser.d.ts +74 -0
  123. package/dist/esm/models/operations/updateuser.d.ts.map +1 -0
  124. package/dist/esm/models/operations/updateuser.js +57 -0
  125. package/dist/esm/models/operations/updateuser.js.map +1 -0
  126. package/dist/esm/models/operations/updateuserprofilepicture.d.ts +70 -0
  127. package/dist/esm/models/operations/updateuserprofilepicture.d.ts.map +1 -0
  128. package/dist/esm/models/operations/updateuserprofilepicture.js +54 -0
  129. package/dist/esm/models/operations/updateuserprofilepicture.js.map +1 -0
  130. package/dist/esm/react-query/index.d.ts +2 -0
  131. package/dist/esm/react-query/index.d.ts.map +1 -1
  132. package/dist/esm/react-query/index.js +2 -0
  133. package/dist/esm/react-query/index.js.map +1 -1
  134. package/dist/esm/react-query/usersUpdateUser.d.ts +35 -0
  135. package/dist/esm/react-query/usersUpdateUser.d.ts.map +1 -0
  136. package/dist/esm/react-query/usersUpdateUser.js +48 -0
  137. package/dist/esm/react-query/usersUpdateUser.js.map +1 -0
  138. package/dist/esm/react-query/usersUpdateUserProfilePicture.d.ts +29 -0
  139. package/dist/esm/react-query/usersUpdateUserProfilePicture.d.ts.map +1 -0
  140. package/dist/esm/react-query/usersUpdateUserProfilePicture.js +42 -0
  141. package/dist/esm/react-query/usersUpdateUserProfilePicture.js.map +1 -0
  142. package/dist/esm/react-query/vendorFieldsCreateVendorField.d.ts +3 -2
  143. package/dist/esm/react-query/vendorFieldsCreateVendorField.d.ts.map +1 -1
  144. package/dist/esm/react-query/vendorFieldsCreateVendorField.js +3 -2
  145. package/dist/esm/react-query/vendorFieldsCreateVendorField.js.map +1 -1
  146. package/dist/esm/sdk/users.d.ts +20 -0
  147. package/dist/esm/sdk/users.d.ts.map +1 -1
  148. package/dist/esm/sdk/users.js +26 -0
  149. package/dist/esm/sdk/users.js.map +1 -1
  150. package/dist/esm/sdk/vendorfields.d.ts +3 -2
  151. package/dist/esm/sdk/vendorfields.d.ts.map +1 -1
  152. package/dist/esm/sdk/vendorfields.js +3 -2
  153. package/dist/esm/sdk/vendorfields.js.map +1 -1
  154. package/jsr.json +1 -1
  155. package/package.json +1 -1
  156. package/src/__tests__/users.test.ts +106 -0
  157. package/src/__tests__/webhooks.test.ts +1 -1
  158. package/src/__tests__/zones.test.ts +14 -31
  159. package/src/funcs/usersUpdateUser.ts +182 -0
  160. package/src/funcs/usersUpdateUserProfilePicture.ts +181 -0
  161. package/src/funcs/vendorFieldsCreateVendorField.ts +3 -2
  162. package/src/lib/config.ts +2 -2
  163. package/src/models/components/company.ts +11 -0
  164. package/src/models/components/companyvendorfield.ts +47 -0
  165. package/src/models/components/expand.ts +2 -0
  166. package/src/models/components/index.ts +1 -0
  167. package/src/models/components/vendor.ts +3 -0
  168. package/src/models/operations/index.ts +2 -0
  169. package/src/models/operations/updateuser.ts +156 -0
  170. package/src/models/operations/updateuserprofilepicture.ts +154 -0
  171. package/src/react-query/index.ts +2 -0
  172. package/src/react-query/usersUpdateUser.ts +116 -0
  173. package/src/react-query/usersUpdateUserProfilePicture.ts +111 -0
  174. package/src/react-query/vendorFieldsCreateVendorField.ts +3 -2
  175. package/src/sdk/users.ts +42 -0
  176. package/src/sdk/vendorfields.ts +3 -2
@@ -91,3 +91,109 @@ test("Users Switch Account", async () => {
91
91
  userToken: {},
92
92
  });
93
93
  });
94
+
95
+ test("Users Update User", async () => {
96
+ const testHttpClient = createTestHTTPClient("updateUser");
97
+
98
+ const greenSecurity = new GreenSecurity({
99
+ serverURL: process.env["TEST_SERVER_URL"] ?? "https://localhost:3000/api",
100
+ httpClient: testHttpClient,
101
+ security: {
102
+ token: process.env["GREEN_SECURITY_TOKEN"] ?? "value",
103
+ },
104
+ });
105
+
106
+ const result = await greenSecurity.users.updateUser({
107
+ id: "<id>",
108
+ requestBody: {
109
+ timezone: "America/New_York",
110
+ },
111
+ });
112
+ expect(result).toBeDefined();
113
+ expect(result).toEqual({
114
+ user: {
115
+ isGatekeeper: true,
116
+ success: true,
117
+ user: {
118
+ id: 123,
119
+ firstName: "John",
120
+ lastName: "Doe",
121
+ email: "john@example.com",
122
+ phone: "555-555-5555",
123
+ userType: "Facility User",
124
+ timezone: "America/Chicago",
125
+ },
126
+ userToken: {
127
+ token: "WDCINRKRKYQ3TUEUEUEHEGWN6WKXP7N12345C8CSHQVJD7D6I",
128
+ tokenType: "permanent",
129
+ },
130
+ vendor: {
131
+ badge: {
132
+ badgeType: "rfid",
133
+ },
134
+ vendorJob: {
135
+ id: 154462,
136
+ job: "Account Representatives/Managers|Account Executive",
137
+ },
138
+ primaryFacility: {
139
+ contacts: {
140
+ contact: {
141
+ status: "Deleted",
142
+ department: 123,
143
+ },
144
+ adminContact: {
145
+ status: "Inactive",
146
+ department: 123,
147
+ },
148
+ techContact: {
149
+ status: "Deleted",
150
+ department: 123,
151
+ },
152
+ greenSecurityCsm: {
153
+ status: "Inactive",
154
+ department: 123,
155
+ },
156
+ accountManager: {
157
+ status: "Inactive",
158
+ department: 123,
159
+ },
160
+ },
161
+ vendorGuestPolicy: {
162
+ enabled: true,
163
+ vendorGuestLimitAndOr: "and",
164
+ vendorGuestRequireEmail: true,
165
+ },
166
+ },
167
+ },
168
+ contact: {
169
+ status: "Deleted",
170
+ department: 123,
171
+ },
172
+ },
173
+ });
174
+ });
175
+
176
+ test("Users Update User Profile Picture", async () => {
177
+ const testHttpClient = createTestHTTPClient("updateUserProfilePicture");
178
+
179
+ const greenSecurity = new GreenSecurity({
180
+ serverURL: process.env["TEST_SERVER_URL"] ?? "https://localhost:3000/api",
181
+ httpClient: testHttpClient,
182
+ security: {
183
+ token: process.env["GREEN_SECURITY_TOKEN"] ?? "value",
184
+ },
185
+ });
186
+
187
+ const result = await greenSecurity.users.updateUserProfilePicture({
188
+ idOrMe: "<value>",
189
+ requestBody: {
190
+ imageFileName: "<value>",
191
+ imageContentType: "image/jpeg",
192
+ imageFileSize: 443381,
193
+ },
194
+ });
195
+ expect(result).toBeDefined();
196
+ expect(result).toEqual({
197
+ id: 541107,
198
+ });
199
+ });
@@ -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();
@@ -39,52 +39,36 @@ test("Zones List Or Search Security Zones", async () => {
39
39
  facility: {
40
40
  contacts: {
41
41
  contact: {
42
- status: "Inactive",
42
+ status: "Deleted",
43
43
  department: 123,
44
44
  },
45
- adminContact: null,
46
- techContact: {
47
- status: "Inactive",
45
+ adminContact: {
46
+ status: "Active",
48
47
  department: 123,
49
48
  },
50
- greenSecurityCsm: {
49
+ techContact: {
51
50
  status: "Deleted",
52
51
  department: 123,
53
52
  },
54
- accountManager: null,
55
- },
56
- vendorGuestPolicy: {
57
- enabled: true,
58
- vendorGuestLimitAndOr: "and",
59
- vendorGuestRequireEmail: true,
60
- },
61
- },
62
- },
63
- {
64
- facility: {
65
- contacts: {
66
- contact: {
67
- status: "Inactive",
68
- department: 123,
69
- },
70
- adminContact: null,
71
- techContact: {
53
+ greenSecurityCsm: {
72
54
  status: "Inactive",
73
55
  department: 123,
74
56
  },
75
- greenSecurityCsm: {
76
- status: "Deleted",
57
+ accountManager: {
58
+ status: "Active",
77
59
  department: 123,
78
60
  },
79
- accountManager: null,
80
61
  },
81
62
  vendorGuestPolicy: {
82
- enabled: true,
63
+ enabled: false,
83
64
  vendorGuestLimitAndOr: "and",
84
- vendorGuestRequireEmail: true,
65
+ vendorGuestRequireEmail: false,
85
66
  },
86
67
  },
87
68
  },
69
+ {
70
+ facility: {},
71
+ },
88
72
  ],
89
73
  });
90
74
  });
@@ -101,9 +85,8 @@ test("Zones Security Zone Checkin", async () => {
101
85
  });
102
86
 
103
87
  const result = await greenSecurity.zones.securityZoneCheckin({
104
- longitude: 5514.78,
105
- latitude: 3322.97,
106
- zoneId: 97443,
88
+ qrCode: "<value>",
89
+ zoneId: 185875,
107
90
  });
108
91
  expect(result).toBeDefined();
109
92
  expect(result).toEqual({});
@@ -0,0 +1,182 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { GreenSecurityCore } from "../core.js";
6
+ import { encodeJSON, encodeSimple } from "../lib/encodings.js";
7
+ import * as M from "../lib/matchers.js";
8
+ import { compactMap } from "../lib/primitives.js";
9
+ import { safeParse } from "../lib/schemas.js";
10
+ import { RequestOptions } from "../lib/sdks.js";
11
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
12
+ import { pathToFunc } from "../lib/url.js";
13
+ import { GreenSecurityError } from "../models/errors/greensecurityerror.js";
14
+ import {
15
+ ConnectionError,
16
+ InvalidRequestError,
17
+ RequestAbortedError,
18
+ RequestTimeoutError,
19
+ UnexpectedClientError,
20
+ } from "../models/errors/httpclienterrors.js";
21
+ import * as errors from "../models/errors/index.js";
22
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
23
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
24
+ import * as operations from "../models/operations/index.js";
25
+ import { APICall, APIPromise } from "../types/async.js";
26
+ import { Result } from "../types/fp.js";
27
+
28
+ /**
29
+ * Update user by ID
30
+ *
31
+ * @remarks
32
+ * Updates the contact information, address, and locale settings of a user.
33
+ * Pass `me` as `{id}` to update the authenticated user's own profile.
34
+ *
35
+ * Only submitted fields are applied — unrecognised fields are silently ignored.
36
+ * Changing `email` automatically resets `bounced_email` to `false`.
37
+ *
38
+ * To rotate an API token use `POST /users/api_key_rotator` instead.
39
+ *
40
+ * If set, this operation will use {@link Security.bearerJwt} from the global security.
41
+ */
42
+ export function usersUpdateUser(
43
+ client: GreenSecurityCore,
44
+ request: operations.UpdateUserRequest,
45
+ options?: RequestOptions,
46
+ ): APIPromise<
47
+ Result<
48
+ operations.UpdateUserUpdateUserOk,
49
+ | errors.ApiErrorResponse
50
+ | GreenSecurityError
51
+ | ResponseValidationError
52
+ | ConnectionError
53
+ | RequestAbortedError
54
+ | RequestTimeoutError
55
+ | InvalidRequestError
56
+ | UnexpectedClientError
57
+ | SDKValidationError
58
+ >
59
+ > {
60
+ return new APIPromise($do(
61
+ client,
62
+ request,
63
+ options,
64
+ ));
65
+ }
66
+
67
+ async function $do(
68
+ client: GreenSecurityCore,
69
+ request: operations.UpdateUserRequest,
70
+ options?: RequestOptions,
71
+ ): Promise<
72
+ [
73
+ Result<
74
+ operations.UpdateUserUpdateUserOk,
75
+ | errors.ApiErrorResponse
76
+ | GreenSecurityError
77
+ | ResponseValidationError
78
+ | ConnectionError
79
+ | RequestAbortedError
80
+ | RequestTimeoutError
81
+ | InvalidRequestError
82
+ | UnexpectedClientError
83
+ | SDKValidationError
84
+ >,
85
+ APICall,
86
+ ]
87
+ > {
88
+ const parsed = safeParse(
89
+ request,
90
+ (value) => operations.UpdateUserRequest$outboundSchema.parse(value),
91
+ "Input validation failed",
92
+ );
93
+ if (!parsed.ok) {
94
+ return [parsed, { status: "invalid" }];
95
+ }
96
+ const payload = parsed.value;
97
+ const body = encodeJSON("body", payload.RequestBody, { explode: true });
98
+
99
+ const pathParams = {
100
+ id: encodeSimple("id", payload.id, {
101
+ explode: false,
102
+ charEncoding: "percent",
103
+ }),
104
+ };
105
+ const path = pathToFunc("/users/{id}")(pathParams);
106
+
107
+ const headers = new Headers(compactMap({
108
+ "Content-Type": "application/json",
109
+ Accept: "application/json",
110
+ }));
111
+
112
+ const securityInput = await extractSecurity(client._options.security);
113
+ const requestSecurity = resolveGlobalSecurity(securityInput, [1]);
114
+
115
+ const context = {
116
+ options: client._options,
117
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
118
+ operationID: "updateUser",
119
+ oAuth2Scopes: null,
120
+
121
+ resolvedSecurity: requestSecurity,
122
+
123
+ securitySource: client._options.security,
124
+ retryConfig: options?.retries
125
+ || client._options.retryConfig
126
+ || { strategy: "none" },
127
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
128
+ };
129
+
130
+ const requestRes = client._createRequest(context, {
131
+ security: requestSecurity,
132
+ method: "PUT",
133
+ baseURL: options?.serverURL,
134
+ path: path,
135
+ headers: headers,
136
+ body: body,
137
+ userAgent: client._options.userAgent,
138
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
139
+ }, options);
140
+ if (!requestRes.ok) {
141
+ return [requestRes, { status: "invalid" }];
142
+ }
143
+ const req = requestRes.value;
144
+
145
+ const doResult = await client._do(req, {
146
+ context,
147
+ errorCodes: ["400", "401", "403", "404", "422", "4XX", "500", "5XX"],
148
+ retryConfig: context.retryConfig,
149
+ retryCodes: context.retryCodes,
150
+ });
151
+ if (!doResult.ok) {
152
+ return [doResult, { status: "request-error", request: req }];
153
+ }
154
+ const response = doResult.value;
155
+
156
+ const responseFields = {
157
+ HttpMeta: { Response: response, Request: req },
158
+ };
159
+
160
+ const [result] = await M.match<
161
+ operations.UpdateUserUpdateUserOk,
162
+ | errors.ApiErrorResponse
163
+ | GreenSecurityError
164
+ | ResponseValidationError
165
+ | ConnectionError
166
+ | RequestAbortedError
167
+ | RequestTimeoutError
168
+ | InvalidRequestError
169
+ | UnexpectedClientError
170
+ | SDKValidationError
171
+ >(
172
+ M.json(200, operations.UpdateUserUpdateUserOk$inboundSchema),
173
+ M.jsonErr([400, 401, 403, 404, 422], errors.ApiErrorResponse$inboundSchema),
174
+ M.fail("4XX"),
175
+ M.fail([500, "5XX"]),
176
+ )(response, req, { extraFields: responseFields });
177
+ if (!result.ok) {
178
+ return [result, { status: "complete", request: req, response }];
179
+ }
180
+
181
+ return [result, { status: "complete", request: req, response }];
182
+ }
@@ -0,0 +1,181 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { GreenSecurityCore } from "../core.js";
6
+ import { encodeJSON, encodeSimple } from "../lib/encodings.js";
7
+ import * as M from "../lib/matchers.js";
8
+ import { compactMap } from "../lib/primitives.js";
9
+ import { safeParse } from "../lib/schemas.js";
10
+ import { RequestOptions } from "../lib/sdks.js";
11
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
12
+ import { pathToFunc } from "../lib/url.js";
13
+ import { GreenSecurityError } from "../models/errors/greensecurityerror.js";
14
+ import {
15
+ ConnectionError,
16
+ InvalidRequestError,
17
+ RequestAbortedError,
18
+ RequestTimeoutError,
19
+ UnexpectedClientError,
20
+ } from "../models/errors/httpclienterrors.js";
21
+ import * as errors from "../models/errors/index.js";
22
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
23
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
24
+ import * as operations from "../models/operations/index.js";
25
+ import { APICall, APIPromise } from "../types/async.js";
26
+ import { Result } from "../types/fp.js";
27
+
28
+ /**
29
+ * Register profile picture metadata for S3 direct upload
30
+ *
31
+ * @remarks
32
+ * Register profile picture metadata for a user. The client should then upload the file directly to S3 at user_profile_image/{id}.{ext}. An AWS Lambda function processes the image (resize to tiny/thumb/large) and triggers a callback. Use 'me' as the id for the authenticated user. Requires authentication and either self-ownership or 'users:edit' permission. API users must be authorized via MarketplaceAppActivation.
33
+ *
34
+ * If set, this operation will use {@link Security.bearerJwt} from the global security.
35
+ */
36
+ export function usersUpdateUserProfilePicture(
37
+ client: GreenSecurityCore,
38
+ request: operations.UpdateUserProfilePictureRequest,
39
+ options?: RequestOptions,
40
+ ): APIPromise<
41
+ Result<
42
+ operations.UpdateUserProfilePictureUpdateUserProfilePictureOk,
43
+ | errors.ApiErrorResponse
44
+ | GreenSecurityError
45
+ | ResponseValidationError
46
+ | ConnectionError
47
+ | RequestAbortedError
48
+ | RequestTimeoutError
49
+ | InvalidRequestError
50
+ | UnexpectedClientError
51
+ | SDKValidationError
52
+ >
53
+ > {
54
+ return new APIPromise($do(
55
+ client,
56
+ request,
57
+ options,
58
+ ));
59
+ }
60
+
61
+ async function $do(
62
+ client: GreenSecurityCore,
63
+ request: operations.UpdateUserProfilePictureRequest,
64
+ options?: RequestOptions,
65
+ ): Promise<
66
+ [
67
+ Result<
68
+ operations.UpdateUserProfilePictureUpdateUserProfilePictureOk,
69
+ | errors.ApiErrorResponse
70
+ | GreenSecurityError
71
+ | ResponseValidationError
72
+ | ConnectionError
73
+ | RequestAbortedError
74
+ | RequestTimeoutError
75
+ | InvalidRequestError
76
+ | UnexpectedClientError
77
+ | SDKValidationError
78
+ >,
79
+ APICall,
80
+ ]
81
+ > {
82
+ const parsed = safeParse(
83
+ request,
84
+ (value) =>
85
+ operations.UpdateUserProfilePictureRequest$outboundSchema.parse(value),
86
+ "Input validation failed",
87
+ );
88
+ if (!parsed.ok) {
89
+ return [parsed, { status: "invalid" }];
90
+ }
91
+ const payload = parsed.value;
92
+ const body = encodeJSON("body", payload.RequestBody, { explode: true });
93
+
94
+ const pathParams = {
95
+ id_or_me: encodeSimple("id_or_me", payload.id_or_me, {
96
+ explode: false,
97
+ charEncoding: "percent",
98
+ }),
99
+ };
100
+ const path = pathToFunc("/users/{id_or_me}/profile_picture")(pathParams);
101
+
102
+ const headers = new Headers(compactMap({
103
+ "Content-Type": "application/json",
104
+ Accept: "application/json",
105
+ }));
106
+
107
+ const securityInput = await extractSecurity(client._options.security);
108
+ const requestSecurity = resolveGlobalSecurity(securityInput, [1]);
109
+
110
+ const context = {
111
+ options: client._options,
112
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
113
+ operationID: "updateUserProfilePicture",
114
+ oAuth2Scopes: null,
115
+
116
+ resolvedSecurity: requestSecurity,
117
+
118
+ securitySource: client._options.security,
119
+ retryConfig: options?.retries
120
+ || client._options.retryConfig
121
+ || { strategy: "none" },
122
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
123
+ };
124
+
125
+ const requestRes = client._createRequest(context, {
126
+ security: requestSecurity,
127
+ method: "PUT",
128
+ baseURL: options?.serverURL,
129
+ path: path,
130
+ headers: headers,
131
+ body: body,
132
+ userAgent: client._options.userAgent,
133
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
134
+ }, options);
135
+ if (!requestRes.ok) {
136
+ return [requestRes, { status: "invalid" }];
137
+ }
138
+ const req = requestRes.value;
139
+
140
+ const doResult = await client._do(req, {
141
+ context,
142
+ errorCodes: ["400", "401", "403", "404", "422", "4XX", "500", "5XX"],
143
+ retryConfig: context.retryConfig,
144
+ retryCodes: context.retryCodes,
145
+ });
146
+ if (!doResult.ok) {
147
+ return [doResult, { status: "request-error", request: req }];
148
+ }
149
+ const response = doResult.value;
150
+
151
+ const responseFields = {
152
+ HttpMeta: { Response: response, Request: req },
153
+ };
154
+
155
+ const [result] = await M.match<
156
+ operations.UpdateUserProfilePictureUpdateUserProfilePictureOk,
157
+ | errors.ApiErrorResponse
158
+ | GreenSecurityError
159
+ | ResponseValidationError
160
+ | ConnectionError
161
+ | RequestAbortedError
162
+ | RequestTimeoutError
163
+ | InvalidRequestError
164
+ | UnexpectedClientError
165
+ | SDKValidationError
166
+ >(
167
+ M.json(
168
+ 200,
169
+ operations
170
+ .UpdateUserProfilePictureUpdateUserProfilePictureOk$inboundSchema,
171
+ ),
172
+ M.jsonErr([400, 401, 403, 404], errors.ApiErrorResponse$inboundSchema),
173
+ M.fail([422, "4XX"]),
174
+ M.fail([500, "5XX"]),
175
+ )(response, req, { extraFields: responseFields });
176
+ if (!result.ok) {
177
+ return [result, { status: "complete", request: req, response }];
178
+ }
179
+
180
+ return [result, { status: "complete", request: req, response }];
181
+ }
@@ -29,8 +29,9 @@ import { Result } from "../types/fp.js";
29
29
  * Create vendor field
30
30
  *
31
31
  * @remarks
32
- * Create a new vendor field for a company. The name can only be set on creation;
33
- * once created, only the show_to_vendor flag can be updated via PATCH.
32
+ * Create a new vendor field for a company. Each company may have at most one custom
33
+ * vendor field; if one already exists, the request fails with 422. The name can only
34
+ * be set on creation; once created, only the show_to_vendor flag can be updated via PATCH.
34
35
  * Requires access to the company (company manager, admin, or API user with company scope).
35
36
  *
36
37
  * For API users: source_user_id is required. The API user acts on behalf of that user
package/src/lib/config.ts CHANGED
@@ -80,8 +80,8 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
80
80
  export const SDK_METADATA = {
81
81
  language: "typescript",
82
82
  openapiDocVersion: "0.0.11",
83
- sdkVersion: "0.43.1-beta.114",
83
+ sdkVersion: "0.43.1-beta.115",
84
84
  genVersion: "2.879.6",
85
85
  userAgent:
86
- "speakeasy-sdk/typescript 0.43.1-beta.114 2.879.6 0.0.11 @greensecurity/javascript-sdk",
86
+ "speakeasy-sdk/typescript 0.43.1-beta.115 2.879.6 0.0.11 @greensecurity/javascript-sdk",
87
87
  } as const;
@@ -8,6 +8,10 @@ import { safeParse } from "../../lib/schemas.js";
8
8
  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
+ import {
12
+ CompanyVendorField,
13
+ CompanyVendorField$inboundSchema,
14
+ } from "./companyvendorfield.js";
11
15
  import {
12
16
  CompanyVendorTypeRestriction,
13
17
  CompanyVendorTypeRestriction$inboundSchema,
@@ -56,6 +60,10 @@ export type Company = {
56
60
  contact?: CompanyContact | undefined;
57
61
  tax?: Tax | undefined;
58
62
  stats?: Stats | undefined;
63
+ /**
64
+ * Result of expanding `company.vendor_fields` on the company object.
65
+ */
66
+ vendorFields?: Array<CompanyVendorField> | null | undefined;
59
67
  vendorTypeRestrictions?:
60
68
  | Array<CompanyVendorTypeRestriction | null>
61
69
  | null
@@ -176,12 +184,15 @@ export const Company$inboundSchema: z.ZodType<Company, z.ZodTypeDef, unknown> =
176
184
  contact: types.optional(z.lazy(() => CompanyContact$inboundSchema)),
177
185
  tax: types.optional(z.lazy(() => Tax$inboundSchema)),
178
186
  stats: types.optional(z.lazy(() => Stats$inboundSchema)),
187
+ vendor_fields: z.nullable(z.array(CompanyVendorField$inboundSchema))
188
+ .optional(),
179
189
  vendor_type_restrictions: z.nullable(
180
190
  z.array(types.nullable(CompanyVendorTypeRestriction$inboundSchema)),
181
191
  ).optional(),
182
192
  }).transform((v) => {
183
193
  return remap$(v, {
184
194
  "credit_balance": "creditBalance",
195
+ "vendor_fields": "vendorFields",
185
196
  "vendor_type_restrictions": "vendorTypeRestrictions",
186
197
  });
187
198
  });
@@ -0,0 +1,47 @@
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 * as types from "../../types/primitives.js";
10
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
11
+
12
+ /**
13
+ * A vendor field definition created by a company.
14
+ */
15
+ export type CompanyVendorField = {
16
+ id: number;
17
+ name: string;
18
+ showToVendor: boolean;
19
+ fieldType: string;
20
+ };
21
+
22
+ /** @internal */
23
+ export const CompanyVendorField$inboundSchema: z.ZodType<
24
+ CompanyVendorField,
25
+ z.ZodTypeDef,
26
+ unknown
27
+ > = z.object({
28
+ id: types.number(),
29
+ name: types.string(),
30
+ show_to_vendor: types.boolean(),
31
+ field_type: types.string(),
32
+ }).transform((v) => {
33
+ return remap$(v, {
34
+ "show_to_vendor": "showToVendor",
35
+ "field_type": "fieldType",
36
+ });
37
+ });
38
+
39
+ export function companyVendorFieldFromJSON(
40
+ jsonString: string,
41
+ ): SafeParseResult<CompanyVendorField, SDKValidationError> {
42
+ return safeParse(
43
+ jsonString,
44
+ (x) => CompanyVendorField$inboundSchema.parse(JSON.parse(x)),
45
+ `Failed to parse 'CompanyVendorField' from JSON`,
46
+ );
47
+ }
@@ -11,6 +11,8 @@ import { ClosedEnum } from "../../types/enums.js";
11
11
  export const Expand = {
12
12
  User: "user",
13
13
  CompanyLocation: "company.location",
14
+ CompanyVendorFields: "company.vendor_fields",
15
+ CompanyVendorTypeRestrictions: "company.vendor_type_restrictions",
14
16
  ContactFacility: "contact.facility",
15
17
  ContactSystem: "contact.system",
16
18
  ContactDepartment: "contact.department",
@@ -7,6 +7,7 @@ export * from "./alert.js";
7
7
  export * from "./backgroundcheckresult.js";
8
8
  export * from "./company.js";
9
9
  export * from "./companymanager.js";
10
+ export * from "./companyvendorfield.js";
10
11
  export * from "./companyvendortyperestriction.js";
11
12
  export * from "./contact.js";
12
13
  export * from "./contenttype.js";