ES module interop fixes; use rollup for production builds (#104)

This commit is contained in:
Brian Terlson 2018-12-14 05:12:55 -08:00 коммит произвёл Steve Faulkner
Родитель dc72172924
Коммит da548f8993
61 изменённых файлов: 843 добавлений и 5087 удалений

3
.gitignore поставляемый
Просмотреть файл

@ -261,6 +261,9 @@ lib/**
*.tgz
dist-esm/
dist-test/
temp/
ts-test/package-lock.json
ts-test/package.json
ts-test/*.js

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

@ -5,4 +5,8 @@ samples
.gitignore
*.code-workspace
*.tgz
ts-test/
ts-test/
dist-test/
dist-esm/test
src/
lib/

24
api-extractor.json Normal file
Просмотреть файл

@ -0,0 +1,24 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/api-extractor.schema.json",
"compiler": {
"configType": "tsconfig",
"rootFolder": "."
},
"project": {
"entryPointSourceFile": "dist-esm/src/index.d.ts"
},
"validationRules": {
"missingReleaseTags": "allow"
},
"dtsRollup": {
"enabled": true,
"publishFolder": "..",
"mainDtsRollupPath": "dist/index.d.ts"
},
"apiReviewFile": {
"enabled": false
},
"apiJsonFile": {
"enabled": false
}
}

14
bundle-types.js Normal file
Просмотреть файл

@ -0,0 +1,14 @@
// TODO. The api-extractor CLI command forces us into their docs generation and will error.
// By invoking the node API we avoid this.
// But we also swallow errors.
// See https://github.com/Microsoft/web-build-tools/issues/920
const ApiExtractor = require("@microsoft/api-extractor");
const NodeCoreLib = require("@microsoft/node-core-library");
const config = NodeCoreLib.JsonFile.loadAndValidate("api-extractor.json", ApiExtractor.Extractor.jsonSchema);
// This interface provides additional runtime state that is NOT part of the config file
const options = {
localBuild: process.argv.indexOf("--ship") < 0
};
const extractor = new ApiExtractor.Extractor(config, options);
extractor.processProject();

5498
package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -13,37 +13,37 @@
],
"version": "3.0.0-0",
"author": "Microsoft Corporation",
"main": "./lib/src/index.js",
"types": "./lib/src/index.d.ts",
"main": "./dist/index.js",
"module": "./dist-esm/src/index.js",
"types": "./dist/index.d.ts",
"engine": {
"node": ">=6.0.0"
},
"scripts": {
"clean": "rimraf lib",
"clean": "rimraf dist && rimraf dist-esm && rimraf dist-test",
"lint": "tslint --project tsconfig.json",
"format": "prettier --write --config .prettierrc.json \"src/**/*.ts\"",
"check-format": "prettier --list-different --config .prettierrc.json \"src/**/*.ts\"",
"compile": "echo Using TypeScript && tsc --version && tsc --pretty",
"compile-prod": "echo Using TypeScript && tsc --version && tsc -p tsconfig.prod.json --pretty",
"docs": "typedoc --excludePrivate --exclude \"**/test/**\" --mode file --out ./lib/docs ./src",
"docs": "typedoc --excludePrivate --exclude \"**/test/**\" --mode file --out ./dist/docs ./src",
"bundle": "rollup -c",
"bundle-types": "node bundle-types.js",
"build": "npm run clean && npm run check-format && npm run lint && npm run compile && npm run docs && npm run bundle && npm run bundle-types",
"test": "mocha -r ./src/test/common/setup.ts ./dist-test/index.js --timeout 100000 -i",
"prepack": "npm install && npm run build",
"webpack": "webpack -d",
"webpack-prod": "webpack -p",
"build": "npm run clean && npm run check-format && npm run lint && npm run compile && npm run docs && npm run webpack",
"build-prod": "npm run clean && npm run check-format && npm run lint && npm run compile-prod && npm run docs && npm run webpack-prod",
"test": "mocha -r ./src/test/common/setup.ts ./lib/src/test/ --recursive --timeout 100000 -i -g .*ignore.js",
"test-ts": "mocha -r ts-node/register -r ./src/test/common/setup.ts ./src/test/**/*.spec.ts --recursive --timeout 100000 -i -g .*ignore.js",
"test-browser": "karma start ./karma.config.js --single-run",
"ci": "npm run build && npm run test && node ts-test.js"
},
"devDependencies": {
"@microsoft/api-extractor": "6.3.0",
"@types/mocha": "^5.2.5",
"@types/node": "^8.10.22",
"@types/node": "^10.5.8",
"@types/priorityqueuejs": "^1.0.1",
"@types/semaphore": "^1.1.0",
"@types/sinon": "^4.3.3",
"@types/tunnel": "^0.0.0",
"@types/underscore": "^1.8.8",
"cross-env": "5.2.0",
"execa": "1.0.0",
"karma": "^3.0.0",
"karma-chrome-launcher": "^2.2.0",
@ -59,14 +59,16 @@
"mocha-multi-reporters": "^1.1.6",
"prettier": "^1.14.0",
"requirejs": "^2.3.5",
"rollup": "^0.64.1",
"rollup-plugin-json": "3.1.0",
"rollup-plugin-local-resolve": "^1.0.7",
"rollup-plugin-multi-entry": "2.0.2",
"sinon": "^5.1.1",
"ts-node": "^6.2.0",
"tslint": "5.11.0",
"tslint-config-prettier": "^1.14.0",
"typedoc": "0.13.0",
"typescript": "3.1.4",
"webpack": "^4.16.3",
"webpack-cli": "^2.1.5"
"typescript": "3.2.2"
},
"dependencies": {
"binary-search-bounds": "2.0.3",
@ -81,5 +83,8 @@
"type": "git",
"url": "https://github.com/Azure/azure-cosmos-js"
},
"license": "MIT"
"license": "MIT",
"tsdoc": {
"tsdocFlavor": "AEDoc"
}
}

