Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[superceded by #1477]: Course and Resources API #1381

Closed
wants to merge 64 commits into from

Conversation

panaaj
Copy link
Member

@panaaj panaaj commented Jan 28, 2022

This PR is based on server v1.41 and superscedes #1361 to implement the following:

  • Course API as outlined in Signal K specification PR #629.
  • Request handling for the Signal K ./api/resources path for both defined resource types (routes, waypoints, notes, regions and charts) and user defined types.
  • Resources API for the creation, and updating of resources (./api/resources/set/<resource_type>)
  • Interface for Resource Provider plugins to persist resource data.

Features:

  • GET, PUT, POST and DELETE request processing for /signalk/v1/api/resources and /signalk/v1/api/resources/*paths
  • Validation of submitted resource data for Signal K defined resource types.
  • Interface for plugins to retrieve resources (getResource(type, id))
  • Interface for plugins to register as a Resource Provider
  • Populates both courseGreatCircle and courseRhumbline attributes
  • Provides a single path to get destination information (./navigation/course)
  • Persists destination information so it is not lost if server is restarted
  • Backward compatibility with exisiting plugins

Resource Provider Plugins:
The persistance of resource data to a storage device is performed by a resource provider plugin.
In this way plugins can be written to support different storage types i.e. filesystem files, database or remote storage.

Example: Filesystem based Resource Provider plugin

@panaaj
Copy link
Member Author

panaaj commented Jan 28, 2022

@tkurki I have created this new branch / PR which is based on v1.41 release.

The one issue I encountered is that with the changes to some of the type definitions I can no longer define the passed app instance as extending both Application and SignalKMessageHub due to emit having different declarations.

I'm not sure if this was intended or just a side-effect of the type refinement?

Extending SignalKMessageHub is required to get the

signalk: FullSignalK
handleMessage: (id: string, data: any) => void

declarations.
Previously these declarations were declared in WithSignalK which is what was being used prior to the changes.

I have worked around it for now by having the declarations in the local file.

interface ResourceApplication
  extends Application,
    WithSecurityStrategy {
      handleMessage: (id: string, data: any) => void
    }

Copy link
Member

@tkurki tkurki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments

RESOURCE_PROVIDER_PLUGINS.md Outdated Show resolved Hide resolved
RESOURCE_PROVIDER_PLUGINS.md Outdated Show resolved Hide resolved
RESOURCE_PROVIDER_PLUGINS.md Outdated Show resolved Hide resolved

## Overview

The SignalK specification defines the path `/signalk/v1/api/resources` for accessing resources to aid in navigation and operation of the vessel.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be bold enough to put this under v2. What do you think? @sbender9 ?

RESOURCE_PROVIDER_PLUGINS.md Outdated Show resolved Hide resolved
WORKING_WITH_RESOURCES_API.md Outdated Show resolved Hide resolved
SERVERPLUGINS.md Show resolved Hide resolved
WORKING_WITH_RESOURCES_API.md Outdated Show resolved Hide resolved
WORKING_WITH_RESOURCES_API.md Outdated Show resolved Hide resolved
src/api/resources/types.ts Outdated Show resolved Hide resolved
WORKING_WITH_RESOURCES_API.md Outdated Show resolved Hide resolved
WORKING_WITH_RESOURCES_API.md Outdated Show resolved Hide resolved
RESOURCE_PROVIDER_PLUGINS.md Outdated Show resolved Hide resolved
SERVERPLUGINS.md Show resolved Hide resolved
src/api/resources/types.ts Outdated Show resolved Hide resolved
Copy link
Member Author

@panaaj panaaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed calling clearDestination() on setActiveRoute() / setDestination() error

src/api/resources/validate.ts Outdated Show resolved Hide resolved
tkurki and others added 7 commits April 3, 2022 22:12
Now that the plugin is in the same repo ts compilation
should happen from the root of the project (server), as
project references are not available in leaf projects.
build --all fails on this.
panaaj and others added 10 commits April 4, 2022 10:57
Chart id should be meaningful.
Instead of the fixed servers in openApi.json files we can
serve servers relative to the host used in the request.

Introduce ts OpenApiRecord to keep metadata, keeping
the openapi.json files schema compliant. I tried first
adding the metadata there, but the schema based validation
did not like extra properties there."
setDestination, activateRoute throw errors with appropriate message.
Special notifications outlined in specification
Notifications used by apps/plugins included in server distro.
To allow plugins to correctly test for server version.
@tkurki tkurki added the feature label May 27, 2022
@panaaj panaaj changed the title Feature: Course and Resources API [superceded by #1477]: Course and Resources API Oct 3, 2022
@panaaj panaaj closed this Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants