@workos-inc/node 10.11.0 → 10.12.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.
@@ -321,7 +321,7 @@ var FetchHttpClient = class FetchHttpClient extends HttpClient {
321
321
  message: `Request timeout after ${timeout}ms`,
322
322
  response: {
323
323
  status: 408,
324
- headers: {},
324
+ headers: new Headers(),
325
325
  data: { error: "Request timeout" }
326
326
  }
327
327
  });
@@ -610,10 +610,11 @@ var UnprocessableEntityException = class extends Error {
610
610
  message = "Unprocessable entity";
611
611
  code;
612
612
  requestID;
613
- constructor({ code, errors, message, requestID }) {
613
+ constructor({ code, error, errors, message, requestID }) {
614
614
  super();
615
615
  this.requestID = requestID;
616
616
  if (message) this.message = message;
617
+ else if (error) this.message = `Error: ${error}`;
617
618
  if (code) this.code = code;
618
619
  if (errors) {
619
620
  const requirement = errors.length === 1 ? "requirement" : "requirements";
@@ -1411,6 +1412,19 @@ const serializeCreateOrganizationOptions = (options) => ({
1411
1412
  metadata: options.metadata
1412
1413
  });
1413
1414
  //#endregion
1415
+ //#region src/organizations/serializers/it-contact-options.serializer.ts
1416
+ const serializeCreateItContactOptions = (options) => ({ email: options.email });
1417
+ const serializeInviteItContactOptions = (options) => ({ intents: options.intents });
1418
+ //#endregion
1419
+ //#region src/organizations/serializers/it-contact.serializer.ts
1420
+ const deserializeItContact = (itContact) => ({
1421
+ object: itContact.object,
1422
+ id: itContact.id,
1423
+ email: itContact.email,
1424
+ createdAt: itContact.created_at,
1425
+ updatedAt: itContact.updated_at
1426
+ });
1427
+ //#endregion
1414
1428
  //#region src/organizations/serializers/update-organization-options.serializer.ts
1415
1429
  const serializeUpdateOrganizationOptions = (options) => ({
1416
1430
  name: options.name,
@@ -1659,6 +1673,30 @@ const deserializeOrganizationDomainVerificationFailed = (organizationDomainVerif
1659
1673
  });
1660
1674
  //#endregion
1661
1675
  //#region src/common/serializers/event.serializer.ts
1676
+ const deserializePipesConnectedAccount = (connectedAccount) => ({
1677
+ object: connectedAccount.object,
1678
+ id: connectedAccount.id,
1679
+ dataIntegrationId: connectedAccount.data_integration_id,
1680
+ providerSlug: connectedAccount.provider_slug,
1681
+ userId: connectedAccount.user_id,
1682
+ organizationId: connectedAccount.organization_id,
1683
+ scopes: connectedAccount.scopes,
1684
+ state: connectedAccount.state,
1685
+ createdAt: connectedAccount.created_at,
1686
+ updatedAt: connectedAccount.updated_at
1687
+ });
1688
+ const deserializePipesConnectionFailed = (connectionFailed) => ({
1689
+ object: connectionFailed.object,
1690
+ dataIntegrationId: connectionFailed.data_integration_id,
1691
+ providerSlug: connectionFailed.provider_slug,
1692
+ userId: connectionFailed.user_id,
1693
+ organizationId: connectionFailed.organization_id,
1694
+ errorCode: connectionFailed.error_code,
1695
+ errorReason: connectionFailed.error_reason,
1696
+ providerError: connectionFailed.provider_error,
1697
+ providerErrorDescription: connectionFailed.provider_error_description,
1698
+ createdAt: connectionFailed.created_at
1699
+ });
1662
1700
  const deserializeEvent = (event) => {
1663
1701
  const eventBase = {
1664
1702
  id: event.id,
@@ -1851,6 +1889,18 @@ const deserializeEvent = (event) => {
1851
1889
  organizationMembershipId: event.data.organization_membership_id
1852
1890
  }
1853
1891
  };
1892
+ case "pipes.connected_account.connected":
1893
+ case "pipes.connected_account.disconnected":
1894
+ case "pipes.connected_account.reauthorization_needed": return {
1895
+ ...eventBase,
1896
+ event: event.event,
1897
+ data: deserializePipesConnectedAccount(event.data)
1898
+ };
1899
+ case "pipes.connected_account.connection_failed": return {
1900
+ ...eventBase,
1901
+ event: event.event,
1902
+ data: deserializePipesConnectionFailed(event.data)
1903
+ };
1854
1904
  case "vault.data.created": return {
1855
1905
  ...eventBase,
1856
1906
  event: event.event,
@@ -3049,6 +3099,88 @@ var Organizations = class {
3049
3099
  const { data } = await this.workos.put(`/organizations/${organizationId}`, serializeUpdateOrganizationOptions(payload));
3050
3100
  return deserializeOrganization(data);
3051
3101
  }
3102
+ /**
3103
+ * List IT Contacts
3104
+ *
3105
+ * Get the IT Contacts for an Organization.
3106
+ * @param options - Object containing the Organization ID.
3107
+ * @returns {Promise<List<ItContact>>}
3108
+ * @throws {AuthorizationException} 403
3109
+ * @throws {NotFoundException} 404
3110
+ */
3111
+ async listItContacts(options) {
3112
+ const { organizationId } = options;
3113
+ const { data } = await this.workos.get(`/organizations/${organizationId}/it_contacts`);
3114
+ return {
3115
+ object: data.object,
3116
+ data: data.data.map(deserializeItContact),
3117
+ listMetadata: {
3118
+ before: data.list_metadata.before,
3119
+ after: data.list_metadata.after
3120
+ }
3121
+ };
3122
+ }
3123
+ /**
3124
+ * Create an IT Contact
3125
+ *
3126
+ * Add an IT Contact to an Organization. No Admin Portal invitation is sent,
3127
+ * though the contact is notified if the Organization has a connection
3128
+ * certificate nearing expiry.
3129
+ * @param options - Object containing the Organization ID and the email address.
3130
+ * @returns {Promise<ItContact>}
3131
+ * @throws {AuthorizationException} 403
3132
+ * @throws {NotFoundException} 404
3133
+ * @throws {ConflictException} 409
3134
+ * @throws {UnprocessableEntityException} 422
3135
+ */
3136
+ async createItContact(options) {
3137
+ const { organizationId, ...payload } = options;
3138
+ const { data } = await this.workos.post(`/organizations/${organizationId}/it_contacts`, serializeCreateItContactOptions(payload));
3139
+ return deserializeItContact(data);
3140
+ }
3141
+ /**
3142
+ * Delete an IT Contact
3143
+ *
3144
+ * Remove an IT Contact from an Organization and revoke the contact's active
3145
+ * setup links.
3146
+ * @param options - Object containing the Organization ID and the IT Contact ID.
3147
+ * @returns {Promise<void>}
3148
+ * @throws {AuthorizationException} 403
3149
+ * @throws {NotFoundException} 404
3150
+ */
3151
+ async deleteItContact(options) {
3152
+ const { organizationId, contactId } = options;
3153
+ await this.workos.delete(`/organizations/${organizationId}/it_contacts/${contactId}`);
3154
+ }
3155
+ /**
3156
+ * Invite an IT Contact
3157
+ *
3158
+ * Create an Admin Portal setup link and email it to the IT Contact. An
3159
+ * Organization can have at most one active invitation.
3160
+ * @param options - Object containing the Organization ID, the IT Contact ID and the intents.
3161
+ * @returns {Promise<void>}
3162
+ * @throws {AuthorizationException} 403
3163
+ * @throws {NotFoundException} 404
3164
+ * @throws {ConflictException} 409
3165
+ * @throws {UnprocessableEntityException} 422
3166
+ */
3167
+ async inviteItContact(options) {
3168
+ const { organizationId, contactId, ...payload } = options;
3169
+ await this.workos.post(`/organizations/${organizationId}/it_contacts/${contactId}/invite`, serializeInviteItContactOptions(payload));
3170
+ }
3171
+ /**
3172
+ * Revoke an IT Contact's invitation
3173
+ *
3174
+ * Revoke the Organization's active Admin Portal invitation.
3175
+ * @param options - Object containing the Organization ID and the IT Contact ID.
3176
+ * @returns {Promise<void>}
3177
+ * @throws {AuthorizationException} 403
3178
+ * @throws {NotFoundException} 404
3179
+ */
3180
+ async revokeItContact(options) {
3181
+ const { organizationId, contactId } = options;
3182
+ await this.workos.post(`/organizations/${organizationId}/it_contacts/${contactId}/revoke`, {});
3183
+ }
3052
3184
  };
3053
3185
  //#endregion
3054
3186
  //#region src/organization-domains/serializers/create-organization-domain-options.serializer.ts
@@ -8138,7 +8270,7 @@ var Vault = class {
8138
8270
  };
8139
8271
  //#endregion
8140
8272
  //#region package.json
8141
- var version = "10.11.0";
8273
+ var version = "10.12.0";
8142
8274
  //#endregion
8143
8275
  //#region src/workos.ts
8144
8276
  const DEFAULT_HOSTNAME = "api.workos.com";
@@ -8369,7 +8501,7 @@ var WorkOS = class {
8369
8501
  const { response } = error;
8370
8502
  if (response) {
8371
8503
  const { status, data, headers } = response;
8372
- const requestID = headers["X-Request-ID"] ?? "";
8504
+ const requestID = headers.get("X-Request-ID") ?? "";
8373
8505
  const { code, error_description: errorDescription, error, errors, message } = data;
8374
8506
  switch (status) {
8375
8507
  case 401: throw new UnauthorizedException(requestID);
@@ -8381,6 +8513,7 @@ var WorkOS = class {
8381
8513
  });
8382
8514
  case 422: throw new UnprocessableEntityException({
8383
8515
  code,
8516
+ error,
8384
8517
  errors,
8385
8518
  message,
8386
8519
  requestID
@@ -8427,6 +8560,15 @@ let DomainDataState = /* @__PURE__ */ function(DomainDataState) {
8427
8560
  return DomainDataState;
8428
8561
  }({});
8429
8562
  //#endregion
8563
+ //#region src/organizations/interfaces/it-contact-options.interface.ts
8564
+ const ItContactIntent = {
8565
+ SSO: "sso",
8566
+ DirectorySync: "directory_sync",
8567
+ LogStreams: "log_streams",
8568
+ DomainVerification: "domain_verification",
8569
+ BringYourOwnKey: "bring_your_own_key"
8570
+ };
8571
+ //#endregion
8430
8572
  //#region src/organization-domains/interfaces/organization-domain.interface.ts
8431
8573
  let OrganizationDomainState = /* @__PURE__ */ function(OrganizationDomainState) {
8432
8574
  OrganizationDomainState["Verified"] = "verified";
@@ -8488,6 +8630,6 @@ function createWorkOS(options) {
8488
8630
  return new WorkOS(options);
8489
8631
  }
8490
8632
  //#endregion
8491
- export { FetchHttpClient as A, NoApiKeyProvidedException as C, isAuthenticationErrorData as D, AuthenticationException as E, GenericServerException as O, NotFoundException as S, BadRequestException as T, UnprocessableEntityException as _, DomainDataState as a, RateLimitExceededException as b, FeatureFlagsRuntimeClient as c, serializeRevokeSessionOptions as d, AuthenticateWithSessionCookieFailureReason as f, Actions as g, AutoPaginatable as h, OrganizationDomainVerificationStrategy as i, SubtleCryptoProvider as j, ApiKeyRequiredException as k, CookieSession as l, Webhooks as m, ConnectionType as n, GenerateLinkIntent as o, PKCE as p, OrganizationDomainState as r, WorkOS as s, createWorkOS as t, RefreshSessionFailureReason as u, UnauthorizedException as v, ConflictException as w, OauthException as x, SignatureVerificationException as y };
8633
+ export { ApiKeyRequiredException as A, NotFoundException as C, AuthenticationException as D, BadRequestException as E, SubtleCryptoProvider as M, isAuthenticationErrorData as O, OauthException as S, ConflictException as T, Actions as _, ItContactIntent as a, SignatureVerificationException as b, WorkOS as c, RefreshSessionFailureReason as d, serializeRevokeSessionOptions as f, AutoPaginatable as g, Webhooks as h, OrganizationDomainVerificationStrategy as i, FetchHttpClient as j, GenericServerException as k, FeatureFlagsRuntimeClient as l, PKCE as m, ConnectionType as n, DomainDataState as o, AuthenticateWithSessionCookieFailureReason as p, OrganizationDomainState as r, GenerateLinkIntent as s, createWorkOS as t, CookieSession as u, UnprocessableEntityException as v, NoApiKeyProvidedException as w, RateLimitExceededException as x, UnauthorizedException as y };
8492
8634
 
8493
- //# sourceMappingURL=factory-iK-8FO4O.mjs.map
8635
+ //# sourceMappingURL=factory-AQv-AfDk.mjs.map