Compare commits
13 Commits
@nhost/rea
...
@nhost/rea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e2ecb4d1e | ||
|
|
52ebbef762 | ||
|
|
82faa4ca0a | ||
|
|
d06a21764a | ||
|
|
8b54d290a5 | ||
|
|
4cfa6bbe1e | ||
|
|
614f213e26 | ||
|
|
4eebf51821 | ||
|
|
9a52298aa7 | ||
|
|
099eebe602 | ||
|
|
798e591b1d | ||
|
|
b48bc034ca | ||
|
|
f57819230b |
@@ -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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nhost/dashboard",
|
||||
"version": "0.13.3",
|
||||
"version": "0.13.5",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"preinstall": "npx only-allow pnpm",
|
||||
|
||||
@@ -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 } =
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @nhost/apollo
|
||||
|
||||
## 5.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @nhost/nhost-js@2.1.1
|
||||
|
||||
## 5.1.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nhost/apollo",
|
||||
"version": "5.1.0",
|
||||
"version": "5.1.1",
|
||||
"description": "Nhost Apollo Client library",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nhost/react-apollo",
|
||||
"version": "5.0.11",
|
||||
"version": "5.0.12",
|
||||
"description": "Nhost React Apollo client",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @nhost/react-urql
|
||||
|
||||
## 2.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @nhost/react@2.0.11
|
||||
|
||||
## 2.0.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nhost/react-urql",
|
||||
"version": "2.0.10",
|
||||
"version": "2.0.11",
|
||||
"description": "Nhost React URQL client",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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/",
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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/'
|
||||
)
|
||||
})
|
||||
@@ -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()
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export { default as appendImageTransformationParameters } from './appendImageTransformationParameters'
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
15
packages/hasura-storage-js/vite.unit.config.js
Normal file
15
packages/hasura-storage-js/vite.unit.config.js
Normal 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}`]
|
||||
}
|
||||
})
|
||||
@@ -1,5 +1,11 @@
|
||||
# @nhost/nextjs
|
||||
|
||||
## 1.13.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @nhost/react@2.0.11
|
||||
|
||||
## 1.13.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nhost/nextjs",
|
||||
"version": "1.13.16",
|
||||
"version": "1.13.17",
|
||||
"description": "Nhost NextJS library",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nhost/nhost-js",
|
||||
"version": "2.1.0",
|
||||
"version": "2.1.1",
|
||||
"description": "Nhost JavaScript SDK",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @nhost/react
|
||||
|
||||
## 2.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @nhost/nhost-js@2.1.1
|
||||
|
||||
## 2.0.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nhost/react",
|
||||
"version": "2.0.10",
|
||||
"version": "2.0.11",
|
||||
"description": "Nhost React library",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @nhost/vue
|
||||
|
||||
## 1.13.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @nhost/nhost-js@2.1.1
|
||||
|
||||
## 1.13.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nhost/vue",
|
||||
"version": "1.13.16",
|
||||
"version": "1.13.17",
|
||||
"description": "Nhost Vue library",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
||||
Reference in New Issue
Block a user