Skip to content

Commit

Permalink
Add export to sample main functions where missing (#12792)
Browse files Browse the repository at this point in the history
* Added export to typescript main declarations where missing

* Minor commit formatting changes
  • Loading branch information
witemple-msft authored Dec 7, 2020
1 parent 5054334 commit 1cc6607
Show file tree
Hide file tree
Showing 19 changed files with 27 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function read_series_from_file(path: string): Array<TimeSeriesPoint> {
return result;
}

async function main() {
export async function main() {
// create client
const client = new AnomalyDetectorClient(endpoint, new AzureKeyCredential(apiKey));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function read_series_from_file(path: string): Array<TimeSeriesPoint> {
return result;
}

async function main() {
export async function main() {
// create client
const client = new AnomalyDetectorClient(endpoint, new AzureKeyCredential(apiKey));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function read_series_from_file(path: string): Array<TimeSeriesPoint> {
return result;
}

async function main() {
export async function main() {
// create client
const client = new AnomalyDetectorClient(endpoint, new AzureKeyCredential(apiKey));

Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-lro/samples/typescript/samplesClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class Client {

// Now let's see how the client is used.

async function main(): Promise<void> {
export async function main(): Promise<void> {
const client = new Client();
let poller = await client.beginLongOperation();
console.log(poller.getResult()); // Should show: { value: 1 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const endpoint = process.env["EVENT_GRID_ENDPOINT"] || "";
// Navigate to Settings > Access keys in your Event Grid topic's menu blade to see both access keys (you may use either).
const accessKey = process.env["EVENT_GRID_ACCESS_KEY"] || "";

async function main(): Promise<void> {
export async function main(): Promise<void> {
// Create the client used to publish events to the Event Grid Service
const client = new EventGridPublisherClient(endpoint, new AzureKeyCredential(accessKey));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import * as dotenv from "dotenv";
// Load the .env file if it exists
dotenv.config();

// The URL of the endpoint of the Event Grid topic.
// The URL of the endpoint of the Event Grid topic.
const endpoint = process.env["EVENT_GRID_ENDPOINT"] || "";

// You can find the access keys in the Azure portal.
// Navigate to Settings > Access keys in your Event Grid topic's menu blade to see both access keys (you may use either).
const accessKey = process.env["EVENT_GRID_ACCESS_KEY"] || "";

async function main(): Promise<void> {
export async function main(): Promise<void> {
// Create the client used to publish events to the Event Grid Service
const client = new EventGridPublisherClient(endpoint, new AzureKeyCredential(accessKey));

Expand All @@ -26,7 +26,7 @@ async function main(): Promise<void> {
subject: "azure/sdk/eventgrid/samples/sendEventSample",
dataVersion: "1.0",
data: {
message: "this is a sample event",
message: "this is a sample event"
}
}
]);
Expand Down
2 changes: 1 addition & 1 deletion sdk/eventhub/event-processor-host/samples/iothubEph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const storageConnectionString = "";
const storageContainerName = EventProcessorHost.createHostName("iothub-container");
const ephName = "my-iothub-eph";

async function main(): Promise<void> {
export async function main(): Promise<void> {
// Start eph.
const eph = await startEph(ephName);
// Sleeeping for 90 seconds. This will give time for eph to receive messages.
Expand Down
2 changes: 1 addition & 1 deletion sdk/eventhub/event-processor-host/samples/multiEph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const ephName2 = "eph-2";
// Use `createHostName` to create a unique name based on given prefix to use different storage containers on each run if needed.
const storageContainerName = EventProcessorHost.createHostName("test-container");

async function main(): Promise<void> {
export async function main(): Promise<void> {
// Start eph-1.
const eph1 = await startEph(ephName1);
await delay(20000);
Expand Down
2 changes: 1 addition & 1 deletion sdk/eventhub/event-processor-host/samples/sendBatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { EventHubClient, EventData } from "@azure/event-hubs";
const connectionString = "";
const eventHubName = "";

async function main(): Promise<void> {
export async function main(): Promise<void> {
const client = EventHubClient.createFromConnectionString(connectionString, eventHubName);
const partitionIds = await client.getPartitionIds();
const messageCount = 300;
Expand Down
2 changes: 1 addition & 1 deletion sdk/eventhub/event-processor-host/samples/singleEph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const storageConnectionString = "";
const storageContainerName = EventProcessorHost.createHostName("test-container");
const ephName = "my-eph";

async function main(): Promise<void> {
export async function main(): Promise<void> {
// Start eph.
const eph = await startEph(ephName);
// Sleeeping for 90 seconds. This will give time for eph to receive messages.
Expand Down
2 changes: 1 addition & 1 deletion sdk/eventhub/event-processor-host/samples/websockets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const urlParts = url.parse("http://localhost:3128");
urlParts.auth = "username:password"; // Skip this if proxy server does not need authentication.
const proxyAgent = new httpsProxyAgent(urlParts);

async function main(): Promise<void> {
export async function main(): Promise<void> {
const eph = EventProcessorHost.createFromConnectionString(
EventProcessorHost.createHostName(ephName),
storageConnectionString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const storageConnectionString = "";
const containerName = "";
const consumerGroup = "";

async function main() {
export async function main() {
// this client will be used by our eventhubs-checkpointstore-blob, which
// persists any checkpoints from this session in Azure Storage
const containerClient = new ContainerClient(storageConnectionString, containerName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const storageContainerUrl =
const storageAccountName = process.env["STORAGE_ACCOUNT_NAME"] || "<storageaccount>";
const storageAccountKey = process.env["STORAGE_ACCOUNT_KEY"] || "<key>";

async function main() {
export async function main() {
// The `containerClient` will be used by our eventhubs-checkpointstore-blob, which
// persists any checkpoints from this session in Azure Storage.
const storageCredential = new StorageSharedKeyCredential(storageAccountName, storageAccountKey);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import {
TableServiceClient,
TablesSharedKeyCredential,
} from "@azure/data-tables";
import { TableServiceClient, TablesSharedKeyCredential } from "@azure/data-tables";

// Load the .env file if it exists
import * as dotenv from "dotenv";
Expand Down Expand Up @@ -47,9 +44,7 @@ async function tableServiceClientWithSasToken() {
* and it is not available for browsers
*/
async function tableServiceClientWithAccountConnectionString() {
const client = TableServiceClient.fromConnectionString(
accountConnectionString
);
const client = TableServiceClient.fromConnectionString(accountConnectionString);
countTablesWithClient(client);
}

Expand All @@ -74,7 +69,7 @@ async function countTablesWithClient(client: TableServiceClient) {
console.log(`Listed ${count} tables`);
}

async function main() {
export async function main() {
console.log("== Client Authentication Methods Sample ==");

await tableServiceClientWithSasConnectionString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ interface Entity {
quantity: number;
}

async function main() {
export async function main() {
await createAndDeleteEntities();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ async function createAndDeleteTable() {
console.log("== Delete and create table Sample ==");

// See authenticationMethods sample for other options of creating a new client
const serviceClient = TableServiceClient.fromConnectionString(
sasConnectionString
);
const serviceClient = TableServiceClient.fromConnectionString(sasConnectionString);

// Create a new table
const tableName = "SampleCreateAndDeleteTable";
Expand All @@ -32,10 +30,7 @@ async function createAndDeleteTableWithTableClient() {
const tableName = "SampleCreateAndDeleteTable2";

// Creating a new table client doesn't do a network call
const client = TableClient.fromConnectionString(
sasConnectionString,
tableName
);
const client = TableClient.fromConnectionString(sasConnectionString, tableName);

// Will attempt to create a table with the tableName specified above
await client.create();
Expand All @@ -44,7 +39,7 @@ async function createAndDeleteTableWithTableClient() {
await client.delete();
}

async function main() {
export async function main() {
await createAndDeleteTable();
await createAndDeleteTableWithTableClient();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ interface Entity {
quantity: number;
}

async function main() {
export async function main() {
await createAndDeleteEntities();
}

Expand Down
8 changes: 3 additions & 5 deletions sdk/tables/data-tables/samples/typescript/src/queryTables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ async function queryTables() {
console.log("== Query tables Sample ==");

// See authenticationMethods sample for other options of creating a new client
const serviceClient = TableServiceClient.fromConnectionString(
accountConnectionString
);
const serviceClient = TableServiceClient.fromConnectionString(accountConnectionString);

// Create a new table
const tableName = "OfficeSupplies3p1";
Expand All @@ -25,7 +23,7 @@ async function queryTables() {
// odata is a helper function that takes care of encoding the query
// filter, in this sample it will add quotes around tableName
const queryTableResults = serviceClient.listTables({
queryOptions: { filter: odata`TableName eq ${tableName}` },
queryOptions: { filter: odata`TableName eq ${tableName}` }
});

// Iterate the results
Expand All @@ -37,7 +35,7 @@ async function queryTables() {
await serviceClient.deleteTable(tableName);
}

async function main() {
export async function main() {
await queryTables();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ interface Entity {
brand?: string;
}

async function main() {
export async function main() {
await createAndDeleteEntities();
}

Expand Down

0 comments on commit 1cc6607

Please sign in to comment.