Skip to content

Commit

Permalink
Merge pull request #841 from commercelayer/update-deps
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
gciotola authored Nov 27, 2024
2 parents 23fd5fb + 966e07d commit 08714bd
Show file tree
Hide file tree
Showing 10 changed files with 2,026 additions and 3,012 deletions.
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@
"packages/*"
],
"devDependencies": {
"husky": "^9.1.6",
"lerna": "^8.1.8",
"husky": "^9.1.7",
"lerna": "^8.1.9",
"lint-staged": "^15.2.10"
},
"resolutions": {
"tar": "^6.2.1"
}
}
32 changes: 16 additions & 16 deletions packages/app-elements/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
"ts:check": "tsc --noEmit"
},
"dependencies": {
"@commercelayer/js-auth": "^6.6.4",
"@commercelayer/sdk": "6.24.0",
"@commercelayer/js-auth": "^6.7.0",
"@commercelayer/sdk": "6.25.1",
"@monaco-editor/react": "4.6.0",
"@types/lodash": "^4.17.12",
"@types/lodash": "^4.17.13",
"@types/react": "^18.3.12",
"@types/react-datepicker": "^7.0.0",
"@types/react-dom": "^18.3.1",
Expand All @@ -50,43 +50,43 @@
"pluralize": "^8.0.0",
"query-string": "^9.1.1",
"react": "^18.3.1",
"react-currency-input-field": "^3.8.0",
"react-currency-input-field": "^3.9.0",
"react-datepicker": "^7.5.0",
"react-dom": "^18.3.1",
"react-hook-form": "^7.53.1",
"react-select": "^5.8.2",
"react-hook-form": "^7.53.2",
"react-select": "^5.8.3",
"react-tooltip": "^5.28.0",
"swr": "^2.2.5",
"ts-invariant": "^0.10.3",
"type-fest": "^4.26.1",
"type-fest": "^4.28.1",
"zod": "^3.23.8"
},
"devDependencies": {
"@commercelayer/eslint-config-ts-react": "^1.4.5",
"@hookform/resolvers": "^3.9.0",
"@hookform/resolvers": "^3.9.1",
"@phosphor-icons/react": "v2.1.7",
"@tailwindcss/forms": "^0.5.9",
"@testing-library/jest-dom": "^6.6.2",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.0.1",
"@types/node": "^20.16.4",
"@types/pluralize": "^0.0.33",
"@types/react-gtm-module": "^2.0.4",
"@types/testing-library__jest-dom": "^6.0.0",
"@vitejs/plugin-react": "^4.3.3",
"@vitejs/plugin-react": "^4.3.4",
"autoprefixer": "^10.4.20",
"cross-fetch": "^4.0.0",
"date-fns": "^4.1.0",
"date-fns-tz": "^3.2.0",
"eslint": "^8.57.0",
"jsdom": "^25.0.1",
"msw": "^2.5.2",
"postcss": "^8.4.47",
"msw": "^2.6.6",
"postcss": "^8.4.49",
"react-gtm-module": "^2.0.11",
"tailwindcss": "^3.4.14",
"typescript": "^5.6.3",
"vite": "^5.4.10",
"tailwindcss": "^3.4.15",
"typescript": "^5.7.2",
"vite": "^6.0.1",
"vite-plugin-dts": "^4.3.0",
"vitest": "^2.1.3",
"vitest": "^2.1.6",
"wouter": "^3.3.5"
},
"peerDependencies": {
Expand Down
23 changes: 23 additions & 0 deletions packages/app-elements/src/helpers/resources.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
type ListableResourceType,
type ResourceTypeLock,
type ResourceUpdate
} from '@commercelayer/sdk'

