Skip to content

IDE & Typehint improvements#264

Merged
nicknisi merged 17 commits intoworkos:mainfrom
bradenkeith:ide-improvements
Apr 2, 2025
Merged

IDE & Typehint improvements#264
nicknisi merged 17 commits intoworkos:mainfrom
bradenkeith:ide-improvements

Conversation

@bradenkeith
Copy link
Contributor

Description

This PR has 2 elements to it:

  1. There is a linter issue in BaseWorkOSResource that is now resolved.
  2. I am offering some improvements to the type hints applied to the Webhooks, so IDEs will be able to decipher the payload it can expect. I extracted the available payload from the Actions > Test payloads offered, as this was the only documentation I could find about what may exist in the payload.

Documentation

Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.

[ x] No

If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.

@bradenkeith bradenkeith requested a review from a team as a code owner March 11, 2025 17:21
@bradenkeith bradenkeith requested a review from gcarvelli March 11, 2025 17:21
@bradenkeith
Copy link
Contributor Author

This documentation shows "access_token" and "refresh_token" should be part of AuthenticationResponse payload. I have updated the resource accordingly.

…able, and add accessToken, refreshToken, and impersonator properties
@bradenkeith
Copy link
Contributor Author

This documentation shows "role" should be part of OrganizationMembership payload. I have updated the resource accordingly. I have also type hinted the class properties to resolve IDE issues.

@nicknisi
Copy link
Member

@bradenkeith it looks like there's some conflicts and test failures in this.

ericroberts and others added 11 commits March 28, 2025 13:53
And allow to be passed when creating or updating a user or organization.
And fix typo in getOrganization docstring
… property (workos#267)

Co-authored-by: Eric Roberts <ericroberts@gmail.com>
* Add WebhookResponse class for handling webhook actions and responses

* Refactor WebhookResponse create method and improve validation

* Resolve linting error

---------

Co-authored-by: Braden Keith <bkeith@romegadigital.com>
@bradenkeith
Copy link
Contributor Author

@nicknisi Should be good for another review. Thank you.

@nicknisi nicknisi merged commit 0c57b35 into workos:main Apr 2, 2025
5 checks passed
@bradenkeith bradenkeith deleted the ide-improvements branch April 3, 2025 00:46
bradenkeith added a commit to bradenkeith/workos-php that referenced this pull request Apr 3, 2025
* Improve Webhook and BaseWorkOSResource PHPDoc types

* Enhance Webhook class with improved code style and PHPDoc annotations

* Add accessToken and refreshToken to AuthenticationResponse class

* Update AuthenticationResponse class to include organizationId as nullable, and add accessToken, refreshToken, and impersonator properties

* Enhance OrganizationMembership class with additional PHPDoc properties for improved type documentation

* Add metadata and external id (workos#268)

And allow to be passed when creating or updating a user or organization.

* Add email standard attribute to DirectoryUser and mark deprecated standard attributes (workos#261)

* Add function to get organization by external id (workos#270)

And fix typo in getOrganization docstring

* Add support for creating, getting and updating users with external_id property (workos#267)

Co-authored-by: Eric Roberts <ericroberts@gmail.com>

* Bump to version 4.22.0. (workos#269)

* Structured responses to webhook events (workos#265)

* Add WebhookResponse class for handling webhook actions and responses

* Refactor WebhookResponse create method and improve validation

* Resolve linting error

---------

Co-authored-by: Braden Keith <bkeith@romegadigital.com>

* Update deprecation notices in DirectoryUser class to include version information and improve clarity

* Update deprecation notices in Organizations class to include version information and improve formatting

* Update doc blocks for deprecation notices

* Update tests to expect Role Slug

---------

Co-authored-by: Braden Keith <bkeith@romegadigital.com>
Co-authored-by: Eric Roberts <ericroberts@gmail.com>
Co-authored-by: Matt Dzwonczyk <9063128+mattgd@users.noreply.github.com>
Co-authored-by: Pepe <pgarciag93@gmail.com>
Comment on lines +16 to +34
* @param array $event An associative array with the following keys:
* - **action** (string, *required*): Specific activity performed by the actor.
* - **occurred_at** (string, *required*): ISO-8601 datetime when the event occurred.
* - **actor** (array, *required*): Associative array describing the actor.
* - **id** (string, *required*): Unique identifier for the actor.
* - **name** (string, *optional*): Name of the actor.
* - **type** (string, *required*): Type or role of the actor.
* - **metadata** (array, *optional*): Arbitrary key-value data.
* - **targets** (array, *required*): Array of associative arrays for each target.
* Each target includes:
* - **id** (string, *required*): Unique identifier for the target.
* - **name** (string, *optional*): Name of the target.
* - **type** (string, *required*): Type or category of the target.
* - **metadata** (array, *optional*): Arbitrary key-value data.
* - **context** (array, *required*): Associative array providing additional context.
* - **location** (string, *required*): Location associated with the event.
* - **user_agent** (string, *optional*): User agent string if applicable.
* - **version** (int, *optional*): Event version. Required if the version is not 1.
* - **metadata** (array, *optional*): Additional arbitrary key-value data for the event.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using array shapes would improve this even more.



/**
* @deprecated 1.12.0 Use `verifyChallenge` instead. This method will be removed in a future major version.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect ordering of @ attrs.

/**
* Class OrganizationMembership.
*
* @property 'organization_membership' $object

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

Comment on lines +13 to +18
* @property-read ?object{
* object: 'user_data',
* email: string,
* first_name: string,
* last_name: string
* } $user_data User information for registration events

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! This kind of array shape.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

6 participants