From 88e5bf25a084fb389879088f468727befe6c8e70 Mon Sep 17 00:00:00 2001 From: Theo Sun Date: Sun, 9 Aug 2020 08:48:02 +0800 Subject: [PATCH] feat: type for batch request for odata 4.01 --- src/builder/batch.ts | 21 +++++++++++++++++++++ src/builder/index.ts | 3 +++ 2 files changed, 24 insertions(+) create mode 100644 src/builder/batch.ts diff --git a/src/builder/batch.ts b/src/builder/batch.ts new file mode 100644 index 0000000..1de65bb --- /dev/null +++ b/src/builder/batch.ts @@ -0,0 +1,21 @@ +// https://docs.oasis-open.org/odata/odata-json-format/v4.01/odata-json-format-v4.01.html#_Toc38457781 +// support json format for batch request + +export interface JsonBatchBundle { + requests: JsonBatchRequest[]; +} + +export type JsonBatchMethod = 'get' | 'post' | 'put' | 'patch' | 'delete' + +export type JsonBatchHeaders = Record + +export interface JsonBatchRequest { + id: string; + method: JsonBatchMethod; + url: string; + atomicityGroup?: string; + dependsOn?: string[]; + headers?: JsonBatchHeaders; + body?: T; +} + diff --git a/src/builder/index.ts b/src/builder/index.ts index 57d6092..7271967 100644 --- a/src/builder/index.ts +++ b/src/builder/index.ts @@ -1,3 +1,6 @@ +import { createRequireFromPath } from 'module'; + export * from './filter'; export * from './param'; export * from './types'; +export * from './batch';