Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

APP-15551 - Update to use createIntegrationHelpers and expose entity type schemas #55

Merged
merged 10 commits into from
Jul 24, 2024

Conversation

jzolo22
Copy link
Contributor

@jzolo22 jzolo22 commented Jul 8, 2024

Changes of note:

  • Use integration helpers on the entities
  • Update location to snipeit_location <-- is this a concern?? potentially need to call it out to DP
  • Duplicate properties that are dot separated to a camelCased equivalent and mark them as deprecated

@jzolo22 jzolo22 changed the title APP-15551 - WIP APP-15551 - Update to use createIntegrationHelpers and expose entity type schemas Jul 9, 2024
@jzolo22 jzolo22 marked this pull request as ready for review July 9, 2024 20:20
@jzolo22 jzolo22 requested a review from a team as a code owner July 9, 2024 20:20
),
byod: SchemaType.Boolean({
deprecated: true,
description: 'Please use BYOD instead.',
Copy link
Contributor

Choose a reason for hiding this comment

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

BYOD is part of the Device schema, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's right!

Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add a date as to when this should be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hesitate to do that unless we actually commit to a date everyone is good with. Kind of arbitrary but we could say Jan 1, 2025? Nice round number

src/entities.ts Outdated Show resolved Hide resolved
src/entities.ts Outdated Show resolved Hide resolved
src/entities.ts Outdated Show resolved Hide resolved
src/entities.ts Outdated Show resolved Hide resolved
src/entities.ts Outdated Show resolved Hide resolved
src/entities.ts Outdated Show resolved Hide resolved
src/entities.ts Outdated
Comment on lines 208 to 215
purchaseDate: SchemaType.Optional(SchemaType.Number()),
terminationDate: SchemaType.Optional(SchemaType.Number()),
depreciation: SchemaType.Optional(SchemaType.String()),
purchaseCost: SchemaType.Optional(
SchemaType.Union([SchemaType.String(), SchemaType.Null()]),
),
notes: SchemaType.Optional(SchemaType.Array(SchemaType.String())),
expirationDate: SchemaType.Optional(SchemaType.Number()),
Copy link
Contributor

@VDubber VDubber Jul 16, 2024

Choose a reason for hiding this comment

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

Suggested change
purchaseDate: SchemaType.Optional(SchemaType.Number()),
terminationDate: SchemaType.Optional(SchemaType.Number()),
depreciation: SchemaType.Optional(SchemaType.String()),
purchaseCost: SchemaType.Optional(
SchemaType.Union([SchemaType.String(), SchemaType.Null()]),
),
notes: SchemaType.Optional(SchemaType.Array(SchemaType.String())),
expirationDate: SchemaType.Optional(SchemaType.Number()),
purchasedOn: SchemaType.Optional(SchemaType.Number()),
terminatedOn: SchemaType.Optional(SchemaType.Number()),
depreciation: SchemaType.Optional(SchemaType.String()),
purchaseCost: SchemaType.Optional(
SchemaType.Union([SchemaType.String(), SchemaType.Null()]),
),
notes: SchemaType.Optional(SchemaType.Array(SchemaType.String())),
expiresOn: SchemaType.Optional(SchemaType.Number()),

Did we approve the date RFC?

Suggestions here are for perhaps a future iteration since these changes are breaking. Or we could deprecate and add? Thoughts?

And I just grabbed a few dates, but I imagine there are others in the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or we could deprecate and add

I'm definitely in favor of this approach

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We haven't approved any official Date changes

Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -42,12 +49,16 @@ export function convertConsumable(
notes: data.notes ? [data.notes] : undefined,
createdOn: parseTimePropertyValue(data.created_at?.datetime),
updatedOn: parseTimePropertyValue(data.updated_at?.datetime),
userCanCheckout: data.user_can_checkout,
userCanCheckout: Boolean(data.user_can_checkout),
Copy link
Contributor

Choose a reason for hiding this comment

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

Boolean("false") => true

Do we expect user_can_checkout to be data type boolean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do, this is from the docs... but maybe wrapping in Boolean isn't necessarily the best here. I feel like I've maybe seen a boolean parsing function from the SDK?

    "user_can_checkout": true,

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm... I think this case is fine to use Boolean(), but in general we could see booleans flip their real value.

I guess I'd prefer to see "false" instead of true on the entity when the real value is false. Does that make sense? Both are bad for query-ability, but one is completely wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I definitely agree

@@ -51,27 +50,30 @@ export function convertHardware(
model: data.model?.name ?? null,
serial: data.serial,
byod: data.byod,
cost: Number(data.purchase_cost),
BYOD: data.byod,
cost: Number(data.purchase_cost) || undefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: future state we should make available more parsing functions.

Copy link
Contributor

Choose a reason for hiding this comment

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

And then those parsing functions behavior could be describe on the docs.
So in the scenario we get $4.23 as the purchase cost, the parse function handles it and returns the number 4.34 and the docs say, we convert this to a number and remove in currency characters....
There probably is a better example...

...(shortLoginId && { shortLoginId }),
email: data.email,
emailDomain: emailDomain ? [emailDomain] : undefined,
shortLoginId: shortLoginId,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a change in behavior. Intentional?

Copy link
Contributor

Choose a reason for hiding this comment

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

null is left on the entity whereas undefined is removed. It's minor but just wanted to confirm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good callout! I wanted to make the value assignment more explicit and less conditional if that makes sense

@VDubber
Copy link
Contributor

VDubber commented Jul 16, 2024

@jzolo22, have we verified that the location to snipeit_location won't break queries? And this change should probably be mentioned in #prod-updates.

@jzolo22 jzolo22 added minor Increment the minor version when merged release Create a release when this pr is merged labels Jul 24, 2024
@jzolo22 jzolo22 merged commit 8c931ab into main Jul 24, 2024
7 checks passed
@jzolo22 jzolo22 deleted the APP-15551 branch July 24, 2024 15:33
@j1-internal-automation
Copy link
Collaborator

🚀 PR was released in v4.3.0 🚀

@j1-internal-automation j1-internal-automation added the released This issue/pull request has been released. label Jul 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
minor Increment the minor version when merged release Create a release when this pr is merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants