Publish plugin
The development of this issue is being made on #8.
We eventually want a cli to publish the plugin but for a first step, it could be only the API, e.g.
POST /volts and the body would be the zip file. We'll check the volt.toml file to see if it's valid, put the version, name, etc to the database, and put the wasm/theme files to storage.
I'll do the CLI after the API gets stabilized
I thought this would be the very first API?
But the API I will do now
POST /volts seems good enough
This will be the first api, doing a cli now is not a great idea because the API is in development, and we have to change the cli everytime that API changes
Can I add support for icons too? I mean, I already have to store files, so what's adding one more to the mix?
Can I add support for icons too? I mean, I already have to store files, so what's adding one more to the mix?
Yes please. Let's add icons.
this LGTM
I made this using open api
openapi: 3.0.0
servers:
- url: https://lapce-extensions.herokuapp.com
description: Production server
- url: http://localhost:8000
description: Local server
info:
description: |
This is the lapce registry API, nothing fancy here
version: v1
title: Lapce Plugin Registry
license:
name: MIT
tags:
- name: repository
description: Publish, manage and search plugins
externalDocs:
description: Find out more
url: http://registry.lapce.dev
- name: login
description: Start and destroy sessions
- name: user
description: Operations about user
paths:
/api/volt/{name}/{version}:
delete:
parameters:
- in: path
schema:
type: string
name: name
required: true
- in: path
schema:
type: string
name: version
required: true
tags: [repository]
description: Yanks a plugin version
responses:
"204":
description: The version was successfully yanked
"404":
description: The plugin/version does not exist or is yanked already
"401":
description: Not Logged In
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
examples:
error:
value:
kind: NotLoggedIn
action: "Send a `token` cookie."
message: "You're already logged out"
/api/volt/{name}:
delete:
parameters:
- in: path
schema:
type: string
name: name
required: true
tags: [repository]
description: Unpublishes a plugin
responses:
"204":
description: The plugin was successfully unpublished
"404":
description: The plugin does not exist
"401":
description: Not Logged In
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
examples:
error:
value:
kind: NotLoggedIn
action: "Send a `token` cookie."
message: "You're already logged out"
security:
- tokenAuth: []
/api/volt:
patch:
description: Updates a plugin, creating a new version
tags: [repository]
requestBody:
required: true
content:
application/zip:
schema:
format: binary
type: string
responses:
"201":
description: The new version was successfully published
content:
application/json:
schema:
$ref: "#/components/schemas/Volt"
"400":
description: The zip was malformed or the files were missing or incorrect
"401":
description: Not Logged In
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
examples:
error:
value:
kind: NotLoggedIn
action: "Send a `token` cookie."
message: "You're already logged out"
"404":
description: The specified plugin does not exist
"409":
description: The version is already published or a newer version already exists
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
examples:
error:
value:
kind: AlreadyExists
action: "Use a version greater than 1.0.0"
message: "A greater or equal version exists."
security:
- tokenAuth: []
post:
description: Creates a new plugin
tags: [repository]
requestBody:
required: true
content:
application/zip:
schema:
format: binary
type: string
responses:
"201":
description: The volt was successfully published
content:
application/json:
schema:
$ref: "#/components/schemas/Volt"
"400":
description: The zip was malformed or the files were missing or incorrect
"401":
description: Not Logged In
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
examples:
error:
value:
kind: NotLoggedIn
action: "Send a `token` cookie."
message: "You're already logged out"
"409":
description: The plugin is already published
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
examples:
error:
value:
kind: AlreadyExists
action: "Use a different name, or if you're trying to update, use PATCH /api/volt/{name} instead"
message: "A plugin with the same name is already published"
security:
- tokenAuth: []
/api/session:
delete:
security:
- tokenAuth: []
tags:
- login
summary: Invalidates the token, logging out
operationId: deleteSession
responses:
"200":
description: Session Invalidated
"401":
description: Not Logged In
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
examples:
error:
value:
kind: NotLoggedIn
action: "Send a `token` cookie."
message: "You're already logged out"
/api/user:
get:
security:
- tokenAuth: []
tags:
- user
summary: Get the current logged in user
operationId: getUser
responses:
"200":
description: Ok
content:
application/json:
examples:
user:
description: A user example
value:
id: 92828847
name: "coffee-is-power"
username: "Tiago Dinis"
avatar_url: "https://avatars.githubusercontent.com/u/92828847?v=4"
schema:
$ref: "#/components/schemas/User"
"401":
description: Not Logged In
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
examples:
error:
value:
kind: NotLoggedIn
action: "Send a `token` cookie."
message: Unauthorized
/login/github:
get:
tags:
- login
summary: Redirects to the github authorize page
operationId: startLogin
responses:
"300":
description: Ok
components:
securitySchemes:
tokenAuth:
type: apiKey
in: cookie
name: token
schemas:
Volt:
type: object
discriminator:
propertyName: id
properties:
id: {type: number}
name: {type: string}
publisher: {type: string}
display_name: {type: string}
icon: {type: string}
versions:
type: array
items:
type: string
author: {type: string}
description: {type: string}
Error:
type: object
discriminator:
propertyName: kind
properties:
kind:
description: Useful to check and match errors programatically
type: string
action:
description: A message that suggests the user to do things to try to fix the error (e.g verify the password)
type: string
message:
type: string
description: Describes what went wrong
User:
type: object
discriminator:
propertyName: id
properties:
id:
description: User ID
type: number
name:
type: string
description: login name
username:
description: Display name
type: string
avatar_url:
type: string
I'll integrate this into the pipeline, so it generates the HTML from the Open API specs and then rocket serves it, but I'll do that later
You can even test and play around with the API on your browser, which I think is really cool
I'll also make a yank version system similar to what cargo does, probably you've seen the delete endpoint
I'll store all the versions of the plugins so it would be cool if people could choose the version they want to download. People do dumb stuff and break their code quite frequently, so adding the ability to go back do older versions is important
So, the design I'm thinking is that, plugins are basically containers that contain versions.
Versions contain the plugin data like themes and the code. So when you publish a plugin, it will create a plugin and create a new version with the data you sent. For me it seems a good design.
draft/preview plugin versions
@panekj What do you mean?
Do you mean like adding a option to mark a version as a preview release?
yes
i'm going to use semantic versioning on the registry, so what if adding a -alpha/beta/rc* tag to the version marks it as a preview release?
But thinking well that can generate false positives/negatives, so its a trade-off, its easier to use, though it's not always reliable.
TO simplify the implementation, i'll let the user decide whether its a pre-release or not
Implemented: 5539616...9d53e35