UNPKG

4.47 kBTypeScriptView Raw
1import { JSONObject } from "../queryExecutionContext";
2import { PartitionKeyDefinition } from "../documents";
3import { RequestOptions } from "..";
4import { PatchRequestBody } from "./patch";
5export declare type Operation = CreateOperation | UpsertOperation | ReadOperation | DeleteOperation | ReplaceOperation | BulkPatchOperation;
6export interface Batch {
7 min: string;
8 max: string;
9 rangeId: string;
10 indexes: number[];
11 operations: Operation[];
12}
13export interface OperationResponse {
14 statusCode: number;
15 requestCharge: number;
16 eTag?: string;
17 resourceBody?: JSONObject;
18}
19/**
20 * Options object used to modify bulk execution.
21 * continueOnError (Default value: false) - Continues bulk execution when an operation fails ** NOTE THIS WILL DEFAULT TO TRUE IN the 4.0 RELEASE
22 */
23export interface BulkOptions {
24 continueOnError?: boolean;
25}
26export declare function isKeyInRange(min: string, max: string, key: string): boolean;
27export interface OperationBase {
28 partitionKey?: string;
29 ifMatch?: string;
30 ifNoneMatch?: string;
31}
32export declare const BulkOperationType: {
33 readonly Create: "Create";
34 readonly Upsert: "Upsert";
35 readonly Read: "Read";
36 readonly Delete: "Delete";
37 readonly Replace: "Replace";
38 readonly Patch: "Patch";
39};
40export declare type OperationInput = CreateOperationInput | UpsertOperationInput | ReadOperationInput | DeleteOperationInput | ReplaceOperationInput | PatchOperationInput;
41export interface CreateOperationInput {
42 partitionKey?: string | number | null | Record<string, unknown> | undefined;
43 ifMatch?: string;
44 ifNoneMatch?: string;
45 operationType: typeof BulkOperationType.Create;
46 resourceBody: JSONObject;
47}
48export interface UpsertOperationInput {
49 partitionKey?: string | number | null | Record<string, unknown> | undefined;
50 ifMatch?: string;
51 ifNoneMatch?: string;
52 operationType: typeof BulkOperationType.Upsert;
53 resourceBody: JSONObject;
54}
55export interface ReadOperationInput {
56 partitionKey?: string | number | boolean | null | Record<string, unknown> | undefined;
57 operationType: typeof BulkOperationType.Read;
58 id: string;
59}
60export interface DeleteOperationInput {
61 partitionKey?: string | number | null | Record<string, unknown> | undefined;
62 operationType: typeof BulkOperationType.Delete;
63 id: string;
64}
65export interface ReplaceOperationInput {
66 partitionKey?: string | number | null | Record<string, unknown> | undefined;
67 ifMatch?: string;
68 ifNoneMatch?: string;
69 operationType: typeof BulkOperationType.Replace;
70 resourceBody: JSONObject;
71 id: string;
72}
73export interface PatchOperationInput {
74 partitionKey?: string | number | null | Record<string, unknown> | undefined;
75 ifMatch?: string;
76 ifNoneMatch?: string;
77 operationType: typeof BulkOperationType.Patch;
78 resourceBody: PatchRequestBody;
79 id: string;
80}
81export declare type OperationWithItem = OperationBase & {
82 resourceBody: JSONObject;
83};
84export declare type CreateOperation = OperationWithItem & {
85 operationType: typeof BulkOperationType.Create;
86};
87export declare type UpsertOperation = OperationWithItem & {
88 operationType: typeof BulkOperationType.Upsert;
89};
90export declare type ReadOperation = OperationBase & {
91 operationType: typeof BulkOperationType.Read;
92 id: string;
93};
94export declare type DeleteOperation = OperationBase & {
95 operationType: typeof BulkOperationType.Delete;
96 id: string;
97};
98export declare type ReplaceOperation = OperationWithItem & {
99 operationType: typeof BulkOperationType.Replace;
100 id: string;
101};
102export declare type BulkPatchOperation = OperationBase & {
103 operationType: typeof BulkOperationType.Patch;
104 id: string;
105};
106export declare function hasResource(operation: Operation): operation is CreateOperation | UpsertOperation | ReplaceOperation;
107export declare function getPartitionKeyToHash(operation: Operation, partitionProperty: string): any;
108export declare function decorateOperation(operation: OperationInput, definition: PartitionKeyDefinition, options?: RequestOptions): Operation;
109export declare function decorateBatchOperation(operation: OperationInput, options?: RequestOptions): Operation;
110/**
111 * Util function for finding partition key values nested in objects at slash (/) separated paths
112 * @hidden
113 */
114export declare function deepFind<T, P extends string>(document: T, path: P): string | JSONObject;
115//# sourceMappingURL=batch.d.ts.map
\No newline at end of file