Skip to content

Commit

Permalink
refactoring: update return types in data manipulation guides to use O…
Browse files Browse the repository at this point in the history
…perationResult and BatchOperationResult
  • Loading branch information
teles committed Dec 30, 2024
1 parent 223987c commit d0ae53d
Show file tree
Hide file tree
Showing 20 changed files with 72 additions and 72 deletions.
4 changes: 2 additions & 2 deletions docs/en/guides/clearing-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const result = await holySheetsInstance.clearFirst(

### Returns

A promise that resolves to a `SanitizedOperationResult<RecordType>` containing the cleared record and optional metadata.
A promise that resolves to a `OperationResult<RecordType>` containing the cleared record and optional metadata.

---

Expand Down Expand Up @@ -77,7 +77,7 @@ const results = await holySheetsInstance.clearMany(

### Returns

A promise that resolves to a `SanitizedBatchOperationResult<RecordType>` containing the cleared records and optional metadata.
A promise that resolves to a `BatchOperationResult<RecordType>` containing the cleared records and optional metadata.

---

Expand Down
4 changes: 2 additions & 2 deletions docs/en/guides/deleting-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const result = await holySheetsInstance.deleteFirst(

### Returns

A promise that resolves to a `SanitizedOperationResult<RecordType>` containing the deleted record and optional metadata.
A promise that resolves to a `OperationResult<RecordType>` containing the deleted record and optional metadata.

---

Expand Down Expand Up @@ -77,7 +77,7 @@ const results = await holySheetsInstance.deleteMany(

### Returns

A promise that resolves to a `SanitizedBatchOperationResult<RecordType>` containing the deleted records and optional metadata.
A promise that resolves to a `BatchOperationResult<RecordType>` containing the deleted records and optional metadata.

---

Expand Down
6 changes: 3 additions & 3 deletions docs/en/guides/finding-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const result = await holySheetsInstance.findFirst({

### Returns

A promise that resolves to a `SanitizedOperationResult<RecordType>` containing the first matching record and optional metadata.
A promise that resolves to a `OperationResult<RecordType>` containing the first matching record and optional metadata.

## findMany

Expand Down Expand Up @@ -74,7 +74,7 @@ const results = await holySheetsInstance.findMany({

### Returns

A promise that resolves to a `SanitizedBatchOperationResult<RecordType>` containing the matching records and optional metadata.
A promise that resolves to a `BatchOperationResult<RecordType>` containing the matching records and optional metadata.

## findAll

Expand Down Expand Up @@ -108,7 +108,7 @@ const allRecords = await holySheetsInstance.findAll({

### Returns

A promise that resolves to a `SanitizedBatchOperationResult<RecordType>` containing all records and optional metadata.
A promise that resolves to a `BatchOperationResult<RecordType>` containing all records and optional metadata.

---

Expand Down
2 changes: 1 addition & 1 deletion docs/en/guides/inserting-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const result = await holySheetsInstance.insert(

### Returns

A promise that resolves to a `SanitizedOperationResult<RecordType[]>` containing the inserted records and optional metadata.
A promise that resolves to a `OperationResult<RecordType[]>` containing the inserted records and optional metadata.

---

Expand Down
4 changes: 2 additions & 2 deletions docs/en/guides/updating-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const result = await holySheetsInstance.updateFirst(

### Returns

A promise that resolves to a `SanitizedOperationResult<RecordType>` containing the updated record and optional metadata.
A promise that resolves to a `OperationResult<RecordType>` containing the updated record and optional metadata.

---

Expand Down Expand Up @@ -81,7 +81,7 @@ const results = await holySheetsInstance.updateMany(

### Returns

A promise that resolves to a `SanitizedBatchOperationResult<RecordType>` containing all updated records and optional metadata.
A promise that resolves to a `BatchOperationResult<RecordType>` containing all updated records and optional metadata.

---

Expand Down
12 changes: 6 additions & 6 deletions docs/en/reference/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Below is a quick-reference table for the most common **HolySheets!** types, foll
| `SelectClause<RecordType>` | Determines which columns to return (`true` to include, `false` to omit). |
| `OperationConfigs` | Configurations for including metadata and other optional features. |
| `OperationMetadata` | Contains details about a completed operation (e.g., duration, status, errors). |
| `SanitizedOperationResult<T>` | Return type for single-record operations (e.g., `findFirst`). |
| `SanitizedBatchOperationResult<T>` | Return type for multi-record operations (e.g., `findMany`). |
| `OperationResult<RecordType>` | Return type for single-record operations (e.g., `findFirst`). |
| `BatchOperationResult<RecordType>` | Return type for multi-record operations (e.g., `findMany`). |

---

Expand Down Expand Up @@ -137,31 +137,31 @@ export interface OperationMetadata {

---

## `SanitizedOperationResult<T>`
## `OperationResult<RecordType>`

Represents the result of a **single-record operation** (like `findFirst`, `updateFirst`, `deleteFirst`, etc.). It includes:

- **`data`**: The returned record (or `undefined` if none found).
- **`metadata`**: Optional metadata (if `includeMetadata` was `true`).

```ts
export interface SanitizedOperationResult<T> {
export interface OperationResult<RecordType> {
data: T | undefined
metadata?: OperationMetadata
}
```

---

## `SanitizedBatchOperationResult<T>`
## `BatchOperationResult<RecordType>`

Represents the result of a **multi-record operation** (like `findMany`, `updateMany`, `deleteMany`, etc.). It includes:

- **`data`**: An array of records (or `undefined` if none found).
- **`metadata`**: Optional metadata (if `includeMetadata` was `true`).

```ts
export interface SanitizedBatchOperationResult<T> {
export interface BatchOperationResult<RecordType> {
data: T[] | undefined
metadata?: OperationMetadata
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/clearFirst/clearFirst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { WhereClause } from '@/types/where'
import { findFirst } from '@/core/findFirst/findFirst'
import { CellValue } from '@/types/cellValue'
import { OperationConfigs } from '@/types/operationConfigs'
import { OperationResult } from '@/services/metadata/IMetadataService'
import { RawOperationResult } from '@/services/metadata/IMetadataService'
import { MetadataService } from '@/services/metadata/MetadataService'
import { IMetadataService } from '@/services/metadata/IMetadataService'
import { ErrorMessages, ErrorCode } from '@/services/errors/errorMessages'
Expand Down Expand Up @@ -44,7 +44,7 @@ export async function clearFirst<RecordType extends Record<string, CellValue>>(
where: WhereClause<RecordType>
},
configs?: OperationConfigs
): Promise<OperationResult<RecordType>> {
): Promise<RawOperationResult<RecordType>> {
const { spreadsheetId, sheets, sheet } = params
const { where } = options
const { includeMetadata = false } = configs ?? {}
Expand Down
4 changes: 2 additions & 2 deletions src/core/clearMany/clearMany.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { OperationConfigs } from '@/types/operationConfigs'
import { MetadataService } from '@/services/metadata/MetadataService'
import {
IMetadataService,
BatchOperationResult
RawBatchOperationResult
} from '@/services/metadata/IMetadataService'
import { ErrorMessages, ErrorCode } from '@/services/errors/errorMessages'

Expand Down Expand Up @@ -46,7 +46,7 @@ export async function clearMany<RecordType extends Record<string, CellValue>>(
where: WhereClause<RecordType>
},
configs?: OperationConfigs
): Promise<BatchOperationResult<RecordType>> {
): Promise<RawBatchOperationResult<RecordType>> {
const { spreadsheetId, sheets, sheet } = params
const { where } = options
const { includeMetadata = false } = configs ?? {}
Expand Down
4 changes: 2 additions & 2 deletions src/core/deleteFirst/deleteFirst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { WhereClause } from '@/types/where'
import { findFirst } from '@/core/findFirst/findFirst'
import { CellValue } from '@/types/cellValue'
import { OperationConfigs } from '@/types/operationConfigs'
import { OperationResult } from '@/services/metadata/IMetadataService'
import { RawOperationResult } from '@/services/metadata/IMetadataService'
import { MetadataService } from '@/services/metadata/MetadataService'
import { IMetadataService } from '@/services/metadata/IMetadataService'
import { ErrorMessages, ErrorCode } from '@/services/errors/errorMessages'
Expand Down Expand Up @@ -44,7 +44,7 @@ export async function deleteFirst<RecordType extends Record<string, CellValue>>(
where: WhereClause<RecordType>
},
configs?: OperationConfigs
): Promise<OperationResult<RecordType>> {
): Promise<RawOperationResult<RecordType>> {
const { spreadsheetId, sheets, sheet } = params
const { where } = options
const { includeMetadata = false } = configs ?? {}
Expand Down
4 changes: 2 additions & 2 deletions src/core/deleteMany/deleteMany.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { OperationConfigs } from '@/types/operationConfigs'
import { MetadataService } from '@/services/metadata/MetadataService'
import {
IMetadataService,
BatchOperationResult
RawBatchOperationResult
} from '@/services/metadata/IMetadataService'
import { ErrorMessages, ErrorCode } from '@/services/errors/errorMessages'

Expand Down Expand Up @@ -46,7 +46,7 @@ export async function deleteMany<RecordType extends Record<string, CellValue>>(
where: WhereClause<RecordType>
},
configs?: OperationConfigs
): Promise<BatchOperationResult<RecordType>> {
): Promise<RawBatchOperationResult<RecordType>> {
const { spreadsheetId, sheets, sheet } = params
const { where } = options
const { includeMetadata = false } = configs ?? {}
Expand Down
4 changes: 2 additions & 2 deletions src/core/findAll/findAll.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ErrorCode, ErrorMessages } from '@/services/errors/errorMessages'
import { IGoogleSheetsService } from '@/services/google-sheets/IGoogleSheetsService'
import {
BatchOperationResult,
RawBatchOperationResult,
IMetadataService
} from '@/services/metadata/IMetadataService'
import { MetadataService } from '@/services/metadata/MetadataService'
Expand Down Expand Up @@ -50,7 +50,7 @@ export async function findAll<RecordType extends Record<string, CellValue>>(
includeEmptyRows?: boolean
},
configs?: OperationConfigs
): Promise<BatchOperationResult<RecordType>> {
): Promise<RawBatchOperationResult<RecordType>> {
const { spreadsheetId, sheets, sheet } = params
const { select, includeEmptyRows = false } = options || {}
const { includeMetadata = false } = configs ?? {}
Expand Down
4 changes: 2 additions & 2 deletions src/core/findFirst/findFirst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { CellValue } from '@/types/cellValue'
import { OperationConfigs } from '@/types/operationConfigs'
import {
IMetadataService,
OperationResult
RawOperationResult
} from '@/services/metadata/IMetadataService'
import { MetadataService } from '@/services/metadata/MetadataService'
import { ErrorCode, ErrorMessages } from '@/services/errors/errorMessages'
Expand All @@ -29,7 +29,7 @@ export async function findFirst<RecordType extends Record<string, CellValue>>(
select?: SelectClause<RecordType>
},
configs?: OperationConfigs
): Promise<OperationResult<RecordType>> {
): Promise<RawOperationResult<RecordType>> {
const { spreadsheetId, sheets, sheet } = params
const { where, select } = options
const { includeMetadata = false } = configs ?? {}
Expand Down
4 changes: 2 additions & 2 deletions src/core/findMany/findMany.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { OperationConfigs } from '@/types/operationConfigs'
import { MetadataService } from '@/services/metadata/MetadataService'
import {
IMetadataService,
BatchOperationResult
RawBatchOperationResult
} from '@/services/metadata/IMetadataService'
import { ErrorMessages, ErrorCode } from '@/services/errors/errorMessages'

Expand Down Expand Up @@ -56,7 +56,7 @@ export async function findMany<RecordType extends Record<string, CellValue>>(
select?: SelectClause<RecordType>
},
configs?: OperationConfigs
): Promise<BatchOperationResult<RecordType>> {
): Promise<RawBatchOperationResult<RecordType>> {
const { spreadsheetId, sheets, sheet } = params
const { where, select } = options
const { includeMetadata = false } = configs ?? {}
Expand Down
4 changes: 2 additions & 2 deletions src/core/getSheetId/getSheetId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { OperationConfigs } from '@/types/operationConfigs'
import { MetadataService } from '@/services/metadata/MetadataService'
import {
IMetadataService,
OperationResult
RawOperationResult
} from '@/services/metadata/IMetadataService'
import { ErrorMessages, ErrorCode } from '@/services/errors/errorMessages'

Expand Down Expand Up @@ -42,7 +42,7 @@ export async function getSheetId(
title: string
},
configs?: OperationConfigs
): Promise<OperationResult<number>> {
): Promise<RawOperationResult<number>> {
const { spreadsheetId, sheets, title } = params
const { includeMetadata = false } = configs ?? {}
const metadataService: IMetadataService = new MetadataService()
Expand Down
4 changes: 2 additions & 2 deletions src/core/insert/insert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@/utils/rangeUtils/rangeUtils'
import { CellValue } from '@/types/cellValue'
import { OperationConfigs } from '@/types/operationConfigs'
import { OperationResult } from '@/services/metadata/IMetadataService'
import { RawOperationResult } from '@/services/metadata/IMetadataService'
import { MetadataService } from '@/services/metadata/MetadataService'
import { IMetadataService } from '@/services/metadata/IMetadataService'
import { ErrorMessages, ErrorCode } from '@/services/errors/errorMessages'
Expand Down Expand Up @@ -51,7 +51,7 @@ export async function insert<RecordType extends Record<string, CellValue>>(
params: InsertParams,
options: { data: RecordType[] },
configs?: OperationConfigs
): Promise<OperationResult<RecordType[]>> {
): Promise<RawOperationResult<RecordType[]>> {
const { spreadsheetId, sheets, sheet } = params
const { data } = options
const { includeMetadata = false } = configs ?? {}
Expand Down
4 changes: 2 additions & 2 deletions src/core/updateFirst/updateFirst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { OperationConfigs } from '@/types/operationConfigs'
import { MetadataService } from '@/services/metadata/MetadataService'
import {
IMetadataService,
OperationResult
RawOperationResult
} from '@/services/metadata/IMetadataService'
import { ErrorMessages, ErrorCode } from '@/services/errors/errorMessages'

Expand Down Expand Up @@ -49,7 +49,7 @@ export async function updateFirst<RecordType extends Record<string, CellValue>>(
data: Partial<RecordType>
},
configs?: OperationConfigs
): Promise<OperationResult<RecordType>> {
): Promise<RawOperationResult<RecordType>> {
const { spreadsheetId, sheets, sheet } = params
const { where, data } = options
const { includeMetadata = false } = configs ?? {}
Expand Down
4 changes: 2 additions & 2 deletions src/core/updateMany/updateMany.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { CellValue } from '@/types/cellValue'
import { MetadataService } from '@/services/metadata/MetadataService'
import {
IMetadataService,
BatchOperationResult
RawBatchOperationResult
} from '@/services/metadata/IMetadataService'
import { OperationConfigs } from '@/types/operationConfigs'
import { ErrorMessages, ErrorCode } from '@/services/errors/errorMessages'
Expand Down Expand Up @@ -49,7 +49,7 @@ export async function updateMany<RecordType extends Record<string, CellValue>>(
data: Partial<RecordType>
},
configs?: OperationConfigs
): Promise<BatchOperationResult<RecordType>> {
): Promise<RawBatchOperationResult<RecordType>> {
const { spreadsheetId, sheets, sheet } = params
const { where, data } = options
const { includeMetadata = false } = configs ?? {}
Expand Down
Loading

0 comments on commit d0ae53d

Please sign in to comment.