Added a couple JS Code Gen tests as well as a negative test. Some changes to output for test required change update to the cmp files.

This commit is contained in:
Darren Gehring 2020-12-22 17:31:19 -08:00
Родитель 87b08ee1f8
Коммит 4ff909cfcc
29 изменённых файлов: 625 добавлений и 29 удалений

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

@ -1,6 +1,7 @@
// Generated consumer-side API for the 'server' Ambrosia Node instance.
// Publisher: Darren Gehring [darrenge@microsoft.com].
// Note: This file was generated
// Note: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
// Note [to publisher]: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
import Ambrosia = require("ambrosia-node");
import IC = Ambrosia.IC;

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

@ -1,6 +1,6 @@
// Generated publisher-side framework for the 'server' Ambrosia Node instance.
// Note: This file was generated
// Note: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
// Note [to publisher]: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
import * as PTM from "./JS_CodeGen_TestFiles/ASTTest"; // PTM = "Published Types and Methods", but this file can also include app-state and app-event handlers
import Ambrosia = require("ambrosia-node");
import Utils = Ambrosia.Utils;

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

@ -1,6 +1,7 @@
// Generated consumer-side API for the 'server' Ambrosia Node instance.
// Publisher: Darren Gehring [darrenge@microsoft.com].
// Note: This file was generated
// Note: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
// Note [to publisher]: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
import Ambrosia = require("ambrosia-node");
import IC = Ambrosia.IC;
@ -68,7 +69,6 @@ export namespace Test
/**
* Some new test.
* @param person Datails of a person.
*/
export async function NewTestAsync(person: { age: number }): Promise<{ age: number }>
{
@ -78,7 +78,6 @@ export namespace Test
/**
* Some new test.
* @param person Datails of a person.
*/
export function NewTest(resultHandler: IC.PostResultHandler<{ age: number }>, person: { age: number }): void
{

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

@ -1,6 +1,6 @@
// Generated publisher-side framework for the 'server' Ambrosia Node instance.
// Note: This file was generated
// Note: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
// Note [to publisher]: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
import * as PTM from "./JS_CodeGen_TestFiles/PI"; // PTM = "Published Types and Methods", but this file can also include app-state and app-event handlers
import Ambrosia = require("ambrosia-node");
import Utils = Ambrosia.Utils;

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

@ -1,6 +1,7 @@
// Generated consumer-side API for the 'server' Ambrosia Node instance.
// Publisher: Darren Gehring [darrenge@microsoft.com].
// Note: This file was generated
// Note: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
// Note [to publisher]: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
import Ambrosia = require("ambrosia-node");
import IC = Ambrosia.IC;

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

@ -1,6 +1,6 @@
// Generated publisher-side framework for the 'server' Ambrosia Node instance.
// Note: This file was generated
// Note: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
// Note [to publisher]: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
import * as PTM from "./JS_CodeGen_TestFiles/TS_AmbrosiaTag"; // PTM = "Published Types and Methods", but this file can also include app-state and app-event handlers
import Ambrosia = require("ambrosia-node");
import Utils = Ambrosia.Utils;

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

@ -0,0 +1,48 @@
// Generated consumer-side API for the 'server' Ambrosia Node instance.
// Publisher: Darren Gehring [darrenge@microsoft.com].
// Note: This file was generated
// Note [to publisher]: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
import Ambrosia = require("ambrosia-node");
import IC = Ambrosia.IC;
let DESTINATION_INSTANCE_NAME: string = "server";
let POST_TIMEOUT_IN_MS: number = 8000; // -1 = Infinite
export namespace Test
{
/**
* Method to test custom serialized parameters.
* @param rawParams A custom serialization (byte array) of all required parameters. Contact the 'server' instance publisher (Darren Gehring [darrenge@microsoft.com]) for details of the serialization format.
*/
export function takesCustomSerializedParams_Fork(rawParams: Uint8Array): void
{
IC.callFork(DESTINATION_INSTANCE_NAME, 2, rawParams);
}
/**
* Method to test custom serialized parameters.
* @param rawParams A custom serialization (byte array) of all required parameters. Contact the 'server' instance publisher (Darren Gehring [darrenge@microsoft.com]) for details of the serialization format.
*/
export function takesCustomSerializedParams_Impulse(rawParams: Uint8Array): void
{
IC.callImpulse(DESTINATION_INSTANCE_NAME, 2, rawParams);
}
/**
* Method to test custom serialized parameters.
* @param rawParams A custom serialization (byte array) of all required parameters. Contact the 'server' instance publisher (Darren Gehring [darrenge@microsoft.com]) for details of the serialization format.
*/
export function takesCustomSerializedParams_EnqueueFork(rawParams: Uint8Array): void
{
IC.queueFork(DESTINATION_INSTANCE_NAME, 2, rawParams);
}
/**
* Method to test custom serialized parameters.
* @param rawParams A custom serialization (byte array) of all required parameters. Contact the 'server' instance publisher (Darren Gehring [darrenge@microsoft.com]) for details of the serialization format.
*/
export function takesCustomSerializedParams_EnqueueImpulse(rawParams: Uint8Array): void
{
IC.queueImpulse(DESTINATION_INSTANCE_NAME, 2, rawParams);
}
}

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

@ -0,0 +1,194 @@
// Generated publisher-side framework for the 'server' Ambrosia Node instance.
// Note: This file was generated
// Note [to publisher]: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
import * as PTM from "./JS_CodeGen_TestFiles/TS_CustomSerialParamNoRawParam"; // PTM = "Published Types and Methods", but this file can also include app-state and app-event handlers
import Ambrosia = require("ambrosia-node");
import Utils = Ambrosia.Utils;
import IC = Ambrosia.IC;
import Messages = Ambrosia.Messages;
import Meta = Ambrosia.Meta;
import Streams = Ambrosia.Streams;
// TODO: It's recommended that you move this class and _appState variable to your input file (./JS_CodeGen_TestFiles/TS_CustomSerialParamNoRawParam.ts) in an exported namespace/module
class AppState extends Ambrosia.AmbrosiaAppState
{
// TODO: Define your application state here
constructor()
{
super();
// TODO: Initialize your application state here
}
}
export let _appState: AppState = new AppState();
/** Returns an OutgoingCheckpoint object used to serialize app state to a checkpoint. */
export function checkpointProducer(): Streams.OutgoingCheckpoint
{
function onCheckpointSent(error?: Error): void
{
Utils.log(`checkpointProducer: ${error ? `Failed (reason: ${error.message})` : "Checkpoint saved"}`)
}
return (Streams.simpleCheckpointProducer(Utils.jsonStringify(_appState), onCheckpointSent));
}
/** Returns an IncomingCheckpoint object used to receive a checkpoint of app state. */
export function checkpointConsumer(): Streams.IncomingCheckpoint
{
function onCheckpointReceived(jsonAppState: string, error?: Error): void
{
if (!error)
{
_appState = Utils.jsonParse(jsonAppState);
}
Utils.log(`checkpointConsumer: ${error ? `Failed (reason: ${error.message})` : "Checkpoint loaded"}`);
}
return (Streams.simpleCheckpointConsumer(onCheckpointReceived));
}
/** This method responds to incoming Ambrosia messages (mainly RPCs, but also the InitialMessage and AppEvents). */
export function messageDispatcher(message: Messages.DispatchedMessage): void
{
// Fast (non-async) handler for high-volume messages
if (!dispatcher(message))
{
// Slower async handler, but simpler/cleaner to code because we can use 'await'
// Note: messageDispatcher() is NOT awaited by the calling code, so we don't await dispatcherAsync(). Consequently, any await's in
// dispatcherAsync() will start independent Promise chains, and these chains are explicitly responsible for managing any
// order-of-execution synchronization issues (eg. if the handling of message n is dependent on the handling of message n - 1).
dispatcherAsync(message);
}
}
/** Synchronous message dispatcher. */
function dispatcher(message: Messages.DispatchedMessage): boolean
{
let handled: boolean = false;
try
{
if (message.type === Messages.DispatchedMessageType.RPC)
{
let rpc: Messages.IncomingRPC = message as Messages.IncomingRPC;
switch (rpc.methodID)
{
// TODO: Add case-statements for your high-volume methods here
}
}
}
catch (error)
{
let messageName: string = (message.type === Messages.DispatchedMessageType.AppEvent) ? `AppEvent:${Messages.AppEventType[(message as Messages.AppEvent).eventType]}` : Messages.DispatchedMessage[message.type];
Utils.log(`Error: Failed to process ${messageName} message`);
Utils.log(error);
}
return (handled);
}
/** Asynchronous message dispatcher. */
async function dispatcherAsync(message: Messages.DispatchedMessage)
{
const loggingPrefix: string = "Dispatcher";
try
{
switch (message.type)
{
case Messages.DispatchedMessageType.RPC:
let rpc: Messages.IncomingRPC = message as Messages.IncomingRPC;
switch (rpc.methodID)
{
case IC.POST_METHOD_ID:
try
{
let methodName: string = IC.getPostMethodName(rpc);
let methodVersion: number = IC.getPostMethodVersion(rpc); // Use this to do version-specific method behavior
switch (methodName)
{
// Code-gen: Post method handlers will go here
default:
let errorMsg: string = `Post method '${methodName}' is not implemented`;
Utils.log(`(${errorMsg})`, loggingPrefix)
IC.postError(rpc, new Error(errorMsg));
break;
}
}
catch (error)
{
Utils.log(error);
IC.postError(rpc, error);
}
break;
case 2:
let rawParams: Uint8Array = rpc.rawParams;
PTM.Test.takesCustomSerializedParams(rawParams);
break;
default:
Utils.log(`(No method is associated with methodID ${rpc.methodID})`, loggingPrefix)
break;
}
break;
case Messages.DispatchedMessageType.AppEvent:
let appEvent: Messages.AppEvent = message as Messages.AppEvent;
switch (appEvent.eventType)
{
case Messages.AppEventType.ICStarting:
// Code-gen: Published types will go here
Meta.publishMethod(2, "takesCustomSerializedParams", ["rawParams: Uint8Array"]);
// TODO: Add an exported function 'onICStarting(): void' to ./JS_CodeGen_TestFiles/TS_CustomSerialParamNoRawParam.ts, then (after the next code-gen) a call to it will be generated here
break;
case Messages.AppEventType.ICStarted:
// TODO: Add an exported function 'onICStarted(): void' to ./JS_CodeGen_TestFiles/TS_CustomSerialParamNoRawParam.ts, then (after the next code-gen) a call to it will be generated here
break;
case Messages.AppEventType.ICStopped:
// TODO: Add an exported function 'onICStopped(exitCode: number): void' to ./JS_CodeGen_TestFiles/TS_CustomSerialParamNoRawParam.ts, then (after the next code-gen) a call to it will be generated here
break;
case Messages.AppEventType.ICReadyForSelfCallRpc:
// TODO: Add an exported function 'onICReadyForSelfCallRpc(): void' to ./JS_CodeGen_TestFiles/TS_CustomSerialParamNoRawParam.ts, then (after the next code-gen) a call to it will be generated here
break;
case Messages.AppEventType.RecoveryComplete:
// TODO: Add an exported function 'onRecoveryComplete(): void' to ./JS_CodeGen_TestFiles/TS_CustomSerialParamNoRawParam.ts, then (after the next code-gen) a call to it will be generated here
break;
case Messages.AppEventType.UpgradeStateAndCode:
// TODO: Add an exported [non-async] function 'onUpgradeStateAndCode(upgradeMode: Messages.AppUpgradeMode): void' to ./JS_CodeGen_TestFiles/TS_CustomSerialParamNoRawParam.ts, then (after the next code-gen) a call to it will be generated here
// Note: You will need to import Ambrosia to ../../AmbrosiaTest/JSCodeGen/JS_CodeGen_TestFiles/TS_CustomSerialParamNoRawParam.ts in order to reference the 'Messages' namespace.
// Also, your handler should call IC.upgrade() [to upgrade code] and _appState.upgrade() [to upgrade state].
break;
case Messages.AppEventType.IncomingCheckpointStreamSize:
// TODO: Add an exported function 'onIncomingCheckpointStreamSize(): void' to ./JS_CodeGen_TestFiles/TS_CustomSerialParamNoRawParam.ts, then (after the next code-gen) a call to it will be generated here
break;
case Messages.AppEventType.FirstStart:
// TODO: Add an exported function 'onFirstStart(): void' to ./JS_CodeGen_TestFiles/TS_CustomSerialParamNoRawParam.ts, then (after the next code-gen) a call to it will be generated here
break;
case Messages.AppEventType.BecomingPrimary:
// TODO: Add an exported function 'onBecomingPrimary(): void' to ./JS_CodeGen_TestFiles/TS_CustomSerialParamNoRawParam.ts, then (after the next code-gen) a call to it will be generated here
break;
}
break;
}
}
catch (error)
{
let messageName: string = (message.type === Messages.DispatchedMessageType.AppEvent) ? `AppEvent:${Messages.AppEventType[(message as Messages.AppEvent).eventType]}` : Messages.DispatchedMessage[message.type];
Utils.log(`Error: Failed to process ${messageName} message`);
Utils.log(error);
}
}

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

@ -0,0 +1,48 @@
// Generated consumer-side API for the 'server' Ambrosia Node instance.
// Publisher: Darren Gehring [darrenge@microsoft.com].
// Note: This file was generated
// Note [to publisher]: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
import Ambrosia = require("ambrosia-node");
import IC = Ambrosia.IC;
let DESTINATION_INSTANCE_NAME: string = "server";
let POST_TIMEOUT_IN_MS: number = 8000; // -1 = Infinite
export namespace Test
{
/**
* Method to test custom serialized parameters.
* @param rawParams Description of the format of the custom serialized byte array.
*/
export function takesCustomSerializedParams_Fork(rawParams: Uint8Array): void
{
IC.callFork(DESTINATION_INSTANCE_NAME, 2, rawParams);
}
/**
* Method to test custom serialized parameters.
* @param rawParams Description of the format of the custom serialized byte array.
*/
export function takesCustomSerializedParams_Impulse(rawParams: Uint8Array): void
{
IC.callImpulse(DESTINATION_INSTANCE_NAME, 2, rawParams);
}
/**
* Method to test custom serialized parameters.
* @param rawParams Description of the format of the custom serialized byte array.
*/
export function takesCustomSerializedParams_EnqueueFork(rawParams: Uint8Array): void
{
IC.queueFork(DESTINATION_INSTANCE_NAME, 2, rawParams);
}
/**
* Method to test custom serialized parameters.
* @param rawParams Description of the format of the custom serialized byte array.
*/
export function takesCustomSerializedParams_EnqueueImpulse(rawParams: Uint8Array): void
{
IC.queueImpulse(DESTINATION_INSTANCE_NAME, 2, rawParams);
}
}

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

@ -0,0 +1,194 @@
// Generated publisher-side framework for the 'server' Ambrosia Node instance.
// Note: This file was generated
// Note [to publisher]: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
import * as PTM from "./JS_CodeGen_TestFiles/TS_CustomSerialParam"; // PTM = "Published Types and Methods", but this file can also include app-state and app-event handlers
import Ambrosia = require("ambrosia-node");
import Utils = Ambrosia.Utils;
import IC = Ambrosia.IC;
import Messages = Ambrosia.Messages;
import Meta = Ambrosia.Meta;
import Streams = Ambrosia.Streams;
// TODO: It's recommended that you move this class and _appState variable to your input file (./JS_CodeGen_TestFiles/TS_CustomSerialParam.ts) in an exported namespace/module
class AppState extends Ambrosia.AmbrosiaAppState
{
// TODO: Define your application state here
constructor()
{
super();
// TODO: Initialize your application state here
}
}
export let _appState: AppState = new AppState();
/** Returns an OutgoingCheckpoint object used to serialize app state to a checkpoint. */
export function checkpointProducer(): Streams.OutgoingCheckpoint
{
function onCheckpointSent(error?: Error): void
{
Utils.log(`checkpointProducer: ${error ? `Failed (reason: ${error.message})` : "Checkpoint saved"}`)
}
return (Streams.simpleCheckpointProducer(Utils.jsonStringify(_appState), onCheckpointSent));
}
/** Returns an IncomingCheckpoint object used to receive a checkpoint of app state. */
export function checkpointConsumer(): Streams.IncomingCheckpoint
{
function onCheckpointReceived(jsonAppState: string, error?: Error): void
{
if (!error)
{
_appState = Utils.jsonParse(jsonAppState);
}
Utils.log(`checkpointConsumer: ${error ? `Failed (reason: ${error.message})` : "Checkpoint loaded"}`);
}
return (Streams.simpleCheckpointConsumer(onCheckpointReceived));
}
/** This method responds to incoming Ambrosia messages (mainly RPCs, but also the InitialMessage and AppEvents). */
export function messageDispatcher(message: Messages.DispatchedMessage): void
{
// Fast (non-async) handler for high-volume messages
if (!dispatcher(message))
{
// Slower async handler, but simpler/cleaner to code because we can use 'await'
// Note: messageDispatcher() is NOT awaited by the calling code, so we don't await dispatcherAsync(). Consequently, any await's in
// dispatcherAsync() will start independent Promise chains, and these chains are explicitly responsible for managing any
// order-of-execution synchronization issues (eg. if the handling of message n is dependent on the handling of message n - 1).
dispatcherAsync(message);
}
}
/** Synchronous message dispatcher. */
function dispatcher(message: Messages.DispatchedMessage): boolean
{
let handled: boolean = false;
try
{
if (message.type === Messages.DispatchedMessageType.RPC)
{
let rpc: Messages.IncomingRPC = message as Messages.IncomingRPC;
switch (rpc.methodID)
{
// TODO: Add case-statements for your high-volume methods here
}
}
}
catch (error)
{
let messageName: string = (message.type === Messages.DispatchedMessageType.AppEvent) ? `AppEvent:${Messages.AppEventType[(message as Messages.AppEvent).eventType]}` : Messages.DispatchedMessage[message.type];
Utils.log(`Error: Failed to process ${messageName} message`);
Utils.log(error);
}
return (handled);
}
/** Asynchronous message dispatcher. */
async function dispatcherAsync(message: Messages.DispatchedMessage)
{
const loggingPrefix: string = "Dispatcher";
try
{
switch (message.type)
{
case Messages.DispatchedMessageType.RPC:
let rpc: Messages.IncomingRPC = message as Messages.IncomingRPC;
switch (rpc.methodID)
{
case IC.POST_METHOD_ID:
try
{
let methodName: string = IC.getPostMethodName(rpc);
let methodVersion: number = IC.getPostMethodVersion(rpc); // Use this to do version-specific method behavior
switch (methodName)
{
// Code-gen: Post method handlers will go here
default:
let errorMsg: string = `Post method '${methodName}' is not implemented`;
Utils.log(`(${errorMsg})`, loggingPrefix)
IC.postError(rpc, new Error(errorMsg));
break;
}
}
catch (error)
{
Utils.log(error);
IC.postError(rpc, error);
}
break;
case 2:
let rawParams: Uint8Array = rpc.rawParams;
PTM.Test.takesCustomSerializedParams(rawParams);
break;
default:
Utils.log(`(No method is associated with methodID ${rpc.methodID})`, loggingPrefix)
break;
}
break;
case Messages.DispatchedMessageType.AppEvent:
let appEvent: Messages.AppEvent = message as Messages.AppEvent;
switch (appEvent.eventType)
{
case Messages.AppEventType.ICStarting:
// Code-gen: Published types will go here
Meta.publishMethod(2, "takesCustomSerializedParams", ["rawParams: Uint8Array"]);
// TODO: Add an exported function 'onICStarting(): void' to ./JS_CodeGen_TestFiles/TS_CustomSerialParam.ts, then (after the next code-gen) a call to it will be generated here
break;
case Messages.AppEventType.ICStarted:
// TODO: Add an exported function 'onICStarted(): void' to ./JS_CodeGen_TestFiles/TS_CustomSerialParam.ts, then (after the next code-gen) a call to it will be generated here
break;
case Messages.AppEventType.ICStopped:
// TODO: Add an exported function 'onICStopped(exitCode: number): void' to ./JS_CodeGen_TestFiles/TS_CustomSerialParam.ts, then (after the next code-gen) a call to it will be generated here
break;
case Messages.AppEventType.ICReadyForSelfCallRpc:
// TODO: Add an exported function 'onICReadyForSelfCallRpc(): void' to ./JS_CodeGen_TestFiles/TS_CustomSerialParam.ts, then (after the next code-gen) a call to it will be generated here
break;
case Messages.AppEventType.RecoveryComplete:
// TODO: Add an exported function 'onRecoveryComplete(): void' to ./JS_CodeGen_TestFiles/TS_CustomSerialParam.ts, then (after the next code-gen) a call to it will be generated here
break;
case Messages.AppEventType.UpgradeStateAndCode:
// TODO: Add an exported [non-async] function 'onUpgradeStateAndCode(upgradeMode: Messages.AppUpgradeMode): void' to ./JS_CodeGen_TestFiles/TS_CustomSerialParam.ts, then (after the next code-gen) a call to it will be generated here
// Note: You will need to import Ambrosia to ../../AmbrosiaTest/JSCodeGen/JS_CodeGen_TestFiles/TS_CustomSerialParam.ts in order to reference the 'Messages' namespace.
// Also, your handler should call IC.upgrade() [to upgrade code] and _appState.upgrade() [to upgrade state].
break;
case Messages.AppEventType.IncomingCheckpointStreamSize:
// TODO: Add an exported function 'onIncomingCheckpointStreamSize(): void' to ./JS_CodeGen_TestFiles/TS_CustomSerialParam.ts, then (after the next code-gen) a call to it will be generated here
break;
case Messages.AppEventType.FirstStart:
// TODO: Add an exported function 'onFirstStart(): void' to ./JS_CodeGen_TestFiles/TS_CustomSerialParam.ts, then (after the next code-gen) a call to it will be generated here
break;
case Messages.AppEventType.BecomingPrimary:
// TODO: Add an exported function 'onBecomingPrimary(): void' to ./JS_CodeGen_TestFiles/TS_CustomSerialParam.ts, then (after the next code-gen) a call to it will be generated here
break;
}
break;
}
}
catch (error)
{
let messageName: string = (message.type === Messages.DispatchedMessageType.AppEvent) ? `AppEvent:${Messages.AppEventType[(message as Messages.AppEvent).eventType]}` : Messages.DispatchedMessage[message.type];
Utils.log(`Error: Failed to process ${messageName} message`);
Utils.log(error);
}
}

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

@ -1,6 +1,7 @@
// Generated consumer-side API for the 'server' Ambrosia Node instance.
// Publisher: Darren Gehring [darrenge@microsoft.com].
// Note: This file was generated
// Note: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
// Note [to publisher]: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
import Ambrosia = require("ambrosia-node");
import IC = Ambrosia.IC;

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

@ -1,6 +1,6 @@
// Generated publisher-side framework for the 'server' Ambrosia Node instance.
// Note: This file was generated
// Note: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
// Note [to publisher]: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
import * as PTM from "./JS_CodeGen_TestFiles/TS_EventHandlerWarnings"; // PTM = "Published Types and Methods", but this file can also include app-state and app-event handlers
import Ambrosia = require("ambrosia-node");
import Utils = Ambrosia.Utils;

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

@ -1,6 +1,7 @@
// Generated consumer-side API for the 'server' Ambrosia Node instance.
// Publisher: Darren Gehring [darrenge@microsoft.com].
// Note: This file was generated
// Note: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
// Note [to publisher]: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
import Ambrosia = require("ambrosia-node");
import IC = Ambrosia.IC;

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

@ -1,6 +1,6 @@
// Generated publisher-side framework for the 'server' Ambrosia Node instance.
// Note: This file was generated
// Note: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
// Note [to publisher]: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
import * as PTM from "./JS_CodeGen_TestFiles/TS_EventHandlers"; // PTM = "Published Types and Methods", but this file can also include app-state and app-event handlers
import Ambrosia = require("ambrosia-node");
import Utils = Ambrosia.Utils;

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

@ -1,6 +1,7 @@
// Generated consumer-side API for the 'server' Ambrosia Node instance.
// Publisher: Darren Gehring [darrenge@microsoft.com].
// Note: This file was generated
// Note: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
// Note [to publisher]: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
import Ambrosia = require("ambrosia-node");
import IC = Ambrosia.IC;

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

@ -1,6 +1,6 @@
// Generated publisher-side framework for the 'server' Ambrosia Node instance.
// Note: This file was generated
// Note: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
// Note [to publisher]: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
import * as PTM from "./JS_CodeGen_TestFiles/TS_MiscTests"; // PTM = "Published Types and Methods", but this file can also include app-state and app-event handlers
import Ambrosia = require("ambrosia-node");
import Utils = Ambrosia.Utils;

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

@ -1,6 +1,7 @@
// Generated consumer-side API for the 'server' Ambrosia Node instance.
// Publisher: Darren Gehring [darrenge@microsoft.com].
// Note: This file was generated
// Note: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
// Note [to publisher]: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
import Ambrosia = require("ambrosia-node");
import IC = Ambrosia.IC;

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

@ -1,6 +1,6 @@
// Generated publisher-side framework for the 'server' Ambrosia Node instance.
// Note: This file was generated
// Note: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
// Note [to publisher]: You can edit this file, but to avoid losing your changes be sure to specify a 'mergeType' other than 'None' (the default is 'Annotate') when re-running emitTypeScriptFile[FromSource]().
import * as PTM from "./JS_CodeGen_TestFiles/TS_Types"; // PTM = "Published Types and Methods", but this file can also include app-state and app-event handlers
import Ambrosia = require("ambrosia-node");
import Utils = Ambrosia.Utils;

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

@ -20,7 +20,8 @@ namespace AmbrosiaTest
{
// Build the JS app first from a JS file
JS_Utilities JSUtils = new JS_Utilities();
//*#*#*# COMMENT OUT FOR NOW - EASIER WITH TEST WRITING ETCJSUtils.BuildJSTestApp();
//*#*#*# COMMENT OUT FOR NOW - EASIER WITH TEST WRITING ETC JSUtils.BuildJSTestApp();
//JSUtils.BuildJSTestApp();
}
[TestInitialize()]
@ -386,6 +387,18 @@ namespace AmbrosiaTest
JSUtils.Test_CodeGen_TSFile(testfileName, true, ConsumerErrorMsg, PublisherErrorMsg);
}
[TestMethod]
public void JS_CG_Neg_SingleUInt8Array()
{
JS_Utilities JSUtils = new JS_Utilities();
string testfileName = "TS_SingleUInt8Array.ts";
string ConsumerErrorMsg = "Unable to publish function 'takesCustomSerializedParams'";
string PublisherErrorMsg = "Uint8Array parameter; Post methods do NOT support custom (raw byte) parameter serialization - all parameters are always serialized to JSON)";
// Generate the consumer and publisher files and verify output and the generated files to cmp files
JSUtils.Test_CodeGen_TSFile(testfileName, true, ConsumerErrorMsg, PublisherErrorMsg);
}
}

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

