Skip to content

Commit

Permalink
fix: assets, beacons, fps, rendezvous and nodes requests and commands…
Browse files Browse the repository at this point in the history
… are not working properly
  • Loading branch information
bchelkowski committed Dec 18, 2023
1 parent e5d4503 commit 3b7e0df
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 19 deletions.
1 change: 1 addition & 0 deletions src/cli/commands/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ export default function ({ createCommand }: CreateCommandParameters): Command {
});

console.table(_assets);
console.table(_assets['graphics-instances'].rographics);
});
}
2 changes: 1 addition & 1 deletion src/cli/commands/beacons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ type CommandType = 'track' | 'untrack' | 'log';

export default function ({ createCommand }: CreateCommandParameters): Command {
return createCommand('Tracks channel and media lifecycle events for a specific channel.')
.argument(...getChannelIdArgumentDefinition())
.argument(...getCommandArgumentDefinition('Command for beacons', {
default: 'log',
validator: ['log', 'track', 'untrack'],
}))
.argument(...getChannelIdArgumentDefinition())
.option(...getRokuIPOptionDefinition())
.action(async ({ args, options }) => {
const _beacons = await beacons({
Expand Down
14 changes: 11 additions & 3 deletions src/cli/commands/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,25 @@ export default function ({ createCommand }: CreateCommandParameters): Command {
return createCommand('Returns all/root or finds some rendered nodes')
.argument(...getTypeArgumentDefinition('Type of returned nodes - can be: all, root or node', {
default: 'all',
validator: ['all', 'root', 'find'],
validator: ['all', 'roots', 'find'],
}))
.argument(...getNodeIdArgumentDefinition())
.option(...getRokuIPOptionDefinition())
.action(async ({ args, options }) => {
const sgNodesData = await sgNodes({
const _sgNodes = await sgNodes({
nodeId: getNodeId(options),
rokuIP: getRokuIP(options) || envVariables.ROKU_IP || '',
type: getType(args),
});

console.table(sgNodesData);
if (_sgNodes.All_Nodes) {
console.table(_sgNodes.All_Nodes);
} else if (_sgNodes.Nodes_Nodes) {
console.table(_sgNodes.Nodes_Nodes);
} else if (_sgNodes.Root_Nodes) {
console.table(_sgNodes.Root_Nodes);
} else {
console.table(_sgNodes);
}
});
}
10 changes: 7 additions & 3 deletions src/cli/commands/rendezvous.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,23 @@ type CommandType = 'track' | 'untrack' | 'log';

export default function ({ createCommand }: CreateCommandParameters): Command {
return createCommand('Lists the node rendezvous events for a sideloaded channel or production/beta channel linked to the Roku developer\'s account.')
.argument(...getChannelIdArgumentDefinition())
.argument(...getCommandArgumentDefinition('Command for beacons', {
default: 'log',
validator: ['log', 'track', 'untrack'],
}))
.argument(...getChannelIdArgumentDefinition())
.option(...getRokuIPOptionDefinition())
.action(async ({ args, options }) => {
const rendezvousData = await rendezvous({
const _rendezvous = await rendezvous({
channelId: getChannelId(args) || envVariables.CHANNEL_ID || '',
command: getCommand<CommandType>(args),
rokuIP: getRokuIP(options) || envVariables.ROKU_IP || '',
});

console.table(rendezvousData);
if (_rendezvous.data && _rendezvous.data['tracking-enabled'] === 'true' && _rendezvous.data?.item) {
console.table(_rendezvous.data.item);
} else {
console.table(_rendezvous);
}
});
}
6 changes: 3 additions & 3 deletions src/requests/beacons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ const CommandRequestMethod = {
};

const CommandPath = {
log: 'query/fwbeacons',
track: 'query/fwbeacons/track',
untrack: 'query/fwbeacons/untrack',
log: '/query/fwbeacons',
track: '/fwbeacons/track',
untrack: '/fwbeacons/untrack',
};

export default async (options: BeaconsOptions): Promise<void> => {
Expand Down
2 changes: 1 addition & 1 deletion src/requests/graphicsFrameRate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default async (options?: GraphicsFrameRateOptions): Promise<void> => {
try {
const response = await new RokuRequest({
method: RequestMethod.GET,
path: 'query/graphics-frame-rate',
path: '/query/graphics-frame-rate',
port: RokuPort.ECP,
rokuIP: options?.rokuIP || args.rokuIP,
}).send();
Expand Down
8 changes: 4 additions & 4 deletions src/requests/rendezvous.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export type RendezvousOptions = {
};

const CommandPath = {
log: 'query/sgrendezvous',
track: 'query/sgrendezvous/track',
untrack: 'query/sgrendezvous/untrack',
log: '/query/sgrendezvous',
track: '/sgrendezvous/track',
untrack: '/sgrendezvous/untrack',
};

const CommandRequestMethod = {
Expand All @@ -22,7 +22,7 @@ const CommandRequestMethod = {
untrack: RequestMethod.POST,
};

export default async (options: RendezvousOptions): Promise<void> => {
export default async (options: RendezvousOptions) => {
let path = CommandPath[options.command];

if (options.command === 'track' && options.channelId) {
Expand Down
8 changes: 4 additions & 4 deletions src/requests/sgNodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export type SGNodesOptions = {
};

const TypePath = {
all: 'query/sgnodes/all',
find: 'query/sgnodes/nodes?node-id=',
roots: 'query/sgnodes/roots',
all: '/query/sgnodes/all',
find: '/query/sgnodes/nodes?node-id=',
roots: '/query/sgnodes/roots',
};

export default async (options: SGNodesOptions) => {
Expand All @@ -35,7 +35,7 @@ export default async (options: SGNodesOptions) => {
explicitArray: false,
});

return parsedResponse;
return parsedResponse.sgnodes;
} catch (error) {
const rokuError = error as RokuRequestError;

Expand Down

0 comments on commit 3b7e0df

Please sign in to comment.