Compare commits

..

13 Commits

Author SHA1 Message Date
Szilárd Dóró
5e2ecb4d1e Merge pull request #1749 from nhost/changeset-release/main
chore: update versions
2023-03-20 10:00:29 +01:00
github-actions[bot]
52ebbef762 chore: update versions 2023-03-17 15:01:14 +00:00
Szilárd Dóró
82faa4ca0a Merge pull request #1748 from nhost/fix/presigned-url-params
fix(hasura-storage-js): allow image transformation parameters in `getPresignedUrl`
2023-03-17 15:58:38 +01:00
Szilárd Dóró
d06a21764a fix unit tests 2023-03-17 15:10:15 +01:00
Szilárd Dóró
8b54d290a5 Merge pull request #1747 from nhost/changeset-release/main
chore: update versions
2023-03-17 14:51:41 +01:00
Szilárd Dóró
4cfa6bbe1e chore: update changeset 2023-03-17 14:12:48 +01:00
Szilárd Dóró
614f213e26 feat: allow image transformation parameters in getPresignedUrl 2023-03-17 14:11:17 +01:00
github-actions[bot]
4eebf51821 chore: update versions 2023-03-17 11:29:52 +00:00
Szilárd Dóró
9a52298aa7 Merge pull request #1746 from nhost/fix/data-grid-date-cell
fix(dashboard): show correct date in data grid
2023-03-17 12:28:34 +01:00
Szilárd Dóró
099eebe602 Merge pull request #1745 from nhost/fix/disable-new-users
fix(dashboard): disable new users
2023-03-17 12:20:38 +01:00
Szilárd Dóró
798e591b1d fix: show correct date in data grid 2023-03-17 10:19:39 +01:00
Szilárd Dóró
b48bc034ca chore: add changeset 2023-03-17 10:01:26 +01:00
Szilárd Dóró
f57819230b fix: disable new users 2023-03-17 10:00:25 +01:00
27 changed files with 184 additions and 27 deletions

View File

