Skip to content

Commit

Permalink
Merge pull request #616 from NASA-AMMOS/feature/609--Add_JSON_spec_to…
Browse files Browse the repository at this point in the history
…_sequencing_server

Add JSON Spec to sequencing server
  • Loading branch information
goetzrrGit authored Jan 24, 2023
2 parents 3f71ab9 + f625d8b commit d51d257
Show file tree
Hide file tree
Showing 11 changed files with 442 additions and 108 deletions.
28 changes: 20 additions & 8 deletions sequencing-server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions sequencing-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@js-temporal/polyfill": "^0.4.3",
"@nasa-jpl/aerie-ampcs": "^1.0.0",
"@nasa-jpl/aerie-ts-user-code-runner": "^0.5.0",
"@nasa-jpl/seq-json-schema": "^1.0.9",
"body-parser": "^1.20.1",
"dataloader": "^2.1.0",
"express": "^5.0.0-beta.1",
Expand Down
6 changes: 3 additions & 3 deletions sequencing-server/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
simulatedActivityInstanceBySimulatedActivityIdBatchLoader,
} from './lib/batchLoaders/simulatedActivityBatchLoader.js';
import { generateTypescriptForGraphQLActivitySchema } from './lib/codegen/ActivityTypescriptCodegen.js';
import { Command, CommandSeqJson, Sequence, SequenceSeqJson } from './lib/codegen/CommandEDSLPreface.js';
import { CommandStem, CommandSeqJson, Sequence, SequenceSeqJson } from './lib/codegen/CommandEDSLPreface.js';
import { processDictionary } from './lib/codegen/CommandTypeCodegen.js';
import './polyfills.js';
import { FallibleStatus } from './types.js';
Expand Down Expand Up @@ -682,7 +682,7 @@ app.post('/get-seqjson-for-seqid-and-simulation-dataset', async (req, res, next)
}
return {
...ai,
commands: row.commands?.map(Command.fromSeqJson) ?? null,
commands: row.commands?.map(CommandStem.fromSeqJson) ?? null,
errors: row.errors,
};
});
Expand Down Expand Up @@ -841,7 +841,7 @@ app.post('/bulk-get-seqjson-for-seqid-and-simulation-dataset', async (req, res,
}
return {
...ai,
commands: row.commands?.map(Command.fromSeqJson) ?? null,
commands: row.commands?.map(CommandStem.fromSeqJson) ?? null,
errors: row.errors,
};
});
Expand Down
4 changes: 2 additions & 2 deletions sequencing-server/src/defaultSeqBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Command, Sequence } from './lib/codegen/CommandEDSLPreface.js';
import { CommandStem, Sequence } from './lib/codegen/CommandEDSLPreface.js';
import type { SeqBuilder } from './types/seqBuilder';

export const defaultSeqBuilder: SeqBuilder = (
Expand All @@ -19,7 +19,7 @@ export const defaultSeqBuilder: SeqBuilder = (

if (ai.errors.length > 0) {
return ai.errors.map(e =>
Command.new({
CommandStem.new({
stem: '$$ERROR$$',
arguments: [e.message],
metadata: {
Expand Down
30 changes: 15 additions & 15 deletions sequencing-server/src/lib/codegen/CommandEDSLPreface.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
Command,
CommandStem,
doyToInstant,
DOY_STRING,
hmsToDuration,
Expand All @@ -11,15 +11,15 @@ import {
describe('Command', () => {
describe('fromSeqJson', () => {
it('should parse a command seqjson', () => {
const command = Command.fromSeqJson({
const command = CommandStem.fromSeqJson({
type: 'command',
stem: 'test',
metadata: {},
args: [],
time: { type: TimingTypes.COMMAND_COMPLETE },
});

expect(command).toBeInstanceOf(Command);
expect(command).toBeInstanceOf(CommandStem);
expect(command.stem).toBe('test');
expect(command.metadata).toEqual({});
expect(command.arguments).toEqual([]);
Expand All @@ -28,7 +28,7 @@ describe('Command', () => {

describe('toEDSLString()', () => {
it('should handle absolute time tagged commands', () => {
const command = Command.new({
const command = CommandStem.new({
stem: 'TEST',
arguments: ['string', 0, true],
absoluteTime: doyToInstant('2020-001T00:00:00.000' as DOY_STRING),
Expand All @@ -38,7 +38,7 @@ describe('Command', () => {
});

it('should handle relative time tagged commands', () => {
const command = Command.new({
const command = CommandStem.new({
stem: 'TEST',
arguments: ['string', 0, true],
relativeTime: hmsToDuration('00:00:00.000' as HMS_STRING),
Expand All @@ -48,7 +48,7 @@ describe('Command', () => {
});

it('should handle epoch relative time tagged commands', () => {
const command = Command.new({
const command = CommandStem.new({
stem: 'TEST',
arguments: ['string', 0, true],
epochTime: hmsToDuration('00:00:00.000' as HMS_STRING),
Expand All @@ -58,7 +58,7 @@ describe('Command', () => {
});

it('should handle command complete commands', () => {
const command = Command.new({
const command = CommandStem.new({
stem: 'TEST',
arguments: ['string', 0, true],
});
Expand All @@ -67,14 +67,14 @@ describe('Command', () => {
});

it('should handle commands without arguments', () => {
const command = Command.new({
const command = CommandStem.new({
stem: 'TEST',
arguments: [],
});

expect(command.toEDSLString()).toEqual('C.TEST');

const command2 = Command.new({
const command2 = CommandStem.new({
stem: 'TEST',
arguments: {},
});
Expand All @@ -83,7 +83,7 @@ describe('Command', () => {
});

it('should convert to EDSL string with array arguments', () => {
const command = Command.new({
const command = CommandStem.new({
stem: 'TEST',
arguments: ['string', 0, true],
absoluteTime: doyToInstant('2020-001T00:00:00.000' as DOY_STRING),
Expand All @@ -93,7 +93,7 @@ describe('Command', () => {
});

it('should convert to EDSL string with named arguments', () => {
const command = Command.new({
const command = CommandStem.new({
stem: 'TEST',
arguments: {
string: 'string',
Expand Down Expand Up @@ -139,12 +139,12 @@ describe('Sequence', () => {
expect(sequence.metadata).toEqual({});
expect(sequence.commands.length).toEqual(2);

expect(sequence.commands[0]!).toBeInstanceOf(Command);
expect(sequence.commands[0]!).toBeInstanceOf(CommandStem);
expect(sequence.commands[0]!.stem).toBe('test');
expect(sequence.commands[0]!.metadata).toEqual({});
expect(sequence.commands[0]!.arguments).toEqual([]);

expect(sequence.commands[1]!).toBeInstanceOf(Command);
expect(sequence.commands[1]!).toBeInstanceOf(CommandStem);
expect(sequence.commands[1]!.stem).toBe('test2');
expect(sequence.commands[1]!.metadata).toEqual({});
expect(sequence.commands[1]!.arguments).toEqual(['string', 0, true]);
Expand Down Expand Up @@ -173,12 +173,12 @@ describe('Sequence', () => {
seqId: 'test',
metadata: {},
commands: [
Command.new({
CommandStem.new({
stem: 'TEST',
arguments: ['string', 0, true],
absoluteTime: doyToInstant('2020-001T00:00:00.000' as DOY_STRING),
}),
Command.new({
CommandStem.new({
stem: 'TEST',
arguments: {
string: 'string',
Expand Down
Loading

0 comments on commit d51d257

Please sign in to comment.