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

Implement loader version API #35

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

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

1 change: 1 addition & 0 deletions migrations/20241122212336_create_geode_versions.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE geode_versions;
25 changes: 25 additions & 0 deletions migrations/20241122212336_create_geode_versions.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
CREATE TABLE geode_versions (
tag TEXT PRIMARY KEY NOT NULL,
mac gd_version,
win gd_version,
android gd_version,
commit_hash TEXT NOT NULL,
prerelease BOOLEAN DEFAULT FALSE NOT NULL,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL
);

-- prefill some versions for the android updater
INSERT INTO geode_versions
(tag, mac, win, android, created_at, commit_hash, prerelease) VALUES
('4.0.1', '2.2074', '2.2074', '2.2074', '2024-11-20T21:39:54Z', 'ed97f3b0405a63f7edfa98df8d493a327e844111', FALSE),
('4.0.0', '2.2074', '2.2074', '2.2074', '2024-11-19T14:40:29Z', 'cb8d7571ddcff608d3a4de8f59f1a969ec0aff39', FALSE),
('4.0.0-beta.2', '2.2074', '2.2074', '2.2074', '2024-11-19T03:37:04Z', 'c0514b191583d6002dbf5c4f387471cff8fa535e', TRUE),
('4.0.0-beta.1', '2.2074', '2.2074', '2.2074', '2024-11-15T20:15:17Z', '9fe3d133e93191d6225f2521b0714788293995c6', TRUE),
('4.0.0-alpha.1', '2.2074', '2.2074', '2.2074', '2024-11-13T16:38:10Z', 'ebd4c920f5775287aea82fe758edec000108ff04', TRUE),
('3.9.3', '2.206', '2.206', '2.206', '2024-11-22T19:05:51Z', 'e363a3e44c4a0af5b8980de4b06ed4c17e7b92ae', FALSE),
('3.9.2', '2.206', '2.206', '2.206', '2024-11-14T22:01:58Z', '948e0d453dec9ea814974b17c68fde4006629611', FALSE),
('3.9.1', '2.206', '2.206', '2.206', '2024-11-14T00:39:09Z', 'c4f6758ab42717816e121bcc656701fc7fd14395', FALSE),
('3.9.0', '2.206', '2.206', '2.206', '2024-10-30T18:29:44Z', 'bd8387df1bc0bbba06a332c655e833121eddd9ff', FALSE),
('2.0.0-beta.27', '2.200', '2.204', '2.205', '2024-05-26T14:37:03Z', '6510df7c8557668744044471ed2a0391759c3f7f', FALSE),
('2.0.0-beta.4', '2.200', '2.204', '2.200', '2024-01-21T16:37:45Z', 'c2f626b93767ef3678b9df1daca14b89fec6c6f7', FALSE);

1 change: 1 addition & 0 deletions migrations/20241123052145_create_version_aliases.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE gd_version_aliases;
23 changes: 23 additions & 0 deletions migrations/20241123052145_create_version_aliases.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
CREATE TABLE gd_version_aliases (
version_name gd_version PRIMARY KEY NOT NULL,
mac_arm_uuid uuid UNIQUE,
mac_intel_uuid uuid UNIQUE,
android_manifest_id INTEGER UNIQUE,
windows_timestamp INTEGER UNIQUE,
added_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL
);

-- yet again, some default values, idk
INSERT INTO gd_version_aliases
(version_name, mac_arm_uuid, mac_intel_uuid, android_manifest_id, windows_timestamp) VALUES
-- not bothering with the mac uuids for most versions
-- it's not like they'll ever be used by the updater anyways
('2.200', null, null, 37, 1702921605),
('2.204', null, null, null, 1705041028),
('2.205', null, null, 38, null),
('2.206', null, null, 39, 1717243515),
('2.207', null, null, null, 1731098609),
('2.2071', null, null, null, 1731117052),
('2.2072', null, null, null, 1731130219),
('2.2073', null, null, null, 1731156923),
('2.2074', '27044C8B-76BD-303C-A035-5314AF1D9E6E', 'DB5CADC0-E533-3123-8A63-5A434FE391ED', 40, 1731376950);
167 changes: 167 additions & 0 deletions openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ tags:
- name: user
description: User management

- name: loader
description: Loader information

paths:
/:
get:
Expand Down Expand Up @@ -628,6 +631,153 @@ paths:
"500":
$ref: "#/components/responses/InternalServerError"

/v1/loader/versions:
get:
tags:
- loader
summary: Get all loader versions, paginated
description: Returns a paginated list of all loader versions. This list is currently sorted by when the mods were added, not by their versions.
qimiko marked this conversation as resolved.
Show resolved Hide resolved

parameters:
- name: gd
in: query
description: Geometry Dash version
required: false
schema:
$ref: "#/components/schemas/GDVersionString"
- name: platform
in: query
description: Platform to filter version by [win, android, mac]
required: false
schema:
$ref: "#/components/schemas/Platform"
- name: prerelease
in: query
description: If prerelease builds should be included in results
required: false
schema:
type: boolean
- $ref: "#/components/parameters/Page"
- $ref: "#/components/parameters/PerPage"

responses:
"200":
description: OK
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/LoaderVersion"
"400":
$ref: "#/components/responses/BadRequest"
"500":
$ref: "#/components/responses/InternalServerError"
post:
tags:
- loader
summary: Create a new loader version (admin only)
security:
- bearerAuth: []

requestBody:
content:
application/json:
schema:
type: object
properties:
tag:
required: true
type: string
description: "Git tag that references the release"
commit_hash:
required: true
type: string
prerelease:
required: false
type: boolean
gd:
$ref: "#/components/schemas/GDVersionObject"

responses:
"204":
description: No Content (Version created)
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"500":
$ref: "#/components/responses/InternalServerError"

/v1/loader/versions/latest:
get:
tags:
- loader
summary: Gets the latest loader version
description: Returns the latest loader version, filtered based on the given parameters

parameters:
- name: gd
in: query
description: Geometry Dash version
required: false
schema:
$ref: "#/components/schemas/GDVersionString"
- name: platform
in: query
description: Platform to filter version by [win, android, mac]
required: false
schema:
$ref: "#/components/schemas/Platform"
- name: prerelease
in: query
description: If prerelease builds should be accepted
required: false
schema:
type: boolean

responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/LoaderVersion"
"404":
$ref: "#/components/responses/NotFoundError"
"400":
$ref: "#/components/responses/BadRequest"
"500":
$ref: "#/components/responses/InternalServerError"

/v1/loader/versions/{version}:
get:
tags:
- loader
summary: Gets a loader version

parameters:
- name: version
description: Geode Version
in: path
required: true
schema:
$ref: "#/components/schemas/ModVersionString"

responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/LoaderVersion"
"404":
$ref: "#/components/responses/NotFoundError"
"400":
$ref: "#/components/responses/BadRequest"
"500":
$ref: "#/components/responses/InternalServerError"

components:
securitySchemes:
bearerAuth:
Expand Down Expand Up @@ -965,6 +1115,23 @@ components:
nullable: true
description: Information given with the version's status (typically a reason)

LoaderVersion:
type: object
properties:
tag:
type: string
commit_hash:
type: string
version:
$ref: "#/components/schemas/ModVersionString"
prerelease:
type: boolean
gd:
$ref: "#/components/schemas/GDVersionObject"
created_at:
type: string
format: date-time

Platform:
type: string
enum:
Expand Down
Loading