Skip to content

Commit

Permalink
bump(extensions-core): bump to 1.0.20
Browse files Browse the repository at this point in the history
  • Loading branch information
bejoinka committed Feb 6, 2025
1 parent c75c581 commit 1cf46b0
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 28 deletions.
16 changes: 8 additions & 8 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
24 changes: 13 additions & 11 deletions extensions/elation/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ export const settings = {
},
} satisfies Record<string, Setting>

export const rateLimitDurationSchema = z
.string()
.regex(
/^\d+[ ]+[smhd]$/,
'Duration must be in format {number} {unit} where unit is s,m,h,d',
)
.transform((val): Duration => {
const [number, unit] = val.split(' ')
return `${number}${unit}` as Duration
})
.optional()

export const SettingsValidationSchema = z.object({
base_url: z.string().min(1),
auth_url: z.string().min(1),
Expand All @@ -68,17 +80,7 @@ export const SettingsValidationSchema = z.object({
*/
username: z.string().optional(),
password: z.string().optional(),
rateLimitDuration: z
.string()
.regex(
/^\d+[ ]+[smhd]$/,
'Duration must be in format {number} {unit} where unit is s,m,h,d',
)
.transform((val): Duration => {
const [number, unit] = val.split(' ')
return `${number}${unit}` as Duration
})
.optional(),
rateLimitDuration: rateLimitDurationSchema,
} satisfies Record<keyof typeof settings, ZodTypeAny>)

export type SettingsType = z.infer<typeof SettingsValidationSchema>
9 changes: 7 additions & 2 deletions extensions/elation/webhooks/appointmentCreatedOrUpdated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { ELATION_SYSTEM } from '../constants'
import { type SubscriptionEvent } from '../types/subscription'
import { createHash } from 'node:crypto'
import { Duration } from '@upstash/ratelimit'
import { rateLimitDurationSchema, SettingsValidationSchema } from '../settings'
import { isNil } from 'lodash'

const dataPoints = {
appointmentId: {
Expand All @@ -31,15 +33,18 @@ export const appointmentCreatedOrUpdated: Webhook<
helpers,
}) => {
const { action, resource, data } = payload
const { rateLimitDuration } = settings
const { id: appointmentId, patient: patientId } = data

// skip non 'saved' actions for that webhook
if (action !== 'saved') {
return
}

if (rateLimitDuration) {
const rateLimitDuration = rateLimitDurationSchema.parse(
settings.rateLimitDuration,
)

if (!isNil(rateLimitDuration)) {
const rateLimiter = helpers.rateLimit(1, rateLimitDuration as Duration)
const strAppt = JSON.stringify(data)
const uniqueHash = createHash('sha256').update(strAppt).digest('hex')
Expand Down
6 changes: 5 additions & 1 deletion extensions/elation/webhooks/patientCreatedOrUpdated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
} from '@awell-health/extensions-core'
import { type SubscriptionEvent } from '../types/subscription'
import { Duration } from '@upstash/ratelimit'
import { rateLimitDurationSchema } from '../settings'
import { createHash } from 'node:crypto'

const dataPoints = {
Expand All @@ -30,14 +31,17 @@ export const patientCreatedOrUpdated: Webhook<
helpers,
}) => {
const { data, resource, action } = payload
const { rateLimitDuration } = settings
const { id: patientId } = data

// skip non 'saved' actions for that webhook
if (action !== 'saved') {
return
}

const rateLimitDuration = rateLimitDurationSchema.parse(
settings.rateLimitDuration,
)

if (rateLimitDuration) {
const rateLimiter = helpers.rateLimit(1, rateLimitDuration as Duration)
const strPatient = JSON.stringify(data)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
},
"dependencies": {
"@awell-health/awell-sdk": "^0.1.20",
"@awell-health/extensions-core": "1.0.19",
"@awell-health/extensions-core": "1.0.20",
"@awell-health/healthie-sdk": "^0.1.1",
"@dropbox/sign": "^1.8.0",
"@hubspot/api-client": "^11.2.0",
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ __metadata:
resolution: "@awell-health/awell-extensions@workspace:."
dependencies:
"@awell-health/awell-sdk": "npm:^0.1.20"
"@awell-health/extensions-core": "npm:1.0.19"
"@awell-health/extensions-core": "npm:1.0.20"
"@awell-health/healthie-sdk": "npm:^0.1.1"
"@dropbox/sign": "npm:^1.8.0"
"@faker-js/faker": "npm:^8.0.2"
Expand Down Expand Up @@ -194,9 +194,9 @@ __metadata:
languageName: node
linkType: hard

"@awell-health/extensions-core@npm:1.0.19":
version: 1.0.19
resolution: "@awell-health/extensions-core@npm:1.0.19"
"@awell-health/extensions-core@npm:1.0.20":
version: 1.0.20
resolution: "@awell-health/extensions-core@npm:1.0.20"
dependencies:
"@types/json-schema": "npm:^7.0.15"
"@upstash/ratelimit": "npm:^2.0.5"
Expand All @@ -208,7 +208,7 @@ __metadata:
zod-validation-error: "npm:^3.2.0"
peerDependencies:
"@awell-health/awell-sdk": "*"
checksum: 10/25e8eb6a9a3fb0a83de715a67e74cf143434e3e964003393a1a5f3a34e44f5af5f642408ebdf72d42c09cdf8a17697830fd5c0160c17c687bec87fdf04fba788
checksum: 10/fd829c1ced8c44dfbc9775b31ad3d96bf1afc5082b835ea06948514d66e6665efea2b5578f150efadcd80c347f240f6d3f850c8db7d484c0b264dff97f42112e
languageName: node
linkType: hard

Expand Down

0 comments on commit 1cf46b0

Please sign in to comment.