27
rollup.config.js Normal file
Просмотреть файл

@ -0,0 +1,27 @@
import resolve from "rollup-plugin-local-resolve";
import json from "rollup-plugin-json";
import multiEntry from "rollup-plugin-multi-entry";
export default [
{
input: "dist-esm/src/test/**/*.spec.js",
output: {
file: "dist-test/index.js",
format: "umd",
name: "Microsoft.Azure.CosmosTest",
sourcemap: true
},
plugins: [resolve(), multiEntry({ exports: false }), json()],
treeshake: false
},
{
input: "dist-esm/src/index.js",
output: {
file: "dist/index.js",
format: "umd",
name: "Microsoft.Azure.Cosmos",
sourcemap: true
},
plugins: [resolve(), json()]
}
];

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

@ -1,9 +1,17 @@
import { Constants, CosmosClientOptions, IHeaders, QueryIterator, RequestOptions, Response, SqlQuerySpec } from ".";
import { PartitionKeyRange } from "./client/Container/PartitionKeyRange";
import { Resource } from "./client/Resource";
import { Helper, StatusCodes, SubStatusCodes } from "./common";
import { ConnectionPolicy, ConsistencyLevel, DatabaseAccount, QueryCompatibilityMode } from "./documents";
import { GlobalEndpointManager } from "./globalEndpointManager";
import {
Constants,
CosmosClientOptions,
IHeaders,
QueryIterator,
RequestOptions,
Response,
SqlQuerySpec
} from "./index";
import { FetchFunctionCallback } from "./queryExecutionContext";
import { FeedOptions, RequestHandler } from "./request";
import { ErrorResponse, getHeaders } from "./request/request";

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

