Skip to content

Commit

Permalink
Fixing build errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
vikask00 committed Jan 11, 2023
1 parent a078274 commit 076765b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 28 deletions.
35 changes: 21 additions & 14 deletions sdk/cosmosdb/cosmos/review/cosmos.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class ClientContext {
batch<T>({ body, path, partitionKey, resourceId, options, }: {
body: T;
path: string;
partitionKey: string;
partitionKey: PartitionKey;
resourceId: string;
options?: RequestOptions;
}): Promise<Response_2<any>>;
Expand Down Expand Up @@ -584,7 +584,7 @@ export interface CreateOperationInput {
// (undocumented)
operationType: typeof BulkOperationType.Create;
// (undocumented)
partitionKey?: string | number | null | Record<string, unknown> | undefined;
partitionKey?: PartitionKey;
// (undocumented)
resourceBody: JSONObject;
}
Expand Down Expand Up @@ -694,7 +694,7 @@ export interface DeleteOperationInput {
// (undocumented)
operationType: typeof BulkOperationType.Delete;
// (undocumented)
partitionKey?: string | number | null | Record<string, unknown> | undefined;
partitionKey?: PartitionKey;
}

// @public (undocumented)
Expand Down Expand Up @@ -734,8 +734,10 @@ export type ExistingKeyOperation = {
path: string;
};

// @public (undocumented)
export function extractPartitionKey(document: unknown, partitionKeyDefinition: PartitionKeyDefinition): PartitionKey[];
// Warning: (ae-forgotten-export) The symbol "PartitionKeyInternal" needs to be exported by the entry point index.d.ts
//
// @public
export function extractPartitionKey(document: unknown, partitionKeyDefinition?: PartitionKeyDefinition): PartitionKeyInternal | undefined;

// @public
export interface FeedOptions extends SharedOptions {
Expand All @@ -752,7 +754,7 @@ export interface FeedOptions extends SharedOptions {
forceQueryPlan?: boolean;
maxDegreeOfParallelism?: number;
maxItemCount?: number;
partitionKey?: any;
partitionKey?: PartitionKey;
populateQueryMetrics?: boolean;
useIncrementalFeed?: boolean;
}
Expand Down Expand Up @@ -870,7 +872,7 @@ export enum IndexKind {

// @public
export class Item {
constructor(container: Container, id: string, partitionKey: PartitionKey, clientContext: ClientContext);
constructor(container: Container, id: string, clientContext: ClientContext, partitionKey?: PartitionKey);
// (undocumented)
readonly container: Container;
delete<T extends ItemDefinition = any>(options?: RequestOptions): Promise<ItemResponse<T>>;
Expand Down Expand Up @@ -900,7 +902,7 @@ export class ItemResponse<T extends ItemDefinition> extends ResourceResponse<T &
// @public
export class Items {
constructor(container: Container, clientContext: ClientContext);
batch(operations: OperationInput[], partitionKey?: string, options?: RequestOptions): Promise<Response_2<OperationResponse[]>>;
batch(operations: OperationInput[], partitionKey?: PartitionKey, options?: RequestOptions): Promise<Response_2<OperationResponse[]>>;
bulk(operations: OperationInput[], bulkOptions?: BulkOptions, options?: RequestOptions): Promise<OperationResponse[]>;
changeFeed(partitionKey: string | number | boolean, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<any>;
changeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<any>;
Expand Down Expand Up @@ -1074,15 +1076,20 @@ export interface PartitionedQueryExecutionInfo {
queryRanges: QueryRange[];
}

// Warning: (ae-forgotten-export) The symbol "PrimitivePartitionKeyValue" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export type PartitionKey = PartitionKeyDefinition | string | number | unknown;
export type PartitionKey = PrimitivePartitionKeyValue | PrimitivePartitionKeyValue[];

// @public (undocumented)
export interface PartitionKeyDefinition {
// Warning: (ae-forgotten-export) The symbol "PartitionKeyKind" needs to be exported by the entry point index.d.ts
kind?: PartitionKeyKind;
paths: string[];
// (undocumented)
systemKey?: boolean;
version?: number;
// Warning: (ae-forgotten-export) The symbol "PartitionKeyDefinitionVersion" needs to be exported by the entry point index.d.ts
version?: PartitionKeyDefinitionVersion;
}

// @public (undocumented)
Expand Down Expand Up @@ -1127,7 +1134,7 @@ export interface PatchOperationInput {
// (undocumented)
operationType: typeof BulkOperationType.Patch;
// (undocumented)
partitionKey?: string | number | null | Record<string, unknown> | undefined;
partitionKey?: PartitionKey;
// (undocumented)
resourceBody: PatchRequestBody;
}
Expand Down Expand Up @@ -1381,7 +1388,7 @@ export interface ReadOperationInput {
// (undocumented)
operationType: typeof BulkOperationType.Read;
// (undocumented)
partitionKey?: string | number | boolean | null | Record<string, unknown> | undefined;
partitionKey?: PartitionKey;
}

// @public (undocumented)
Expand All @@ -1407,7 +1414,7 @@ export interface ReplaceOperationInput {
// (undocumented)
operationType: typeof BulkOperationType.Replace;
// (undocumented)
partitionKey?: string | number | null | Record<string, unknown> | undefined;
partitionKey?: PartitionKey;
// (undocumented)
resourceBody: JSONObject;
}
Expand Down Expand Up @@ -2014,7 +2021,7 @@ export interface UpsertOperationInput {
// (undocumented)
operationType: typeof BulkOperationType.Upsert;
// (undocumented)
partitionKey?: string | number | null | Record<string, unknown> | undefined;
partitionKey?: PartitionKey;
// (undocumented)
resourceBody: JSONObject;
}
Expand Down
1 change: 0 additions & 1 deletion sdk/cosmosdb/cosmos/src/client/Item/Items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
OperationInput,
BulkOptions,
decorateBatchOperation,
hasResource,
} from "../../utils/batch";
import { assertNotUndefined } from "../../utils/typeChecks";
import { hashPartitionKey } from "../../utils/hashing/hash";
Expand Down
3 changes: 0 additions & 3 deletions sdk/cosmosdb/cosmos/src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,6 @@ export const Constants = {
DatabaseAccountPathSegment: "databaseaccount",
},

// Maximum number of partition keys allowed for a container.
MaxNumberOfPartitionKeysAllowed: 3,

PartitionKeyRange: {
// Partition Key Range Constants
MinInclusive: "minInclusive",
Expand Down
9 changes: 0 additions & 9 deletions sdk/cosmosdb/cosmos/src/documents/PartitionKey.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { Constants } from "../common";
import { NonePartitionKeyLiteral, NullPartitionKeyLiteral } from "./PartitionKeyInternal";

export type PartitionKey = PrimitivePartitionKeyValue | PrimitivePartitionKeyValue[];
Expand Down Expand Up @@ -36,24 +35,16 @@ export type NonePartitionKey = {
export class PartitionKeyBuilder {
readonly values: PrimitivePartitionKeyValue[] = [];
public addValue(value: string | boolean | number): PartitionKeyBuilder {
this.checkPartitionKeySize();
this.values.push(value);
return this;
}
public addNullValue() {
this.checkPartitionKeySize();
this.values.push(NullPartitionKeyLiteral)
}
public addNoneValue() {
this.checkPartitionKeySize();
this.values.push(NonePartitionKeyLiteral)
}
public build(): PartitionKey {
return [...this.values];
}
private checkPartitionKeySize() {
if(this.values.length >= Constants.MaxNumberOfPartitionKeysAllowed) {
throw new Error(`Only ${Constants.MaxNumberOfPartitionKeysAllowed} partition keys are allowed.`);
}
}
}
2 changes: 1 addition & 1 deletion sdk/cosmosdb/cosmos/test/public/functional/item.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,6 @@ describe("bulk/batch item operations", async function () {
});
describe("v2 container", function () {
describe("multi partition container", async function () {
let v2Container: Container;
let readItemId: string;
let replaceItemId: string;
let patchItemId: string;
Expand Down Expand Up @@ -785,6 +784,7 @@ describe("bulk/batch item operations", async function () {
{ id: replaceItemId, key: 5, key2: 5, key3: "T", class: "2012" },
{ id: patchItemId, key: 5, key2: 5, key3: true, class: "2019" },
],
bulkOperationOptions: {},
operations: [
{
description: 'Read document with partitionKey containing booleans values.',
Expand Down
1 change: 1 addition & 0 deletions sdk/cosmosdb/cosmos/tsconfig.strict.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
"src/routing/index.ts",
"src/utils/SasToken.ts",
"src/utils/tracing.ts",
"src/utils/hashing",
"src/client/SasToken/SasTokenProperties.ts",
"src/client/SasToken/PermissionScopeValues.ts",
"test/public/common/TestHelpers.ts",
Expand Down

0 comments on commit 076765b

Please sign in to comment.