sketch-hq / sketch-assistants

Monorepo containing the official Sketch Assistants, along with utility functions and types for Sketch Assistant development.
MIT License
45 stars 11 forks source link

Assistants web service #73

Closed jedrichards closed 4 years ago

jedrichards commented 4 years ago

Assistants will benefit from web services that performs the following tasks:

  1. Facilitates one-click installs (required for launch)
  2. Sits in-between Sketch and the npm registry API, and provides Assistant package metadata (only required once we add support for Npm Assistants to Sketch, not required while we only support Url Assistants)

Read on more for more details.

Glossary

Using a web service here, instead of users crafting the sketch:// protocol deep-links themselves gains us the following advantages:

Already have a proof of concept that is being used in the wild at the moment, so should just be a case of reworking this.

Url Assistants behaviour

This is the behaviour of the current proof of concept.

  1. User clicks a link to the service, indicating the npm package name of the Assistant they want to add to their Sketch document
  2. Various options can be supplied (e.g. tag or latest version etc, Sketch variant for the deep link etc.)
  3. The service queries the npm API to resolve a fully qualified tgz url for that Assistant package
  4. The service redirects to the sketch:// deep link protocol, and asks the Sketch to add it as a Url Assistant

Npm Assistant behaviour

This won't be required until we support Npm Assistants.

Path and options would change minimally between the two behaviours, so we could just switch it over when Npm Assistants are released.

  1. User clicks a link to the service, indicating the npm package name of the Assistant they want to add to their Sketch document
  2. Various options can be supplied (e.g. tag or latest version etc, Sketch variant for the deep link etc.)
  3. The service queries the npm API to determine which semver should be used
  4. The service redirects to the sketch:// deep link protocol, and asks Sketch to add it as a Npm Assistant

Sketch Npm Proxy

This won't be required until we support Npm Assistants.

This could begin life as a single endpoint, where Sketch could ask for metadata about Npm packages, and get back information.

Using a web service here will insulate Sketch from any changes or rough edges in the npm API.

So if Sketch posted the following JSON to the endpoint (i.e. one or more Assistant names)

[
  "@sketch-hq/sketch-tidy-assistant"
]

It would get back something like

{
  "@sketch-hq/sketch-tidy-assistant": {
    "title": "Tidy Assistant",
    "description": "Blah",
    "icon": "https://www.domain.com/icon.png",
    "tags": {
      "latest": "5.0.1"
    },
    "versions": {
      "5.0.1": "https://registry.npmjs.org/@sketch-hq/sketch-tidy-assistant/-/sketch-tidy-assistant-5.0.1.tgz",
      "5.0.0": "https://registry.npmjs.org/@sketch-hq/sketch-tidy-assistant/-/sketch-tidy-assistant-5.0.0.tgz",
      "4.1.0": "https://registry.npmjs.org/@sketch-hq/sketch-tidy-assistant/-/sketch-tidy-assistant-4.1.0.tgz",
      ...
    }
  },
  ...
}

Technology choices

Domain

Perhaps something like assistants.sketch.com?

craig006 commented 4 years ago

@jedrichards it looks good to me.

One thing we could consider adding to the response from our "npm proxy", is some of the localized data, if that is possible. This would be useful when opening a document with a missing assistant to allow us to still display a friendly, title, description and perhaps even the icon, before the user chooses to hit the install button. But happy to not do this if you guys don't think its worth it.

Example: image

christianklotz commented 4 years ago

@luisbosque would be good to get your thoughts on it 🙏

luisbosque commented 4 years ago

After talking with @christianklotz setting up this backend service seems like too much complexity for what we try to achieve here. The logic to redirect to a sketch:// url seems like something that could perfectly happen in the assistants' webpage in JS or another approach would be to pre-generate the sketch:// urls of the different assistants during the deployment.

This will make a much simpler architecture, easier to maintain and prevent us to have to maintain a new service.

jedrichards commented 4 years ago

Agreed that extra services/moving parts aren't all that desirable.

If we're ditching the one-click web service we need to be clear on the implications:

None of the above are deal breakers though, so if we're ok with them we should brief the web marketing team about the extra requirement asap.

christianklotz commented 4 years ago

Closing for now, as #118 is handled separately.