@ -1,15 +1,14 @@
import { Agent, AgentOptions } from "https";
import * as tunnel from "tunnel";
import * as url from "url";
import { Constants, RequestOptions } from ".";
import { Database, Databases } from "./client/Database";
import { Offer, Offers } from "./client/Offer";
import { ClientContext } from "./ClientContext";
import { Helper, Platform } from "./common";
import { Constants, Helper, Platform } from "./common";
import { CosmosClientOptions } from "./CosmosClientOptions";
import { DatabaseAccount } from "./documents";
import { GlobalEndpointManager } from "./globalEndpointManager";
import { CosmosResponse } from "./request";
import { CosmosResponse, RequestOptions } from "./request";
/**
* Provides a client-side logical representation of the Azure Cosmos DB database account.

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

@ -1,7 +1,8 @@
import { PartitionKey } from "../..";
import { ClientContext } from "../../ClientContext";
import { Helper, UriFactory } from "../../common";
import { PartitionKeyDefinition } from "../../documents";
import { PartitionKey } from "../../index";
import { QueryIterator } from "../../queryIterator";
import { CosmosResponse, FeedOptions, RequestOptions } from "../../request";
import { Conflict, Conflicts } from "../Conflict";
import { Database } from "../Database";
@ -11,6 +12,7 @@ import { Trigger, Triggers } from "../Trigger";
import { UserDefinedFunction, UserDefinedFunctions } from "../UserDefinedFunction";
import { ContainerDefinition } from "./ContainerDefinition";
import { ContainerResponse } from "./ContainerResponse";
import { PartitionKeyRange } from "./PartitionKeyRange";
/**
* Operations for reading, replacing, or deleting a specific, existing container by id.
@ -207,7 +209,7 @@ export class Container {
};
}
public readPartitionKeyRanges(feedOptions?: FeedOptions) {
public readPartitionKeyRanges(feedOptions?: FeedOptions): QueryIterator<PartitionKeyRange> {
feedOptions = feedOptions || {};
return this.clientContext.queryPartitionKeyRanges(this.url, undefined, feedOptions);
}

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

@ -1,7 +1,7 @@
import { Container } from ".";
import { CosmosResponse } from "../../request/CosmosResponse";
import { Resource } from "../Resource";
import { ContainerDefinition } from "./ContainerDefinition";
import { Container } from "./index";
/** Response object for Container operations */
export interface ContainerResponse extends CosmosResponse<ContainerDefinition & Resource, Container> {

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

@ -1,6 +1,6 @@
import { Trigger } from ".";
import { CosmosResponse } from "../../request";
import { Resource } from "../Resource";
import { Trigger } from "./index";
import { TriggerDefinition } from "./TriggerDefinition";
export interface TriggerResponse extends CosmosResponse<TriggerDefinition & Resource, Trigger> {

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

@ -1,7 +1,7 @@
import { Constants } from ".";
import { IHeaders } from "..";
import { ConnectionPolicy } from "../documents";
import { IHeaders } from "../index";
import { RequestContext } from "../request/RequestContext";
import { Constants } from "./index";
/** @hidden */
const Regexes = Constants.RegularExpressions;

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

@ -1,5 +1,5 @@
import * as os from "os";
import { Constants } from ".";
import { Constants } from "./index";
/** @hidden */

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

@ -1,4 +1,4 @@
import { Constants, Helper } from ".";
import { Constants, Helper } from "./index";
/** @hidden */
export class UriFactory {

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

@ -1,5 +1,5 @@
import { ConnectionMode, MediaReadMode } from ".";
import { RetryOptions } from "../retry";
import { ConnectionMode, MediaReadMode } from "./index";
/**
* Represents the Connection policy associated with a CosmosClient in the Azure Cosmos DB database service.
*/

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

@ -1,6 +1,6 @@
import { ConsistencyLevel } from ".";
import { Constants } from "../common";
import { IHeaders } from "../queryExecutionContext";
import { ConsistencyLevel } from "./index";
/**
* Represents a DatabaseAccount in the Azure Cosmos DB database service.

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

@ -1,4 +1,4 @@
import { DataType, IndexingMode, IndexKind } from ".";
import { DataType, IndexingMode, IndexKind } from "./index";
export interface IndexingPolicy {
/** The indexing mode (consistent or lazy) {@link IndexingMode}. */

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

@ -1,4 +1,4 @@
import { PartitionKind } from ".";
import { PartitionKind } from "./index";
export interface PartitionKeyDefinition {
paths: string[];

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

@ -1,9 +1,9 @@
import * as url from "url";
import { RequestOptions } from ".";
import * as url from "url";
import { Constants, Helper } from "./common";
import { CosmosClient } from "./CosmosClient";
import { CosmosClientOptions } from "./CosmosClientOptions";
import { DatabaseAccount } from "./documents";
import { RequestOptions } from "./index";
import { LocationCache } from "./LocationCache";
import { CosmosResponse } from "./request";
import { RequestContext } from "./request/RequestContext";

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

@ -1,4 +1,3 @@
import * as DocumentBase from "./documents";
export {
ConnectionMode,
ConsistencyLevel,
@ -22,7 +21,6 @@ export {
UserDefinedFunctionType
} from "./documents";
export { DocumentBase, DocumentBase as AzureDocuments };
export { Constants, UriFactory } from "./common";
export { RetryOptions } from "./retry";
export { Response, RequestOptions, FeedOptions, MediaOptions, ErrorResponse } from "./request";

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

@ -1,7 +1,7 @@
import { IHeaders } from "..";
import { Response } from "../../request/request";
import { AverageAggregator, CountAggregator, MaxAggregator, MinAggregator, SumAggregator } from "../Aggregators";
import { IExecutionContext } from "../IExecutionContext";
import { IHeaders } from "../index";
import { IEndpointComponent } from "./IEndpointComponent";
/** @hidden */

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

@ -1,8 +1,8 @@
import { IExecutionContext } from ".";
import { ClientContext } from "../ClientContext";
import { Constants } from "../common";
import { ClientSideMetrics, QueryMetrics } from "../queryMetrics";
import { Response } from "../request";
import { IExecutionContext } from "./index";
import { SqlQuerySpec } from "./SqlQuerySpec";
/** @hidden */

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

@ -1,4 +1,3 @@
import { FetchFunctionCallback, SqlQuerySpec } from ".";
import { ClientContext } from "../ClientContext";
import { Constants, Helper, StatusCodes, SubStatusCodes } from "../common";
import { FeedOptions } from "../request";
@ -6,6 +5,7 @@ import { Response } from "../request/request";
import { DefaultQueryExecutionContext } from "./defaultQueryExecutionContext";
import { FetchResult, FetchResultType } from "./FetchResult";
import { HeaderUtils, IHeaders } from "./headerUtils";
import { FetchFunctionCallback, SqlQuerySpec } from "./index";
/** @hidden */
const HttpHeaders = Constants;

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

@ -1,11 +1,11 @@
import { ClientContext } from "../ClientContext";
import {
DocumentProducer,
IExecutionContext,
OrderByDocumentProducerComparator,
ParallelQueryExecutionContextBase,
PartitionedQueryExecutionContextInfo
} from ".";
import { ClientContext } from "../ClientContext";
} from "./index";
/** @hidden */
export class OrderByQueryExecutionContext extends ParallelQueryExecutionContextBase implements IExecutionContext {

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

@ -1,11 +1,11 @@
import { ClientContext } from "../ClientContext";
import { PARITIONKEYRANGE } from "../routing";
import {
DocumentProducer,
IExecutionContext,
ParallelQueryExecutionContextBase,
PartitionedQueryExecutionContextInfo
} from ".";
import { ClientContext } from "../ClientContext";
import { PARITIONKEYRANGE } from "../routing";
} from "./index";
/** @hidden */
export class ParallelQueryExecutionContext extends ParallelQueryExecutionContextBase implements IExecutionContext {

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

@ -1,6 +1,10 @@
import * as bs from "binary-search-bounds";
import PriorityQueue from "priorityqueuejs";
import semaphore from "semaphore";
import { ClientContext } from "../ClientContext";
import { StatusCodes, SubStatusCodes } from "../common";
import { Response } from "../request/request";
import { PARITIONKEYRANGE, QueryRange, SmartRoutingMapProvider } from "../routing";
import {
DocumentProducer,
HeaderUtils,
@ -8,11 +12,7 @@ import {
IHeaders,
PartitionedQueryExecutionContextInfo,
PartitionedQueryExecutionContextInfoParser
} from ".";
import { ClientContext } from "../ClientContext";
import { StatusCodes, SubStatusCodes } from "../common";
import { Response } from "../request/request";
import { PARITIONKEYRANGE, QueryRange, SmartRoutingMapProvider } from "../routing";
} from "./index";
/** @hidden */
export enum ParallelQueryExecutionContextBaseStates {

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

@ -1,12 +1,3 @@
import {
HeaderUtils,
IExecutionContext,
IHeaders,
OrderByQueryExecutionContext,
ParallelQueryExecutionContext,
PartitionedQueryExecutionContextInfo,
PartitionedQueryExecutionContextInfoParser
} from ".";
import { ClientContext } from "../ClientContext";
import { Response } from "../request/request";
import {
@ -15,6 +6,15 @@ import {
OrderByEndpointComponent,
TopEndpointComponent
} from "./EndpointComponent";
import {
HeaderUtils,
IExecutionContext,
IHeaders,
OrderByQueryExecutionContext,
ParallelQueryExecutionContext,
PartitionedQueryExecutionContextInfo,
PartitionedQueryExecutionContextInfoParser
} from "./index";
/** @hidden */
export class PipelinedQueryExecutionContext implements IExecutionContext {

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

@ -1,3 +1,6 @@
import { ClientContext } from "../ClientContext";
import { StatusCodes, SubStatusCodes } from "../common";
import { Response } from "../request/request";
import {
DefaultQueryExecutionContext,
FetchFunctionCallback,
@ -5,10 +8,7 @@ import {
PartitionedQueryExecutionContextInfo,
PipelinedQueryExecutionContext,
SqlQuerySpec
} from ".";
import { ClientContext } from "../ClientContext";
import { StatusCodes, SubStatusCodes } from "../common";
import { Response } from "../request/request";
} from "./index";
/** @hidden */
export class ProxyQueryExecutionContext implements IExecutionContext {

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

@ -1,5 +1,5 @@
import { CompareFunction, Range } from ".";
import { Document, PartitionKey } from "../documents";
import { CompareFunction, Range } from "./index";
/** @hidden */
export type PartitionKeyExtractorFunction = (obj: object) => PartitionKey;

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

@ -1,4 +1,4 @@
import { IHeaders } from "..";
import { IHeaders } from "../index";
export interface ErrorResponse {
code?: number;

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

@ -1,4 +1,4 @@
import { IHeaders } from "..";
import { IHeaders } from "../index";
/**
* The feed options and query methods.

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

@ -1,4 +1,4 @@
import { IHeaders } from "..";
import { IHeaders } from "../index";
/**
* Options associated with upload media.

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

@ -1,9 +1,9 @@
import { Agent, OutgoingHttpHeaders } from "http";
import { RequestOptions } from "https"; // TYPES ONLY
import * as querystring from "querystring";
import { Constants, IHeaders } from "..";
import { ConnectionPolicy } from "../documents";
import { GlobalEndpointManager } from "../globalEndpointManager";
import { Constants, IHeaders } from "../index";
import { RetryUtility } from "../retry";
import { bodyFromData, createRequestObject, parse, Response } from "./request";
import { RequestContext } from "./RequestContext";

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

@ -1,5 +1,5 @@
import { IHeaders } from "..";
import { PartitionKey } from "../documents";
import { IHeaders } from "../index";
/**
* Options that can be specified for a requested issued to the Azure Cosmos DB servers.=

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

@ -1,4 +1,4 @@
import { IHeaders } from "..";
import { IHeaders } from "../index";
export interface Response<T> {
headers?: IHeaders;

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

@ -1,5 +1,5 @@
import { ClientRequest, ClientResponse } from "http"; // TYPES ONLY
import * as https from "https"; // TYPES ONLY
import http from "http";
import https from "https";
import { Socket } from "net";
import { Stream } from "stream";
import * as url from "url";
@ -11,8 +11,8 @@ import { IHeaders } from "../queryExecutionContext";
import { ErrorResponse } from "./ErrorResponse";
export { ErrorResponse }; // Should refactor this out
import { FeedOptions, MediaOptions, RequestOptions } from ".";
import { AuthHandler, AuthOptions } from "../auth";
import { FeedOptions, MediaOptions, RequestOptions } from "./index";
import { Response } from "./Response";
export { Response }; // Should refactor this out
@ -64,7 +64,7 @@ export function createRequestObject(
const isMedia = requestOptions.path.indexOf("//media") === 0;
const httpsRequest: ClientRequest = https.request(requestOptions, (response: ClientResponse) => {
const httpsRequest: http.ClientRequest = https.request(requestOptions, (response: http.IncomingMessage) => {
// In case of media response, return the stream to the user and the user will need
// to handle reading the stream.
if (isMedia && connectionPolicy.MediaReadMode === MediaReadMode.Streamed) {
@ -81,7 +81,7 @@ export function createRequestObject(
response.setEncoding("utf8");
}
response.on("data", chunk => {
response.on("data", (chunk: any) => {
data += chunk;
});
response.on("end", () => {
@ -131,7 +131,7 @@ export function createRequestObject(
* @param {object} data - the data body returned from the executon of a request.
* @hidden
*/
function getErrorBody(response: ClientResponse, data: string, headers: IHeaders): ErrorResponse {
function getErrorBody(response: http.IncomingMessage, data: string, headers: IHeaders): ErrorResponse {
const errorBody: ErrorResponse = {
code: response.statusCode,
body: data,

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

@ -1,6 +1,5 @@
import { RequestOptions } from "https";
import { RequestOptions } from "https";
import * as url from "url";
import { EndpointDiscoveryRetryPolicy, ResourceThrottleRetryPolicy, SessionRetryPolicy } from ".";
import { Constants, Helper, StatusCodes, SubStatusCodes } from "../common";
import { ConnectionPolicy } from "../documents";
import { GlobalEndpointManager } from "../globalEndpointManager";
@ -8,6 +7,7 @@ import { Response } from "../request";
import { LocationRouting } from "../request/LocationRouting";
import { RequestContext } from "../request/RequestContext";
import { DefaultRetryPolicy } from "./defaultRetryPolicy";
import { EndpointDiscoveryRetryPolicy, ResourceThrottleRetryPolicy, SessionRetryPolicy } from "./index";
import { IRetryPolicy } from "./IRetryPolicy";
import { RetryContext } from "./RetryContext";

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

@ -1,5 +1,5 @@
import { InMemoryCollectionRoutingMap } from ".";
import { Constants } from "../common";
import { InMemoryCollectionRoutingMap } from "./index";
function compareRanges(a: any, b: any) {
const aVal = a[0][Constants.PartitionKeyRange.MinInclusive];

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

@ -1,7 +1,7 @@
import semaphore from "semaphore";
import { CollectionRoutingMapFactory, InMemoryCollectionRoutingMap, QueryRange } from ".";
import { ClientContext } from "../ClientContext";
import { Helper } from "../common";
import { CollectionRoutingMapFactory, InMemoryCollectionRoutingMap, QueryRange } from "./index";
/** @hidden */
export class PartitionKeyRangeCache {

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

@ -1,6 +1,6 @@
import { PartitionKeyRangeCache, QueryRange } from ".";
import { ClientContext } from "../ClientContext";
import { Constants } from "../common";
import { PartitionKeyRangeCache, QueryRange } from "./index";
/** @hidden */
export const PARITIONKEYRANGE = Constants.PartitionKeyRange;

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

@ -1,5 +1,5 @@
import assert from "assert";
import { CosmosClient, DocumentBase } from "../..";
import { CosmosClient, PartitionKind, PermissionMode } from "../..";
import { PermissionDefinition } from "../../client";
import { endpoint, masterKey } from "../common/_testConfig";
import { createOrUpsertPermission, getTestContainer, getTestDatabase, removeAllDatabases } from "../common/TestHelpers";
@ -53,7 +53,7 @@ describe("NodeJS CRUD Tests", function() {
const { body: user1 } = await database.users.create({ id: "user1" });
let permission = {
id: "permission On Coll1",
permissionMode: DocumentBase.PermissionMode.Read,
permissionMode: PermissionMode.Read,
resource: (container1 as any)._self
}; // TODO: any rid stuff
// create permission for container1
@ -66,7 +66,7 @@ describe("NodeJS CRUD Tests", function() {
assert((permissionOnColl1 as any)._token !== undefined, "permission token is invalid");
permission = {
id: "permission On Doc1",
permissionMode: DocumentBase.PermissionMode.All,
permissionMode: PermissionMode.All,
resource: (document2 as any)._self // TODO: any rid
};
// create permission for document 2
@ -82,7 +82,7 @@ describe("NodeJS CRUD Tests", function() {
const { body: user2 } = await database.users.create({ id: "user2" });
permission = {
id: "permission On coll2",
permissionMode: DocumentBase.PermissionMode.All,
permissionMode: PermissionMode.All,
resource: (container2 as any)._self // TODO: any rid
};
// create permission on container 2
@ -188,7 +188,7 @@ describe("NodeJS CRUD Tests", function() {
const partitionKey = "key";
const containerDefinition = {
id: "coll1",
partitionKey: { paths: ["/" + partitionKey], kind: DocumentBase.PartitionKind.Hash }
partitionKey: { paths: ["/" + partitionKey], kind: PartitionKind.Hash }
};
const container = await getTestContainer("authorization CRUD multiple partitons", undefined, containerDefinition);
// create user
@ -198,7 +198,7 @@ describe("NodeJS CRUD Tests", function() {
const key = 1;
const permissionDefinition: PermissionDefinition = {
id: "permission1",
permissionMode: DocumentBase.PermissionMode.All,
permissionMode: PermissionMode.All,
resource: container.url,
resourcePartitionKey: [key]
};

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

@ -1,6 +1,6 @@
import assert from "assert";
import { Agent } from "http";
import { CosmosClient, DocumentBase } from "../..";
import { ConnectionPolicy, CosmosClient } from "../..";
import { endpoint, masterKey } from "../common/_testConfig";
import { getTestDatabase, removeAllDatabases } from "../common/TestHelpers";
@ -9,7 +9,7 @@ describe("NodeJS CRUD Tests", function() {
describe("Validate client request timeout", function() {
it("nativeApi Client Should throw exception", async function() {
const connectionPolicy = new DocumentBase.ConnectionPolicy();
const connectionPolicy = new ConnectionPolicy();
// making timeout 5 ms to make sure it will throw
// (create database request takes 10ms-15ms to finish on emulator)
connectionPolicy.RequestTimeout = 1;

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

@ -1,5 +1,5 @@
import assert from "assert";
import { Constants, DocumentBase } from "../..";
import { Constants, PartitionKind } from "../..";
import { ContainerDefinition, Database } from "../../client";
import { DataType, Index, IndexedPath, IndexingMode, IndexingPolicy, IndexKind } from "../../documents";
import { getTestDatabase, removeAllDatabases } from "../common/TestHelpers";
@ -23,7 +23,7 @@ describe("NodeJS CRUD Tests", function() {
};
if (hasPartitionKey) {
containerDefinition.partitionKey = { paths: ["/id"], kind: DocumentBase.PartitionKind.Hash };
containerDefinition.partitionKey = { paths: ["/id"], kind: PartitionKind.Hash };
}
const { body: containerDef } = await database.containers.create(containerDefinition);
@ -58,7 +58,7 @@ describe("NodeJS CRUD Tests", function() {
// Replacing partition key is not allowed.
try {
containerDef.partitionKey = { paths: ["/key"], kind: DocumentBase.PartitionKind.Hash };
containerDef.partitionKey = { paths: ["/key"], kind: PartitionKind.Hash };
await container.replace(containerDef);
assert.fail("Replacing paritionkey must throw");
} catch (err) {
@ -106,7 +106,7 @@ describe("NodeJS CRUD Tests", function() {
// create a container
const badPartitionKeyDefinition: any = {
paths: "/id", // This is invalid. Must be an array.
kind: DocumentBase.PartitionKind.Hash
kind: PartitionKind.Hash
};
const containerDefinition: ContainerDefinition = {
@ -170,24 +170,20 @@ describe("NodeJS CRUD Tests", function() {
assert.equal(
containerDef.indexingPolicy.indexingMode,
DocumentBase.IndexingMode.consistent,
IndexingMode.consistent,
"default indexing mode should be consistent"
);
await container.delete();
const lazyContainerDefinition: ContainerDefinition = {
id: "lazy container",
indexingPolicy: { indexingMode: DocumentBase.IndexingMode.lazy }
indexingPolicy: { indexingMode: IndexingMode.lazy }
};
const { body: lazyContainerDef } = await database.containers.create(lazyContainerDefinition);
const lazyContainer = database.container(lazyContainerDef.id);
assert.equal(
lazyContainerDef.indexingPolicy.indexingMode,
DocumentBase.IndexingMode.lazy,
"indexing mode should be lazy"
);
assert.equal(lazyContainerDef.indexingPolicy.indexingMode, IndexingMode.lazy, "indexing mode should be lazy");
await lazyContainer.delete();
@ -199,7 +195,7 @@ describe("NodeJS CRUD Tests", function() {
const consistentContainer = database.container(consistentContainerDef.id);
assert.equal(
containerDef.indexingPolicy.indexingMode,
DocumentBase.IndexingMode.consistent,
IndexingMode.consistent,
"indexing mode should be consistent"
);
await consistentContainer.delete();
@ -208,14 +204,14 @@ describe("NodeJS CRUD Tests", function() {
id: "containerWithIndexingPolicy",
indexingPolicy: {
automatic: true,
indexingMode: DocumentBase.IndexingMode.consistent,
indexingMode: IndexingMode.consistent,
includedPaths: [
{
path: "/",
indexes: [
{
kind: DocumentBase.IndexKind.Hash,
dataType: DocumentBase.DataType.Number,
kind: IndexKind.Hash,
dataType: DataType.Number,
precision: 2
}
]
@ -241,10 +237,7 @@ describe("NodeJS CRUD Tests", function() {
assert.equal("/", containerWithIndexingPolicyDef.indexingPolicy.includedPaths[0].path);
// Backend adds a default index
assert(containerWithIndexingPolicyDef.indexingPolicy.includedPaths[0].indexes.length > 1);
assert.equal(
DocumentBase.IndexKind.Hash,
containerWithIndexingPolicyDef.indexingPolicy.includedPaths[0].indexes[0].kind
);
assert.equal(IndexKind.Hash, containerWithIndexingPolicyDef.indexingPolicy.includedPaths[0].indexes[0].kind);
// The second included path is a timestamp index created by the server.
// And one excluded path.
@ -401,7 +394,7 @@ describe("NodeJS CRUD Tests", function() {
const lazyContainerDefinition = {
id: "lazy_coll",
indexingPolicy: { indexingMode: DocumentBase.IndexingMode.lazy }
indexingPolicy: { indexingMode: IndexingMode.lazy }
};
const { headers: headers2 } = await createThenReadcontainer(database, lazyContainerDefinition);
assert.notEqual(headers2[Constants.HttpHeaders.IndexTransformationProgress], undefined);
@ -409,7 +402,7 @@ describe("NodeJS CRUD Tests", function() {
const noneContainerDefinition = {
id: "none_coll",
indexingPolicy: { indexingMode: DocumentBase.IndexingMode.none, automatic: false }
indexingPolicy: { indexingMode: IndexingMode.none, automatic: false }
};
const { headers: headers3 } = await createThenReadcontainer(database, noneContainerDefinition);
assert.notEqual(headers3[Constants.HttpHeaders.IndexTransformationProgress], undefined);

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

@ -1,5 +1,5 @@
import assert from "assert";
import { Container, DocumentBase } from "../..";
import { Container, PartitionKind } from "../..";
import { ItemDefinition } from "../../client";
import {
bulkDeleteItems,
@ -109,7 +109,7 @@ describe("NodeJS CRUD Tests", function() {
// create container
const containerDefinition = {
id: "coll1",
partitionKey: { paths: ["/" + partitionKey], kind: DocumentBase.PartitionKind.Hash }
partitionKey: { paths: ["/" + partitionKey], kind: PartitionKind.Hash }
};
const { body: containerdef } = await database.containers.create(containerDefinition, { offerThroughput: 12000 });

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

@ -1,5 +1,5 @@
import assert from "assert";
import { DocumentBase } from "../..";
import { PartitionKind, PermissionMode } from "../..";
import { PermissionDefinition } from "../../client";
import {
createOrUpsertPermission,
@ -28,7 +28,7 @@ describe("NodeJS CRUD Tests", function() {
const beforeCreateCount = permissions.length;
const permissionDef: PermissionDefinition = {
id: "new permission",
permissionMode: DocumentBase.PermissionMode.Read,
permissionMode: PermissionMode.Read,
resource: container.url
};
@ -59,18 +59,14 @@ describe("NodeJS CRUD Tests", function() {
const { result: results } = await user.permissions.query(querySpec).toArray();
assert(results.length > 0, "number of results for the query should be > 0");
permissionDef.permissionMode = DocumentBase.PermissionMode.All;
permissionDef.permissionMode = PermissionMode.All;
const { body: replacedPermission } = await replaceOrUpsertPermission(
user,
permissionDef,
undefined,
isUpsertTest
);
assert.equal(
replacedPermission.permissionMode,
DocumentBase.PermissionMode.All,
"permission mode should change"
);
assert.equal(replacedPermission.permissionMode, PermissionMode.All, "permission mode should change");
assert.equal(permissionDef.id, replacedPermission.id, "permission id should stay the same");
// to change the id of an existing resourcewe have to use replace
@ -107,7 +103,7 @@ describe("NodeJS CRUD Tests", function() {
const partitionKey = "id";
const containerDefinition = {
id: "coll1",
partitionKey: { paths: ["/" + partitionKey], kind: DocumentBase.PartitionKind.Hash }
partitionKey: { paths: ["/" + partitionKey], kind: PartitionKind.Hash }
};
const container = await getTestContainer(
"permission CRUD over multiple partitions",
@ -125,7 +121,7 @@ describe("NodeJS CRUD Tests", function() {
const beforeCreateCount = permissions.length;
const permissionDefinition = {
id: "new permission",
permissionMode: DocumentBase.PermissionMode.Read,
permissionMode: PermissionMode.Read,
resource: container.url,
resourcePartitionKey: [1]
};
@ -159,18 +155,14 @@ describe("NodeJS CRUD Tests", function() {
assert(results.length > 0, "number of results for the query should be > 0");
// Replace permission
permissionDef.permissionMode = DocumentBase.PermissionMode.All;
permissionDef.permissionMode = PermissionMode.All;
const { body: replacedPermission } = await replaceOrUpsertPermission(
user,
permissionDef,
undefined,
isUpsertTest
);
assert.equal(
replacedPermission.permissionMode,
DocumentBase.PermissionMode.All,
"permission mode should change"
);
assert.equal(replacedPermission.permissionMode, PermissionMode.All, "permission mode should change");
assert.equal(replacedPermission.id, permissionDef.id, "permission id should stay the same");
assert.equal(
JSON.stringify(replacedPermission.resourcePartitionKey),

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

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

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

@ -1,5 +1,5 @@
import assert from "assert";
import { Database, DocumentBase } from "../..";
import { Database, DataType, IndexKind } from "../..";
import { createOrUpsertItem, getTestDatabase, removeAllDatabases } from "../common/TestHelpers";
describe("NodeJS CRUD Tests", function() {
@ -21,8 +21,8 @@ describe("NodeJS CRUD Tests", function() {
path: '/"Location"/?',
indexes: [
{
kind: DocumentBase.IndexKind.Spatial,
dataType: DocumentBase.DataType.Point
kind: IndexKind.Spatial,
dataType: DataType.Point
}
]
},

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

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

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

@ -1,5 +1,5 @@
import assert from "assert";
import { DocumentBase } from "../..";
import { TriggerOperation, TriggerType } from "../..";
import { Container, TriggerDefinition } from "../../client";
import { getTestContainer, removeAllDatabases } from "../common/TestHelpers";
@ -30,8 +30,8 @@ describe("NodeJS CRUD Tests", function() {
const triggerDefinition: TriggerDefinition = {
id: "sample trigger",
body: "serverScript() { var x = 10; }",
triggerType: DocumentBase.TriggerType.Pre,
triggerOperation: DocumentBase.TriggerOperation.All
triggerType: TriggerType.Pre,
triggerOperation: TriggerOperation.All
};
// tslint:enable:no-var-keyword
// tslint:enable:prefer-const
@ -98,8 +98,8 @@ describe("NodeJS CRUD Tests", function() {
const triggerDefinition: TriggerDefinition = {
id: "sample trigger",
body: "serverScript() { var x = 10; }",
triggerType: DocumentBase.TriggerType.Pre,
triggerOperation: DocumentBase.TriggerOperation.All
triggerType: TriggerType.Pre,
triggerOperation: TriggerOperation.All
};
// tslint:enable:no-var-keyword
// tslint:enable:prefer-const
@ -173,14 +173,14 @@ describe("NodeJS CRUD Tests", function() {
.getRequest()
.setBody(item);
},
triggerType: DocumentBase.TriggerType.Pre,
triggerOperation: DocumentBase.TriggerOperation.All
triggerType: TriggerType.Pre,
triggerOperation: TriggerOperation.All
},
{
id: "t2",
body: "function() { }", // trigger already stringified
triggerType: DocumentBase.TriggerType.Pre,
triggerOperation: DocumentBase.TriggerOperation.All
triggerType: TriggerType.Pre,
triggerOperation: TriggerOperation.All
},
{
id: "t3",
@ -193,8 +193,8 @@ describe("NodeJS CRUD Tests", function() {
.getRequest()
.setBody(item);
},
triggerType: DocumentBase.TriggerType.Pre,
triggerOperation: DocumentBase.TriggerOperation.All
triggerType: TriggerType.Pre,
triggerOperation: TriggerOperation.All
},
{
id: "response1",
@ -208,14 +208,14 @@ describe("NodeJS CRUD Tests", function() {
.getBody();
if (postbody.id !== "TESTING POST TRIGGERt1") throw "name mismatch";
},
triggerType: DocumentBase.TriggerType.Post,
triggerOperation: DocumentBase.TriggerOperation.All
triggerType: TriggerType.Post,
triggerOperation: TriggerOperation.All
},
{
id: "triggerOpType",
body: "function() { }",
triggerType: DocumentBase.TriggerType.Post,
triggerOperation: DocumentBase.TriggerOperation.Delete
triggerType: TriggerType.Post,
triggerOperation: TriggerOperation.Delete
}
];
// tslint:enable:no-var-keyword

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

@ -1,8 +1,8 @@
import assert from "assert";
import * as util from "util";
import { QueryIterator } from "../..";
import { Container, ContainerDefinition, Database } from "../../client";
import { DataType, IndexKind, PartitionKind } from "../../documents";
import { QueryIterator } from "../../index";
import { SqlQuerySpec } from "../../queryExecutionContext";
import { FeedOptions } from "../../request";
import { TestData } from "../common/TestData";

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

@ -1,5 +1,5 @@
import assert from "assert";
import { Container, CosmosClient, DocumentBase } from "../..";
import { Container, CosmosClient, PermissionMode } from "../..";
import { Database } from "../../client";
import { endpoint } from "../common/_testConfig";
import { getTestContainer, removeAllDatabases } from "../common/TestHelpers";
@ -15,11 +15,11 @@ describe("Authorization", function() {
let userAllDefinition: any = { id: "User With All Permission" };
let collReadPermission: any = {
id: "container Read Permission",
permissionMode: DocumentBase.PermissionMode.Read
permissionMode: PermissionMode.Read
};
let collAllPermission: any = {
id: "container All Permission",
permissionMode: DocumentBase.PermissionMode.All
permissionMode: PermissionMode.All
};
/************** TEST **************/

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

@ -1,8 +1,8 @@
import assert from "assert";
import * as util from "util";
import { Constants } from "../..";
import { Container, ContainerDefinition } from "../../client";
import { DataType, IndexKind, PartitionKind } from "../../documents";
import { Constants } from "../../index";
import { SqlQuerySpec } from "../../queryExecutionContext";
import { QueryIterator } from "../../queryIterator";
import { bulkInsertItems, getTestContainer, removeAllDatabases } from "../common/TestHelpers";

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

@ -1,7 +1,7 @@
import * as http from "http";
import * as net from "net";
import * as url from "url";
import { CosmosClient, DocumentBase } from "../..";
import { ConnectionPolicy, CosmosClient } from "../../index";
import { endpoint, masterKey } from "../common/_testConfig";
import { addEntropy } from "../common/TestHelpers";
@ -28,7 +28,7 @@ if (!isBrowser()) {
});
const proxyPort = 8989;
const connectionPolicy = new DocumentBase.ConnectionPolicy();
const connectionPolicy = new ConnectionPolicy();
connectionPolicy.ProxyUrl = "http://127.0.0.1:8989";
it("nativeApi Client Should successfully execute request", async function() {

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

@ -1,5 +1,5 @@
import assert from "assert";
import { AzureDocuments, Constants, CosmosClient, RetryOptions } from "../..";
import { ConnectionPolicy, Constants, CosmosClient, RetryOptions } from "../..";
import * as request from "../../request";
describe("retry policy tests", function() {
@ -14,7 +14,7 @@ describe("retry policy tests", function() {
key: "value"
};
const connectionPolicy = new AzureDocuments.ConnectionPolicy();
const connectionPolicy = new ConnectionPolicy();
// mocked database account to return the WritableLocations and ReadableLocations
// set with the default endpoint

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

@ -1,9 +1,9 @@
import assert from "assert";
import * as sinon from "sinon";
import { Constants, CosmosClient, IHeaders } from "../..";
import { ClientContext } from "../../ClientContext";
import { Helper } from "../../common";
import { ConsistencyLevel, PartitionKind } from "../../documents";
import { Constants, CosmosClient, IHeaders } from "../../index";
import { RequestHandler } from "../../request";
import { SessionContainer } from "../../session/sessionContainer";
import { VectorSessionToken } from "../../session/VectorSessionToken";

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

@ -1,5 +1,5 @@
import assert from "assert";
import { CosmosClient, DocumentBase } from "../..";
import { ConnectionPolicy, CosmosClient } from "../..";
import { getTestDatabase } from "../common/TestHelpers";
const endpoint = "https://localhost:443";
@ -22,7 +22,7 @@ describe.skip("Validate SSL verification check for emulator", function() {
});
it("nativeApi Client Should successfully execute request", async function() {
const connectionPolicy = new DocumentBase.ConnectionPolicy();
const connectionPolicy = new ConnectionPolicy();
// Disable SSL verification explicitly
connectionPolicy.DisableSSLVerification = true;
const client = new CosmosClient({

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

@ -1,14 +1,9 @@
import assert from "assert";
import assert from "assert";
import * as os from "os";
import * as util from "util";
import { Constants } from "../..";
import * as packageJson from "../../../package.json";
import { Platform } from "../../common";
// var assert = require("assert")
// , Contants = require("../lib/constants")
// , os = require("os")
// , Platform = require("../lib/platform")
// , util = require("util");
import { Constants } from "../../index";
describe("Platform.getUserAgent", function() {
it("getUserAgent()", function() {
@ -45,7 +40,6 @@ describe("Platform.getUserAgent", function() {
describe("Version", function() {
it("should have matching constant version & package version", function() {
const packageJson = require("../../../package.json");
const packageVersion = packageJson["version"];
const constantVersion = Constants.SDKVersion;
assert.equal(constantVersion, packageVersion, "Package.json and Constants.SDKVersion don't match");

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

@ -1,13 +1,13 @@
{
"compilerOptions": {
"declaration": true,
"module": "commonjs",
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"noImplicitAny": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"outDir": "./lib",
"outDir": "./dist-esm",
"preserveConstEnums": true,
"removeComments": false,
"target": "es6",

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

@ -1,6 +0,0 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"module": "es6"
}
}

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

@ -1,17 +0,0 @@
var path = require("path");
var webpack = require("webpack");
module.exports = (env, argv) => ({
entry: "./lib/src/index.js",
node: {
buffer: true,
net: "mock",
tls: "mock"
},
output: {
filename: "azurecosmos.js",
path: path.resolve(__dirname, "lib", "dist"),
library: "CosmosClient"
},
devtool: argv.mode === "production" ? "source-map" : "inline-source-map"
});