This commit is contained in:
Steve Faulkner 2019-06-05 20:53:23 -04:00 коммит произвёл GitHub
Родитель e001eeaf52
Коммит d63a79b02a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
17 изменённых файлов: 23 добавлений и 43 удалений

Просмотреть файл

@ -1,7 +1,6 @@
import { ClientContext } from "../../ClientContext";
import { Constants, getIdFromLink, getPathFromLink, isResourceValid, ResourceType, StatusCodes } from "../../common";
import { DEFAULT_PARTITION_KEY_PATH } from "../../common/partitionKeys";
import { PartitionKind } from "../../documents";
import { mergeHeaders, SqlQuerySpec } from "../../queryExecutionContext";
import { QueryIterator } from "../../queryIterator";
import { FeedOptions, RequestOptions } from "../../request";
@ -110,7 +109,6 @@ export class Containers {
// If they don't specify a partition key, use the default path
if (!body.partitionKey || !body.partitionKey.paths) {
body.partitionKey = {
kind: PartitionKind.Hash,
paths: [DEFAULT_PARTITION_KEY_PATH]
};
}

Просмотреть файл

@ -1,8 +1,5 @@
import { PartitionKind } from "./index";
export interface PartitionKeyDefinition {
paths: string[];
kind: keyof typeof PartitionKind;
version?: number;
systemKey?: boolean;
}

Просмотреть файл

@ -1,3 +0,0 @@
export enum PartitionKind {
Hash = "Hash"
}

Просмотреть файл

@ -9,7 +9,6 @@ export * from "./IndexingPolicy";
export * from "./IndexKind";
export * from "./PartitionKey";
export * from "./PartitionKeyDefinition";
export * from "./PartitionKind";
export * from "./PermissionMode";
export * from "./TriggerOperation";
export * from "./TriggerType";

Просмотреть файл

@ -14,7 +14,6 @@ export {
Location,
PartitionKey,
PartitionKeyDefinition,
PartitionKind,
PermissionMode,
TriggerOperation,
TriggerType,

Просмотреть файл

@ -1,5 +1,5 @@
import assert from "assert";
import { CosmosClient, PartitionKind, PermissionMode } from "../../dist-esm";
import { CosmosClient, PermissionMode } from "../../dist-esm";
import { PermissionDefinition } from "../../dist-esm/client";
import { endpoint, masterKey } from "../common/_testConfig";
import { createOrUpsertPermission, getTestContainer, getTestDatabase, removeAllDatabases } from "../common/TestHelpers";
@ -188,7 +188,7 @@ describe("NodeJS CRUD Tests", function() {
const partitionKey = "key";
const containerDefinition = {
id: "coll1",
partitionKey: { paths: ["/" + partitionKey], kind: PartitionKind.Hash }
partitionKey: { paths: ["/" + partitionKey] }
};
const container = await getTestContainer("authorization CRUD multiple partitons", undefined, containerDefinition);
// create user

Просмотреть файл

@ -1,5 +1,5 @@
import assert from "assert";
import { Constants, PartitionKind } from "../../dist-esm";
import { Constants } from "../../dist-esm";
import { ContainerDefinition, Database } from "../../dist-esm/client";
import { ContainerRequest } from "../../dist-esm/client/Container/ContainerRequest";
import { DataType, Index, IndexedPath, IndexingMode, IndexingPolicy, IndexKind } from "../../dist-esm/documents";
@ -24,7 +24,7 @@ describe("Containers", function() {
};
if (partitionKey) {
containerDefinition.partitionKey = { paths: [partitionKey], kind: PartitionKind.Hash };
containerDefinition.partitionKey = { paths: [partitionKey] };
}
const { resource: containerDef } = await database.containers.create(containerDefinition);
@ -32,7 +32,6 @@ describe("Containers", function() {
assert.equal(containerDefinition.id, containerDef.id);
assert.equal("consistent", containerDef.indexingPolicy.indexingMode);
if (containerDef.partitionKey) {
assert.equal(containerDef.partitionKey.kind, containerDefinition.partitionKey.kind);
assert.deepEqual(containerDef.partitionKey.paths, containerDefinition.partitionKey.paths);
}
// read containers after creation
@ -62,7 +61,7 @@ describe("Containers", function() {
// Replacing partition key is not allowed.
try {
containerDef.partitionKey = { paths: ["/key"], kind: PartitionKind.Hash };
containerDef.partitionKey = { paths: ["/key"] };
await container.replace(containerDef);
assert.fail("Replacing paritionkey must throw");
} catch (err) {
@ -113,8 +112,7 @@ describe("Containers", function() {
// create a container
const badPartitionKeyDefinition: any = {
paths: "/id", // This is invalid. Must be an array.
kind: PartitionKind.Hash
paths: "/id" // This is invalid. Must be an array.
};
const containerDefinition: ContainerDefinition = {

Просмотреть файл

@ -1,5 +1,5 @@
import assert from "assert";
import { Container, PartitionKind } from "../../dist-esm";
import { Container } from "../../dist-esm";
import { ItemDefinition } from "../../dist-esm/client";
import {
bulkDeleteItems,
@ -119,7 +119,7 @@ describe("Item CRUD", function() {
// create container
const containerDefinition = {
id: "coll1",
partitionKey: { paths: ["/" + partitionKey], kind: PartitionKind.Hash }
partitionKey: { paths: ["/" + partitionKey] }
};
const { resource: containerdef } = await database.containers.create(containerDefinition, {

Просмотреть файл

@ -1,5 +1,5 @@
import assert from "assert";
import { PartitionKind, PermissionMode } from "../../dist-esm";
import { PermissionMode } from "../../dist-esm";
import { PermissionDefinition } from "../../dist-esm/client";
import {
createOrUpsertPermission,
@ -103,7 +103,7 @@ describe("NodeJS CRUD Tests", function() {
const partitionKey = "id";
const containerDefinition = {
id: "coll1",
partitionKey: { paths: ["/" + partitionKey], kind: PartitionKind.Hash }
partitionKey: { paths: ["/" + partitionKey] }
};
const container = await getTestContainer(
"permission CRUD over multiple partitions",

Просмотреть файл

@ -1,5 +1,5 @@
import assert from "assert";
import { Constants, CosmosClient, PartitionKind } from "../../dist-esm";
import { CosmosClient } from "../../dist-esm";
import { Container } from "../../dist-esm/client";
import { endpoint, masterKey } from "../common/_testConfig";
import { bulkInsertItems, getTestContainer, getTestDatabase, removeAllDatabases } from "../common/TestHelpers";
@ -75,8 +75,7 @@ describe("NodeJS CRUD Tests", function() {
const containerDefinition = {
id: "coll1",
partitionKey: {
paths: ["/" + partitionKey],
kind: PartitionKind.Hash
paths: ["/" + partitionKey]
}
};

Просмотреть файл

@ -1,5 +1,5 @@
import assert from "assert";
import { Constants, PartitionKind } from "../../dist-esm";
import { Constants } from "../../dist-esm";
import { Container, StoredProcedureDefinition } from "../../dist-esm/client";
import { bulkInsertItems, getTestContainer, getTestDatabase, removeAllDatabases } from "../common/TestHelpers";
@ -150,7 +150,7 @@ describe("NodeJS CRUD Tests", function() {
const containerDefinition = {
id: "coll1",
partitionKey: { paths: ["/" + partitionKey], kind: PartitionKind.Hash }
partitionKey: { paths: ["/" + partitionKey] }
};
const { resource: containerResult } = await database.containers.create(containerDefinition, {

Просмотреть файл

@ -1,7 +1,7 @@
import assert from "assert";
import * as util from "util";
import { Container, ContainerDefinition, Database } from "../../dist-esm/client";
import { DataType, IndexKind, PartitionKind } from "../../dist-esm/documents";
import { DataType, IndexKind } from "../../dist-esm/documents";
import { QueryIterator } from "../../dist-esm/index";
import { SqlQuerySpec } from "../../dist-esm/queryExecutionContext";
import { FeedOptions } from "../../dist-esm/request";
@ -37,8 +37,7 @@ describe("NodeJS Aggregate Query Tests", async function() {
]
},
partitionKey: {
paths: ["/" + partitionKey],
kind: PartitionKind.Hash
paths: ["/" + partitionKey]
}
};

Просмотреть файл

@ -1,7 +1,7 @@
import assert from "assert";
import * as util from "util";
import { Container, ContainerDefinition } from "../../dist-esm/client";
import { DataType, IndexKind, PartitionKind } from "../../dist-esm/documents";
import { DataType, IndexKind } from "../../dist-esm/documents";
import { SqlQuerySpec } from "../../dist-esm/queryExecutionContext";
import { QueryIterator } from "../../dist-esm/queryIterator";
import { bulkInsertItems, getTestContainer, removeAllDatabases } from "../common/TestHelpers";
@ -63,8 +63,7 @@ describe("Cross Partition", function() {
]
},
partitionKey: {
paths: ["/id"],
kind: PartitionKind.Hash
paths: ["/id"]
}
};
const containerOptions = { offerThroughput: 25100 };

Просмотреть файл

@ -1,5 +1,4 @@
import assert from "assert";
import { PartitionKind } from "../../dist-esm/documents";
import { extractPartitionKey } from "../../dist-esm/extractPartitionKey";
describe("extractPartitionKey", function() {
@ -12,8 +11,8 @@ describe("extractPartitionKey", function() {
});
describe("With a defined partitionKeyDefinition", function() {
const partitionKeyDefinition = { paths: ["/a/b"], kind: PartitionKind.Hash };
const migratedPartitionKeyDefinition = { paths: ["/_partitionKey"], kind: PartitionKind.Hash, isSystemKey: true };
const partitionKeyDefinition = { paths: ["/a/b"] };
const migratedPartitionKeyDefinition = { paths: ["/_partitionKey"], isSystemKey: true };
it("should return [{}] when document has no partition key value", function() {
const document = {};

Просмотреть файл

@ -18,7 +18,6 @@ describe("Change Feed Iterator", function() {
before(async function() {
const containerDef: ContainerDefinition = {
partitionKey: {
kind: "Hash",
paths: ["/key"]
}
};
@ -87,7 +86,6 @@ describe("Change Feed Iterator", function() {
before(async function() {
const containerDef: ContainerDefinition = {
partitionKey: {
kind: "Hash",
paths: ["/key"]
}
};

Просмотреть файл

@ -1,6 +1,5 @@
import assert from "assert";
import { FeedOptions } from "../../dist-esm";
import { PartitionKind } from "../../dist-esm/documents";
import { getTestContainer, getTestDatabase, removeAllDatabases } from "../common/TestHelpers";
const doc = { id: "myId", pk: "pk" };
@ -17,8 +16,7 @@ describe("ResourceLink Trimming of leading and trailing slashes", function() {
const containerDefinition = {
id: containerId,
partitionKey: {
paths: ["/pk"],
kind: PartitionKind.Hash
paths: ["/pk"]
}
};
const containerOptions = { offerThroughput: 10100 };

Просмотреть файл

@ -2,7 +2,7 @@ import assert from "assert";
import * as sinon from "sinon";
import { ClientContext } from "../../dist-esm/ClientContext";
import { OperationType, ResourceType, trimSlashes } from "../../dist-esm/common";
import { ConsistencyLevel, PartitionKind } from "../../dist-esm/documents";
import { ConsistencyLevel } from "../../dist-esm/documents";
import { Constants, CosmosClient, CosmosHeaders } from "../../dist-esm/index";
import { SessionContainer } from "../../dist-esm/session/sessionContainer";
import { VectorSessionToken } from "../../dist-esm/session/VectorSessionToken";
@ -31,7 +31,7 @@ describe("Session Token", function() {
const containerDefinition = {
id: containerId,
partitionKey: { paths: ["/id"], kind: PartitionKind.Hash }
partitionKey: { paths: ["/id"] }
};
const containerOptions = { offerThroughput: 25100 };