@@ -1,5 +1,19 @@
# @nhost/dashboard
## 0.13.5
### Patch Changes
- @nhost/react-apollo@5.0.12
- @nhost/nextjs@1.13.17
## 0.13.4
### Patch Changes
- b48bc034: fix(dashboard): disable new users
- 798e591b: fix(dashboard): show correct date in data grid
## 0.13.3
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/dashboard",
"version": "0.13.3",
"version": "0.13.5",
"private": true,
"scripts": {
"preinstall": "npx only-allow pnpm",

View File

@@ -46,7 +46,7 @@ export default function DataGridDateCell<TData extends object>({
: undefined;
const { year, month, day, hour, minute, second } = getDateComponents(date, {
adjustTimezone: specificType === 'timetz' || specificType === 'timestamptz',
adjustTimezone: ['date', 'timetz', 'timestamptz'].includes(specificType),
});
const { inputRef, focusCell, isEditing, cancelEditCell } =

View File

@@ -35,7 +35,7 @@ export default function DisableNewUsersSettings() {
const form = useForm<DisableNewUsersFormValues>({
reValidateMode: 'onSubmit',
defaultValues: {
disabled: !!data?.config?.auth?.signUp?.enabled,
disabled: !data?.config?.auth?.signUp?.enabled,
},
});

View File

@@ -1,5 +1,11 @@
# @nhost/apollo
## 5.1.1
### Patch Changes
- @nhost/nhost-js@2.1.1
## 5.1.0
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/apollo",
"version": "5.1.0",
"version": "5.1.1",
"description": "Nhost Apollo Client library",
"license": "MIT",
"keywords": [

View File

@@ -1,5 +1,12 @@
# @nhost/react-apollo
## 5.0.12
### Patch Changes
- @nhost/apollo@5.1.1
- @nhost/react@2.0.11
## 5.0.11
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/react-apollo",
"version": "5.0.11",
"version": "5.0.12",
"description": "Nhost React Apollo client",
"license": "MIT",
"keywords": [

View File

@@ -1,5 +1,11 @@
# @nhost/react-urql
## 2.0.11
### Patch Changes
- @nhost/react@2.0.11
## 2.0.10
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/react-urql",
"version": "2.0.10",
"version": "2.0.11",
"description": "Nhost React URQL client",
"license": "MIT",
"keywords": [

View File

@@ -1,5 +1,11 @@
# @nhost/hasura-storage-js
## 2.0.4
### Patch Changes
- 614f213e: fix(hasura-storage-js): allow image transformation parameters in `getPresignedUrl`
## 2.0.3
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/hasura-storage-js",
"version": "2.0.3",
"version": "2.0.4",
"description": "Hasura-storage client",
"license": "MIT",
"keywords": [
@@ -47,6 +47,7 @@
"e2e": "start-test e2e:backend http-get://localhost:9695 ci:test",
"ci:test": "vitest run",
"e2e:backend": "nhost dev --no-browser",
"test": "vitest --config ./vite.unit.config.js",
"test:watch": "vitest",
"test:coverage": "vitest run --coverage",
"prettier": "prettier --check src/",

View File

@@ -129,6 +129,7 @@ export class HasuraStorageClient {
async getPresignedUrl(
params: StorageGetPresignedUrlParams
): Promise<StorageGetPresignedUrlResponse> {
const { fileId, ...imageTransformationParams } = params
const { presignedUrl, error } = await this.api.getPresignedUrl(params)
if (error) {
return { presignedUrl: null, error }
@@ -138,7 +139,18 @@ export class HasuraStorageClient {
return { presignedUrl: null, error: new Error('Invalid file id') }
}
return { presignedUrl, error: null }
const urlWithTransformationParams = appendImageTransformationParameters(
presignedUrl.url,
imageTransformationParams
)
return {
presignedUrl: {
...presignedUrl,
url: urlWithTransformationParams
},
error: null
}
}
/**

View File

@@ -0,0 +1,41 @@
import { expect, test } from 'vitest'
import appendImageTransformationParameters from './appendImageTransformationParameters'
test('should append image transformation parameters to a simple URL', () => {
expect(
appendImageTransformationParameters('https://example.com/', {
width: 100,
height: 100,
blur: 50,
quality: 80
})
).toBe('https://example.com/?w=100&h=100&b=50&q=80')
})
test('should append image transformation parameters to a URL with existing query parameters', () => {
expect(
appendImageTransformationParameters('https://example.com/?foo=bar', {
width: 100,
height: 100,
blur: 50,
quality: 80
})
).toBe('https://example.com/?foo=bar&w=100&h=100&b=50&q=80')
})
test('should not append falsy values', () => {
expect(
appendImageTransformationParameters('https://example.com/', {
width: undefined,
height: 100,
blur: undefined,
quality: 80
})
).toBe('https://example.com/?h=100&q=80')
})
test('should keep the original URL if no transformation parameters are provided', () => {
expect(appendImageTransformationParameters('https://example.com/', {})).toBe(
'https://example.com/'
)
})

View File

@@ -0,0 +1,36 @@
import { StorageImageTransformationParams } from '../types'
/**
* Appends image transformation parameters to the URL. If the URL already
* contains query parameters, the transformation parameters are appended to
* the existing query parameters.
*
* @internal
* @param url - The URL to append the transformation parameters to.
* @param params - The image transformation parameters.
* @returns The URL with the transformation parameters appended.
*/
export default function appendImageTransformationParameters(
url: string,
params: StorageImageTransformationParams
): string {
const urlObject = new URL(url)
// create an object with the transformation parameters by using the first
// character of the parameter name as the key
const imageTransformationParams = Object.entries(params).reduce(
(accumulator, [key, value]) => ({ ...accumulator, [key.charAt(0)]: value }),
{} as Record<string, any>
)
// set the query parameters in the URL object
Object.entries(imageTransformationParams).forEach(([key, value]) => {
if (!value) {
return
}
urlObject.searchParams.set(key, value)
})
return urlObject.toString()
}

View File

@@ -0,0 +1 @@
export { default as appendImageTransformationParameters } from './appendImageTransformationParameters'

View File

@@ -1,13 +1,2 @@
import { StorageImageTransformationParams } from './types'
export * from './appendImageTransformationParameters'
export * from './types'
export const appendImageTransformationParameters = (
url: string,
params: StorageImageTransformationParams
): string => {
const queryParameters = Object.entries(params)
.map(([key, value]) => `${key.charAt(0)}=${value}`)
.join('&')
return queryParameters ? `${url}?${queryParameters}` : url
}

View File

@@ -65,9 +65,7 @@ export interface StorageGetUrlParams extends StorageImageTransformationParams {
fileId: string
}
// TODO not implemented yet in hasura-storage
// export interface StorageGetPresignedUrlParams extends StorageImageTransformationParams {
export interface StorageGetPresignedUrlParams {
export interface StorageGetPresignedUrlParams extends StorageImageTransformationParams {
fileId: string
}

View File

@@ -0,0 +1,15 @@
import { defineConfig } from 'vite'
import baseConfig from '../../config/vite.lib.config'
const PWD = process.env.PWD
export default defineConfig({
...baseConfig,
test: {
...(baseConfig.test || {}),
testTimeout: 30000,
environment: 'node',
include: [`${PWD}/src/**/*.{spec,test}.{ts,tsx}`]
}
})

View File

@@ -1,5 +1,11 @@
# @nhost/nextjs
## 1.13.17
### Patch Changes
- @nhost/react@2.0.11
## 1.13.16
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/nextjs",
"version": "1.13.16",
"version": "1.13.17",
"description": "Nhost NextJS library",
"license": "MIT",
"keywords": [

View File

@@ -1,5 +1,12 @@
# @nhost/nhost-js
## 2.1.1
### Patch Changes
- Updated dependencies [614f213e]
- @nhost/hasura-storage-js@2.0.4
## 2.1.0
### Minor Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/nhost-js",
"version": "2.1.0",
"version": "2.1.1",
"description": "Nhost JavaScript SDK",
"license": "MIT",
"keywords": [

View File

@@ -1,5 +1,11 @@
# @nhost/react
## 2.0.11
### Patch Changes
- @nhost/nhost-js@2.1.1
## 2.0.10
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/react",
"version": "2.0.10",
"version": "2.0.11",
"description": "Nhost React library",
"license": "MIT",
"keywords": [

View File

@@ -1,5 +1,11 @@
# @nhost/vue
## 1.13.17
### Patch Changes
- @nhost/nhost-js@2.1.1
## 1.13.16
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/vue",
"version": "1.13.16",
"version": "1.13.17",
"description": "Nhost Vue library",
"license": "MIT",
"keywords": [