Expand Down Expand Up @@ -112,6 +113,7 @@ const singularLowercase: Record<ListableResourceType, string> = {
stock_locations: 'stock location',
stock_reservations: 'stock reservation',
stock_transfers: 'stock transfer',
stores: 'Store',
stripe_gateways: 'stripe gateway',
stripe_payments: 'stripe payment',
subscription_models: 'subscription model',
Expand Down Expand Up @@ -236,6 +238,7 @@ const pluralLowercase: Record<ListableResourceType, string> = {
stock_locations: 'stock locations',
stock_reservations: 'stock reservations',
stock_transfers: 'stock transfers',
stores: 'Stores',
stripe_gateways: 'stripe gateways',
stripe_payments: 'stripe payments',
subscription_models: 'subscription models',
Expand Down Expand Up @@ -287,3 +290,23 @@ export type TriggerAttribute<Resource extends ResourceUpdate> = Extract<
keyof Resource,
`_${string}`
>

export type ResourceEndpoint =
| Exclude<ResourceTypeLock, 'applications' | 'organizations'>
| ('organization' | 'application')

/**
* Get the resource endpoint for a given resource type.
* @param resourceType The resource type
* @returns The resource endpoint
* @example getResourceEndpoint('organizations') // 'organization'
*/
export function getResourceEndpoint(
resourceType: ResourceTypeLock
): ResourceEndpoint {
return resourceType === 'organizations'
? 'organization'
: resourceType === 'applications'
? 'application'
: resourceType
}
6 changes: 5 additions & 1 deletion packages/app-elements/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ export {
} from '#helpers/date'
export { downloadJsonAsFile } from '#helpers/downloadJsonAsFile'
export { computeFullname, formatDisplayName } from '#helpers/name'
export { formatResourceName, type TriggerAttribute } from '#helpers/resources'
export {
formatResourceName,
getResourceEndpoint,
type TriggerAttribute
} from '#helpers/resources'
export {
getAvatarSrcFromRate,
getParcelTrackingDetail,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { type ResourceEndpoint } from '#helpers/resources'
import { useTokenProvider } from '#providers/TokenProvider'
import type { CommerceLayerClient, ResourceTypeLock } from '@commercelayer/sdk'
import type { CommerceLayerClient } from '@commercelayer/sdk'
import { useCallback } from 'react'
import useSWR, {
type Fetcher,
Expand Down Expand Up @@ -39,7 +40,7 @@ type ForceToBeMethod<Method> = Method extends GenericMethod
* @returns SWR response
*/
export function useCoreApi<
Resource extends ResourceTypeLock,
Resource extends ResourceEndpoint,
Action extends ConditionalKeys<CommerceLayerClient[Resource], GenericMethod>,
Method extends ForceToBeMethod<CommerceLayerClient[Resource][Action]>,
Args extends Parameters<Method>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function MockTokenProvider({
id: '1234',
name: 'Commerce Layer',
slug: 'mock',
type: 'organization',
type: 'organizations',
created_at: '2021-01-01T00:00:00.000Z',
updated_at: '2021-01-01T00:00:00.000Z'
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { HookedInput } from '#ui/forms/Input'
import { HookedValidationApiError } from '#ui/forms/ReactHookForm'
import { useForm } from 'react-hook-form'

import { getResourceEndpoint } from '#helpers/resources'
import { useCoreSdkProvider } from '#providers/CoreSdkProvider'
import { Button } from '#ui/atoms/Button'
import { Spacer } from '#ui/atoms/Spacer'
Expand Down Expand Up @@ -36,7 +37,7 @@ export const ResourceDetailsForm = withSkeletonTemplate<{
<HookedForm
{...methods}
onSubmit={(formValues) => {
void sdkClient[resource.type]
void sdkClient[getResourceEndpoint(resource.type)]
.update({
id: resource.id,
reference: formValues.reference,
Expand All @@ -45,7 +46,7 @@ export const ResourceDetailsForm = withSkeletonTemplate<{
.then(() => {
void onUpdated()
})
.catch((error) => {
.catch((error: any) => {
setApiError(error)
})
}}
Expand Down
56 changes: 28 additions & 28 deletions packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,52 +17,52 @@
"pnpm": ">=7"
},
"dependencies": {
"prettier": "^3.3.3",
"prettier": "^3.4.1",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@babel/core": "^7.26.0",
"@babel/preset-env": "^7.26.0",
"@commercelayer/eslint-config-ts-react": "^1.4.5",
"@hookform/resolvers": "^3.9.0",
"@hookform/resolvers": "^3.9.1",
"@mdx-js/react": "^3.1.0",
"@storybook/addon-actions": "^8.3.6",
"@storybook/addon-backgrounds": "^8.3.6",
"@storybook/addon-docs": "^8.3.6",
"@storybook/addon-essentials": "^8.3.6",
"@storybook/addon-interactions": "^8.3.6",
"@storybook/addon-links": "^8.3.6",
"@storybook/addon-measure": "^8.3.6",
"@storybook/addon-outline": "^8.3.6",
"@storybook/blocks": "^8.3.6",
"@storybook/cli": "^8.3.6",
"@storybook/client-logger": "^8.3.6",
"@storybook/components": "^8.3.6",
"@storybook/core-common": "^8.3.6",
"@storybook/addon-actions": "^8.4.5",
"@storybook/addon-backgrounds": "^8.4.5",
"@storybook/addon-docs": "^8.4.5",
"@storybook/addon-essentials": "^8.4.5",
"@storybook/addon-interactions": "^8.4.5",
"@storybook/addon-links": "^8.4.5",
"@storybook/addon-measure": "^8.4.5",
"@storybook/addon-outline": "^8.4.5",
"@storybook/blocks": "^8.4.5",
"@storybook/cli": "^8.4.5",
"@storybook/client-logger": "^8.4.5",
"@storybook/components": "^8.4.5",
"@storybook/core-common": "^8.4.5",
"@storybook/icons": "^1.2.12",
"@storybook/manager-api": "^8.3.6",
"@storybook/react": "^8.3.6",
"@storybook/react-vite": "^8.3.6",
"@storybook/theming": "^8.3.6",
"@storybook/manager-api": "^8.4.5",
"@storybook/react": "^8.4.5",
"@storybook/react-vite": "^8.4.5",
"@storybook/theming": "^8.4.5",
"@types/js-yaml": "^4.0.9",
"@types/node": "^20.16.4",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@vitejs/plugin-react": "^4.3.3",
"@vitejs/plugin-react": "^4.3.4",
"babel-loader": "^9.2.1",
"date-fns": "^4.1.0",
"eslint": "^8.57.0",
"eslint-plugin-storybook": "^0.10.1",
"eslint-plugin-storybook": "^0.11.1",
"js-yaml": "^4.1.0",
"msw": "^2.5.2",
"react-hook-form": "^7.53.1",
"react-select": "^5.8.2",
"msw": "^2.6.6",
"react-hook-form": "^7.53.2",
"react-select": "^5.8.3",
"remark-gfm": "^4.0.0",
"storybook": "^8.3.6",
"typescript": "^5.6.3",
"vite": "^5.4.10",
"vite-tsconfig-paths": "^5.0.1",
"storybook": "^8.4.5",
"typescript": "^5.7.2",
"vite": "^6.0.1",
"vite-tsconfig-paths": "^5.1.3",
"zod": "^3.23.8"
},
"msw": {
Expand Down
3 changes: 2 additions & 1 deletion packages/docs/src/components/CodeSample.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Source } from '@storybook/blocks'
import { type Plugin } from 'prettier'
import * as prettierEstree from 'prettier/plugins/estree'
import * as prettierTypescript from 'prettier/plugins/typescript'
import * as prettier from 'prettier/standalone'
Expand Down Expand Up @@ -52,7 +53,7 @@ export function CodeSample({
trailingComma: 'none',
parser: 'typescript',
printWidth: 60,
plugins: [prettierTypescript, prettierEstree]
plugins: [prettierTypescript, prettierEstree as Plugin<any>]
})

tmpSanitizedCode = tmpSanitizedCode.replaceAll(';', ';\n')
Expand Down
Loading

0 comments on commit 08714bd

Please sign in to comment.