diff --git a/src/content/docs/en/pages/devtools/azion-lib/usage/storage.mdx b/src/content/docs/en/pages/devtools/azion-lib/usage/storage.mdx index 098f96ea92..0a337d958b 100644 --- a/src/content/docs/en/pages/devtools/azion-lib/usage/storage.mdx +++ b/src/content/docs/en/pages/devtools/azion-lib/usage/storage.mdx @@ -55,7 +55,7 @@ The `createClient` method has the following **parameters** and **return value**: | Parameter | Type | Description | |-----------|------|-------------| -| `config` | `Partial<{ token: string; options?: OptionsParams }>` | Configuration options for the Storage client. | +| `config` | `Partial<{ token: string; options?: AzionClientOptions }>` | Configuration options for the Storage client. | **Returns**: @@ -82,7 +82,7 @@ import { createBucket } from 'azion/storage'; import type { AzionStorageResponse, AzionBucket } from 'azion/storage'; const { data, error }: AzionStorageResponse = await createBucket({ name: 'my-new-bucket', - edge_access: 'public', + edge_access: 'read_write', }); if (data) { console.log(`Bucket created with name: ${data.name}`); @@ -96,8 +96,8 @@ if (data) { | Parameter | Type | Description | |-----------|------|-------------| | `name` | `string` | The name of the new bucket. | -| `edge_access` | `string` | The `edge access` configuration for the bucket. | -| `options?` | `AzionClientOptions` | Optional parameters for the request. | +| `edge_access` | [`EdgeAccessType`](#edgeaccesstype) | The `edge access` configuration for the bucket. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. | **Returns**: @@ -127,7 +127,7 @@ if (data) { | Parameter | Type | Description | |-----------|------|-------------| | `name` | `string` | The name of the bucket to be deleted. | -| `debug?` | `boolean` | Enables debug mode for detailed logging. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. | **Returns**: @@ -158,10 +158,8 @@ if (buckets) { | Parameter | Type | Description | |-----------|------|-------------| -| `options?` | `AzionBucketCollectionOptions` | Optional parameters for filtering and pagination. | -| `page?` | `number` | The page number for pagination. | -| `page_size?` | `number` | The number of items per page. | -| `debug?` | `boolean` | Enables debug mode for detailed logging. | +| `params?` | [`AzionBucketCollectionParams`](#azionbucketcollectionparams) | Parameters for filtering and pagination. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. | **Returns**: @@ -191,7 +189,7 @@ if (bucket) { | Parameter | Type | Description | |-----------|------|-------------| | `name` | `string` | The name of the bucket to be retrieved. | -| `debug?` | `boolean` | Enables debug mode for detailed logging. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. | **Returns**: @@ -210,7 +208,7 @@ import { updateBucket, AzionBucket, AzionStorageResponse } from 'azion/storage'; const { data: updatedBucket, error }: AzionStorageResponse | null = await updateBucket({ name: 'my-bucket', - edge_access: 'private', + edge_access: 'read_write', }); if (updatedBucket) { console.log(`Bucket updated: ${updatedBucket.name}`); @@ -224,8 +222,8 @@ if (updatedBucket) { | Parameter | Type | Description | |-----------|------|-------------| | `name` | `string` | The name of the bucket to be updated. | -| `edge_access` | `string` | The new `edge access` configuration for the bucket. | -| `debug?` | `boolean` | Enables debug mode for detailed logging. | +| `edge_access` | [`EdgeAccessType`](#edgeaccesstype) | The new `edge access` configuration for the bucket. | +| `options?` |[`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. | **Returns**: @@ -243,9 +241,9 @@ Example: import { createObject, AzionBucketObject, AzionStorageResponse } from 'azion/storage'; const { data: newObject, error }: AzionStorageResponse = await createObject({ - bucketName: 'my-bucket', + bucket: 'my-bucket', key: 'new-file.txt', - file: 'File content', + content: 'File content', }); if (newObject) { console.log(`Object created with key: ${newObject.key}`); @@ -259,10 +257,10 @@ if (newObject) { | Parameter | Type | Description | |-------------|----------|-----------------------------------------------| -| `bucketName` | `string` | The name of the bucket to create the object in. | -| `objectKey` | `string` | Key (name) of the object to be created. | -| `file` | `string` | The content of the file to be uploaded. | -| `debug?` | `boolean`| Enables debug mode for detailed logging. | +| `bucket` | `string` | The name of the bucket to create the object in.| +| `key` | `string` | Key (name) of the object to be created.| +| `content` | `string` | The content of the file to be uploaded.| +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. | **Returns**: @@ -280,7 +278,7 @@ Example: import { getObjectByKey, AzionBucketObject, AzionStorageResponse } from 'azion/storage'; const { data: object, error }: AzionStorageResponse = await getObjectByKey({ - bucketName: 'my-bucket', + bucket: 'my-bucket', key: 'file.txt', }); if (object) { @@ -294,9 +292,9 @@ if (object) { | Parameter | Type | Description | |-----------|------|-------------| -| `bucketName` | `string` | The name of the bucket containing the object. | -| `objectKey` | `string` | The key of the object to be retrieved. | -| `debug?` | `boolean` | Enables debug mode for detailed logging. | +| `bucket` | `string` | The name of the bucket containing the object. | +| `key` | `string` | The key of the object to be retrieved. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. | **Returns**: @@ -314,7 +312,7 @@ Example: import { getObjects, AzionBucketObject, AzionStorageResponse } from 'azion/storage'; const { data: objectResult, error }: AzionStorageResponse = await getObjects({ - bucketName: 'my-bucket', + bucket: 'my-bucket', }); if (objectResult) { console.log(`Retrieved ${objectResult.count} objects from the bucket`); @@ -327,8 +325,9 @@ if (objectResult) { | Parameter | Type | Description | |-----------|------|-------------| -| `bucketName` | `string` | The name of the bucket to retrieve objects from. | -| `debug?` | `boolean` | Enables debug mode for detailed logging. | +| `bucket` | `string` | The name of the bucket to retrieve objects from. | +| `params?` | [`AzionObjectCollectionParams`](#azionobjectcollectionparams) | Parameters for filtering and pagination. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. | **Returns**: @@ -346,9 +345,9 @@ Example: import { updateObject, AzionBucketObject } from 'azion/storage'; const { data: updatedObject, error }: AzionStorageResponse = await updateObject({ - bucketName: 'my-bucket', + bucket: 'my-bucket', key: 'file.txt', - file: 'Updated content', + content: 'Updated content', }); if (updatedObject) { console.log(`Object updated: ${updatedObject.key}`); @@ -362,10 +361,10 @@ if (updatedObject) { | Parameter | Type | Description | |-----------|------|-------------| -| `bucketName` | `string` | The name of the bucket containing the object. | -| `objectKey` | `string` | The key of the object to be updated. | -| `file` | `string` | The new content of the file. | -| `debug?` | `boolean` | Enables debug mode for detailed logging. | +| `bucket` | `string` | The name of the bucket containing the object. | +| `key` | `string` | The key of the object to be updated. | +| `content` | `string` | The new content of the file. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. | **Returns**: @@ -377,13 +376,13 @@ if (updatedObject) { Deletes an object from a specific bucket. -Example: +Example: ```typescript import { deleteObject, AzionDeletedBucketObject, AzionStorageResponse } from 'azion/storage'; const { data: result, error }: AzionStorageResponse = await deleteObject({ - bucketName: 'my-bucket', + bucket: 'my-bucket', key: 'file.txt', }); if (result) { @@ -397,9 +396,9 @@ if (result) { | Parameter | Type | Description | |-----------|------|-------------| -| `bucketName` | `string` | The name of the bucket containing the object. | -| `objectKey` | `string` | The key of the object to be deleted. | -| `debug?` | `boolean` | Enables debug mode for detailed logging. | +| `bucket` | `string` | The name of the bucket containing the object. | +| `key` | `string` | The key of the object to be deleted. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. | **Returns**: @@ -413,14 +412,47 @@ if (result) { These are the types used by the **Storage** library and its methods: -### `ClientConfig` +### AzionBucketCollectionParams + +Parameters for filtering and pagination when retrieving a collection of buckets. + +| Parameter | Type | Description | +|-----------|------|-------------| +| `page?` | `number` | The page number for pagination. | +| `page_size?` | `number` | The number of items per page. | + +### `AzionObjectCollectionParams` + +| Parameter | Type | Description | +|-----------|------|-------------| +| `max_object_count?` | `number` | The max number of items per request. | + +### `EdgeAccessType` + +The type of access control for the bucket. + +```typescript +'read_only' | 'read_write' | 'restricted' +``` + +### `AzionClientOptions` Configuration options for the Storage client. | Parameter | Type | Description | |-----------|------|-------------| -| `token?` | `string` | Your Azion API token. | | `debug?` | `boolean` | Enables debug mode for detailed logging. | +| `force?` | `boolean` | Force the operation even if it might be destructive. | +| `env?` | [`AzionEnvironment`](#azionenvironment) | Environment to use (dev, stage, prod). | +| `external?` | `boolean` | Force using external REST API instead of built-in runtime API. | + +### AzionEnvironment + +The environment in which the client operates. + +```typescript +'development' | 'staging' | 'production' +``` ### `StorageClient` @@ -429,8 +461,8 @@ An object with methods to interact with Storage. | Method | Parameters | Return Type | |--------|------------|--------------| | `getBuckets` | `options?: BucketCollectionOptions` | `Promise>` | -| `createBucket` | `name: string, edge_access: string` | `Promise>` | -| `updateBucket` | `name: string, edge_access: string` | `Promise>` | +| `createBucket` | `name: string, edge_access: EdgeAccessType` | `Promise>` | +| `updateBucket` | `name: string, edge_access: EdgeAccessType` | `Promise>` | | `deleteBucket` | `name: string` | `Promise>` | | `getBucket` | `name: string` | `Promise>` | @@ -450,7 +482,7 @@ The bucket object. | Property | Type | Description | |----------|------|-------------| | `name` | `string` | The name of the bucket. | -| `edge_access` | `string` (optional) | The `edge access` of the bucket. | +| `edge_access` | [`EdgeAccessType`](#edgeaccesstype) | The `edge access` of the bucket. | | `state` | `'executed' \| 'pending'` (optional) | The state of the bucket. | | `getObjects` | `() => Promise>` (optional) | A method to get all objects in the bucket. | | `getObjectByKey` | `(objectKey: string) => Promise>` (optional) | A method to get an object by its key. | diff --git a/src/content/docs/pt-br/pages/devtools/azion-lib/usage/storage.mdx b/src/content/docs/pt-br/pages/devtools/azion-lib/usage/storage.mdx index 10e2ec9c01..84c6424ae1 100644 --- a/src/content/docs/pt-br/pages/devtools/azion-lib/usage/storage.mdx +++ b/src/content/docs/pt-br/pages/devtools/azion-lib/usage/storage.mdx @@ -48,13 +48,14 @@ if (data) { console.error('Failed to create bucket', error); } ``` + O método `createClient` tem os seguintes **parâmetros** e **valor de retorno**: **Parâmetros**: | Parâmetro | Tipo | Descrição | |-----------|------|-------------| -| `config` | `Partial<{ token: string; options?: OptionsParams }>` | Configurações do `client` do Storage. | +| `config` | `Partial<{ token: string; options?: AzionClientOptions }>` | Configurações do `client` do Storage. | **Retorno**: @@ -81,7 +82,7 @@ import { createBucket } from 'azion/storage'; import type { AzionStorageResponse, AzionBucket } from 'azion/storage'; const { data, error }: AzionStorageResponse = await createBucket({ name: 'my-new-bucket', - edge_access: 'public', + edge_access: 'read_write', }); if (data) { console.log(`Bucket created with name: ${data.name}`); @@ -89,13 +90,14 @@ if (data) { console.error('Failed to create bucket', error); } ``` + **Parâmetros**: | Parâmetro | Tipo | Descrição | |-----------|------|-------------| | `name` | `string` | O nome do novo bucket. | -| `edge_access` | `string` | A configuração de `edge access` do bucket. | -| `options?` | `AzionClientOptions` | Parâmetros opcionais para a requisição. | +| `edge_access` | [`EdgeAccessType`](#edgeaccesstype) | A configuração de `edge access` do bucket. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Parâmetros opcionais para a requisição. | **Retorno**: @@ -125,7 +127,7 @@ if (data) { | Parâmetro | Tipo | Descrição | |-----------|------|-------------| | `name` | `string` | O nome do bucket a ser excluído. | -| `debug?` | `boolean` | Habilita o modo de debug para logs detalhados. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Parâmetros opcionais para a requisição. | **Retorno**: @@ -156,10 +158,8 @@ if (buckets) { | Parâmetro | Tipo | Descrição | |-----------|------|-------------| -| `options?` | `AzionBucketCollectionOptions` | Parâmetros opcionais para filtragem e paginação. | -| `page?` | `number` | O número da página para paginação. | -| `page_size?` | `number` | O número de itens por página. | -| `debug?` | `boolean` | Ativa o modo de debug para logs detalhados. | +| `params?` | [`AzionBucketCollectionParams`](#azionbucketcollectionparams) | Parâmetros para filtragem e paginação. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Parâmetros opcionais para a requisição. | **Retorno**: @@ -189,7 +189,7 @@ if (bucket) { | Parâmetro | Tipo | Descrição | |-----------|------|-------------| | `name` | `string` | O nome do bucket a ser atualizado. | -| `debug?` | `boolean` | Ativa o modo de debug para logs detalhados. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Parâmetros opcionais para a requisição. | **Retorno**: @@ -208,7 +208,7 @@ import { updateBucket, AzionBucket, AzionStorageResponse } from 'azion/storage'; const { data: updatedBucket, error }: AzionStorageResponse | null = await updateBucket({ name: 'my-bucket', - edge_access: 'private', + edge_access: 'read_write', }); if (updatedBucket) { console.log(`Bucket updated: ${updatedBucket.name}`); @@ -222,8 +222,8 @@ if (updatedBucket) { | Parâmetro | Tipo | Descrição | |-----------|------|-------------| | `name` | `string` | O nome do bucket a ser atualizado. | -| `edge_access` | `string` | A nova configuração de `edge access` para o bucket. | -| `debug?` | `boolean` | Ativa o modo de debug para logs detalhados. | +| `edge_access` | [`EdgeAccessType`](#edgeaccesstype) | A configuração de `edge access` do bucket. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Parâmetros opcionais para a requisição. | **Retorno**: @@ -241,9 +241,9 @@ Exemplo: import { createObject, AzionBucketObject, AzionStorageResponse } from 'azion/storage'; const { data: newObject, error }: AzionStorageResponse = await createObject({ - bucketName: 'my-bucket', + name: 'my-bucket', key: 'new-file.txt', - file: 'File content', + content: 'File content', }); if (newObject) { console.log(`Object created with key: ${newObject.key}`); @@ -257,10 +257,10 @@ if (newObject) { | Parâmetro | Tipo | Descrição | |-------------|----------|---------------------------------------------| -| `bucketName` | `string` | O nome do bucket onde o objeto será criado. | -| `objectKey` | `string` | A chave (nome) do objeto a ser criado. | -| `file` | `string` | O conteúdo do arquivo a ser enviado. | -| `debug?` | `boolean`| Ativa o modo de debug para logs detalhados. | +| `name` | `string` | O nome do bucket onde o objeto será criado. | +| `key` | `string` | A chave (nome) do objeto a ser criado. | +| `content` | `string` | O conteúdo do arquivo a ser enviado. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Parâmetros opcionais para a requisição. | **Retorno**: @@ -278,7 +278,7 @@ Exemplo: import { getObjectByKey, AzionBucketObject, AzionStorageResponse } from 'azion/storage'; const { data: object, error }: AzionStorageResponse = await getObjectByKey({ - bucketName: 'my-bucket', + name: 'my-bucket', key: 'file.txt', }); if (object) { @@ -292,9 +292,9 @@ if (object) { | Parâmetro | Tipo | Descrição | |-----------|------|-------------| -| `bucketName` | `string` | O nome do bucket contendo o objeto. | -| `objectKey` | `string` | A chave do objeto a ser recuperado. | -| `debug?` | `boolean` | Ativa o modo de debug para logs detalhados. | +| `name` | `string` | O nome do bucket contendo o objeto. | +| `key` | `string` | A chave do objeto a ser recuperado. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Parâmetros opcionais para a requisição. | **Retorno**: @@ -312,7 +312,7 @@ Exemplo: import { getObjects, AzionBucketObject, AzionStorageResponse } from 'azion/storage'; const { data: objectResult, error }: AzionStorageResponse = await getObjects({ - bucketName: 'my-bucket', + name: 'my-bucket', }); if (objectResult) { console.log(`Retrieved ${objectResult.count} objects from the bucket`); @@ -325,8 +325,8 @@ if (objectResult) { | Parâmetro | Tipo | Descrição | |-----------|------|-------------| -| `bucketName` | `string` | O nome do bucket a partir do qual os objetos devem ser recuperados. | -| `debug?` | `boolean` | Ativa o modo de debug para logs detalhados. | +| `name` | `string` | O nome do bucket a partir do qual os objetos devem ser recuperados. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Parâmetros opcionais para a requisição. | **Retorno**: @@ -344,9 +344,9 @@ Exemplo: import { updateObject, AzionBucketObject } from 'azion/storage'; const { data: updatedObject, error }: AzionStorageResponse = await updateObject({ - bucketName: 'my-bucket', + name: 'my-bucket', key: 'file.txt', - file: 'Updated content', + content: 'Updated content', }); if (updatedObject) { console.log(`Object updated: ${updatedObject.key}`); @@ -355,14 +355,15 @@ if (updatedObject) { console.error('Failed to update object', error); } ``` + **Parâmetros**: | Parâmetro | Tipo | Descrição | |-----------|------|-------------| -| `bucketName` | `string` | O nome do bucket que contém o objeto. | -| `objectKey` | `string` | O nome do objeto a ser atualizado. | -| `arquivo` | `string` | O novo conteúdo do arquivo. | -| `debug?` | `boolean` | Ativa o modo de debug para logs detalhados. | +| `name` | `string` | O nome do bucket que contém o objeto. | +| `key` | `string` | O nome do objeto a ser atualizado. | +| `content` | `string` | O novo conteúdo do arquivo. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Parâmetros opcionais para a requisição. | **Retorno**: @@ -380,7 +381,7 @@ Exemplo: import { deleteObject, AzionDeletedBucketObject, AzionStorageResponse } from 'azion/storage'; const { data: result, error }: AzionStorageResponse = await deleteObject({ - bucketName: 'my-bucket', + name: 'my-bucket', key: 'file.txt', }); if (result) { @@ -389,13 +390,14 @@ if (result) { console.error('Failed to delete object', error); } ``` + **Parâmetros**: | Parâmetro | Tipo | Descrição | |-----------|------|-------------| -| `bucketName` | `string` | O nome do bucket que contém o objeto. | -| `objectKey` | `string` | O nome do objeto a ser excluído. | -| `debug?` | `boolean` | Ativa o modo de debug para logs detalhados. | +| `name` | `string` | O nome do bucket que contém o objeto. | +| `key` | `string` | O nome do objeto a ser excluído. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Parâmetros opcionais para a requisição. | **Retorno**: @@ -409,14 +411,47 @@ if (result) { Estes são os tipos usados pela biblioteca **Storage** e seus métodos: -### `ClientConfig` +### AzionBucketCollectionParams + +Parâmetros para filtragem e paginação ao solicitar uma coleção de buckets. + +| Parâmetro | Tipo | Descrição | +|-----------|------|-------------| +| `page?` | `number` | O número da página para paginação. | +| `page_size?` | `number` | O número de itens por página. | + +### `AzionObjectCollectionParams` + +| Parâmetro | Tipo | Descrição | +|-----------|------|-------------| +| `max_object_count?` | `number` | O número máximo de objetos a serem retornados. | + +### `EdgeAccessType` + +O tipo de controle de acesso para o bucket. + +```typescript +'read_only' | 'read_write' | 'restricted' +``` + +### `AzionClientOptions` Opções de configuração para o `client` de Storage. | Parâmetro | Tipo | Descrição | |-----------|------|-------------| -| `token?` | `string` | Seu token de API da Azion. | | `debug?` | `boolean` | Ativa o modo de debug para logs detalhados. | +| `force?` | `boolean` | Força a operação mesmo que possa ser destrutiva. | +| `env?` | [`AzionEnvironment`](#azionenvironment) | Ambiente a ser utilizado (desenvolvimento, homologação, produção). | +| `external?` | `boolean` | Força o uso da API REST externa em vez da API interna do runtime. | + +### AzionEnvironment + +O ambiente em que o cliente opera. + +```typescript +'development' | 'staging' | 'production' +``` ### `StorageClient` @@ -425,8 +460,8 @@ Um objeto com métodos para interagir com o Storage. | Método | Parâmetros | Tipo de retorno | |--------|------------|-----------------| | `getBuckets` | `options?: BucketCollectionOptions` | `Promise>` | -| `createBucket` | `name: string, edge_access: string` | `Promise>` | -| `updateBucket` | `name: string, edge_access: string` | `Promise>` | +| `createBucket` | `name: string, edge_access: EdgeAccessType` | `Promise>` | +| `updateBucket` | `name: string, edge_access: EdgeAccessType` | `Promise>` | | `deleteBucket` | `name: string` | `Promise>` | | `getBucket` | `name: string` | `Promise>` | @@ -446,7 +481,7 @@ O objeto bucket. | Propriedade | Tipo | Descrição | |-------------|------|-------------| | `name` | `string` | O nome do bucket. | -| `edge_access` | `string` (opcional) | A configuração `edge access` do bucket. | +| `edge_access` | [`EdgeAccessType`](#edgeaccesstype) | A configuração `edge access` do bucket. | | `state` | `'executed' \| 'pending'` (opcional) | O estado do bucket. | | `getObjects` | `() => Promise>` (opcional) | Um método para obter todos os objetos no bucket. | | `getObjectByKey` | `(objectKey: string) => Promise>` (opcional) | Um método para obter um objeto pela sua chave. |