@ -87,6 +87,27 @@ namespace AmbrosiaTest
JSUtils.Test_CodeGen_TSFile(testfileName);
}
[TestMethod]
public void JS_CG_CustomSerialParam_Test()
{
JS_Utilities JSUtils = new JS_Utilities();
string testfileName = "TS_CustomSerialParam.ts";
// Generate the consumer and publisher files and verify output and the generated files to cmp files
JSUtils.Test_CodeGen_TSFile(testfileName);
}
[TestMethod]
public void JS_CG_CustomSerialParamNoRaw_Test()
{
JS_Utilities JSUtils = new JS_Utilities();
string testfileName = "TS_CustomSerialParamNoRawParam.ts";
// Generate the consumer and publisher files and verify output and the generated files to cmp files
JSUtils.Test_CodeGen_TSFile(testfileName);
}
[TestMethod]
@ -104,6 +125,8 @@ namespace AmbrosiaTest
JSUtils.Test_CodeGen_TSFile(testfileName, false, ConsumerWarning, PublisherWarning);
}
//**** Misc valid tests that are just a "catch all" if don't know where to put teest
[TestMethod]
public void JS_CG_Misc_Test()

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

@ -18,7 +18,7 @@ namespace AmbrosiaTest
public string PublisherCodeGenSuccessMessage = "Publisher code file generation SUCCEEDED: 1 of 1 files generated; 0 TypeScript errors, 0 merge conflicts";
public string ConsumerCodeGenFailMessage = "Consumer code file generation FAILED: 0 of 1 files generated";
public string PublisherCodeGenFailMessage = "Publisher code file generation FAILED: 0 of 1 files generated";
public string CodeGenNoTypeScriptErrorsMessage = "Success: No TypeScript errors found in ";
public string CodeGenNoTypeScriptErrorsMessage = "Success: No TypeScript errors found in generated file ";
// Runs a TS file through the JS LB and verifies code gen works correctly
public void Test_CodeGen_TSFile(string TestFile, bool NegTest = false, string ExtraConErrorMessage = "", string ExtraPubErrorMessage = "")
@ -85,7 +85,6 @@ namespace AmbrosiaTest
pass = MyUtils.WaitForProcessToFinish(testOutputLogFile, ExtraPubErrorMessage, 1, false, TestFile, true);
}
}
catch (Exception e)
{
@ -104,10 +103,11 @@ namespace AmbrosiaTest
{
try
{
Utilities MyUtils = new Utilities();
Utilities MyUtils = new Utilities();
// For some reason, the powershell script does NOT work if called from bin/x64/debug directory. Setting working directory to origin fixes it
string scriptWorkingDir = @"..\..\..\..\..\AmbrosiaTest\AmbrosiaTest";
string scriptWorkingDir = @"..\..\..\..\..\AmbrosiaTest";
string scriptDir = ConfigurationManager.AppSettings["AmbrosiaJSCodeGenDirectory"];
string fileName = "pwsh.exe";
string parameters = "-file BuildJSTestApp.ps1 " + scriptDir;

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

@ -0,0 +1,13 @@
export module Test
{
/**
* Method with single 'rawParams: Uint8Array' parameter cannot be a Post method (ie. missing the 'methodID=' attribute)
* @param rawParams Description of the format of the custom serialized byte array.
* @ambrosia publish=true
*/
export function takesCustomSerializedParams(rawParams: Uint8Array): void {
}
}

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

@ -57,9 +57,10 @@ export namespace Test {
console.log("JSDOcTag");
}
/* This will NOT generate code - causes a warning that Skipping Function */
/******** @ambrosia publish=true */
export function NotJSDOcTag() {
export function NotJSDOcTag() {
console.log("NotJSDOcTag");
}

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

@ -0,0 +1,15 @@
export namespace Test
{
/**
* Method to test custom serialized parameters.
* @ambrosia publish=true, methodID=2
* @param rawParams Description of the format of the custom serialized byte array.
*/
export function takesCustomSerializedParams(rawParams: Uint8Array): void {
}
}

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

@ -0,0 +1,17 @@
/**
Test when missing @param rawParams
*/
export namespace Test
{
/**
* Method to test custom serialized parameters.
* @ambrosia publish=true, methodID=2
*/
export function takesCustomSerializedParams(rawParams: Uint8Array): void {
}
}

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

@ -22,12 +22,12 @@ async function main()
{
await Ambrosia.initializeAsync(Ambrosia.LBInitMode.CodeGen);
let sourceFile: string = Utils.getCommandLineArg("sourceFile");
let codeGenKind: Meta.CodeGenFileKind = Meta.CodeGenFileKind[Utils.getCommandLineArg("codeGenKind", "All")] ?? Meta.CodeGenFileKind.All;
let codeGenKind: Meta.GeneratedFileKind = Meta.GeneratedFileKind[Utils.getCommandLineArg("codeGenKind", "All")] ?? Meta.GeneratedFileKind.All;
let mergeType: Meta.FileMergeType = Meta.FileMergeType[Utils.getCommandLineArg("mergeType", "None")] ?? Meta.FileMergeType.None;
let generatedFileName: string = Utils.getCommandLineArg("generatedFileName", "TestOutput") ?? "TestOutput";
Meta.emitTypeScriptFileFromSource(sourceFile, { fileKind: Meta.CodeGenFileKind.Consumer, mergeType: Meta.FileMergeType.None, emitGeneratedTime: false, generatedFileName: generatedFileName+"_Consumer" });
Meta.emitTypeScriptFileFromSource(sourceFile, { fileKind: Meta.CodeGenFileKind.Publisher, mergeType: Meta.FileMergeType.None, emitGeneratedTime: false, generatedFileName: generatedFileName+"_Publisher" });
Meta.emitTypeScriptFileFromSource(sourceFile, { fileKind: Meta.GeneratedFileKind.Consumer, mergeType: Meta.FileMergeType.None, emitGeneratedTime: false, generatedFileName: generatedFileName+"_Consumer" });
Meta.emitTypeScriptFileFromSource(sourceFile, { fileKind: Meta.GeneratedFileKind.Publisher, mergeType: Meta.FileMergeType.None, emitGeneratedTime: false, generatedFileName: generatedFileName+"_Publisher" });
}
catch (error)

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

@ -0,0 +1,25 @@
{
"$schema": "./ambrosiaConfig-schema.json",
"instanceName": "server",
"icCraPort": 2500,
"icReceivePort": 2000,
"icSendPort": 2001,
"icLogFolder": "C:/logs/",
"icBinFolder": "C:/src/Git/PostSledgehammer/AMBROSIA/ImmortalCoordinator/bin/x64/Release",
"useNetCore": false,
"logTriggerSizeInMB": 1024,
"debugStartCheckpoint": 0,
"debugTestUpgrade": false,
"appVersion": 0,
"lbOptions":
{
"deleteLogs": true,
"deleteRemoteCRAConnections": false,
"outputLogDestination": "ConsoleAndFile",
"outputLogFolder": "./outputLogs",
"outputLoggingLevel": "Normal",
"allowDisplayOfRpcParams": true,
"allowPostMethodTimeouts": true,
"enableTypeScriptStackTraces": true
}
}

6
AmbrosiaTest/JSCodeGen/package-lock.json сгенерированный
Просмотреть файл

@ -21,10 +21,10 @@
}
},
"ambrosia-node": {
"version": "file:ambrosia-node-0.0.74.tgz",
"integrity": "sha512-HH4XIb73AuFtqOu5BTrVMfjiUVXuSf1Srh73Woa4GUG86wB2iLKpq5aQiVA4zeMA1OcZ4JYfYSA3xz57vZcL1A==",
"version": "file:ambrosia-node-0.0.75.tgz",
"integrity": "sha512-ifbINNPye0i3t28Ldr503atqgC0vMqEbKqAZRi9JyTNO5RdnHoem7Cl/yDeuJM4B/A5RtY1II6bqsawcZqiJkg==",
"requires": {
"@types/node": "^14.14.12",
"@types/node": "^14.14.14",
"azure-storage": "^2.10.3",
"source-map-support": "^0.5.19"
}

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

@ -7,7 +7,7 @@
"name": ""
},
"dependencies": {
"ambrosia-node": "file:ambrosia-node-0.0.74.tgz",
"ambrosia-node": "file:ambrosia-node-0.0.75.tgz",
"typescript": "^4.0.5"
}
}