Skip to content

Commit

Permalink
Merge branch 'packaging-docs'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sewer56 committed Aug 30, 2024
2 parents f85bf7f + 512a861 commit e9ab3d5
Show file tree
Hide file tree
Showing 17 changed files with 1,237 additions and 80 deletions.
11 changes: 7 additions & 4 deletions docs/Common/Configuration/About.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

!!! info "This page describes Reloaded3's configuration file format details."

!!! warning "TODO: Ingest for settings outside of Reloaded3 origin"

!!! warning "TODO: How we store global configuration in Application Profiles"
!!! warning "TODO: How we store global configuration in [Game Config][game-config]"

## Requirements

Expand Down Expand Up @@ -63,9 +61,14 @@ The planned UX for the time being is the following.
| [Source Generation][source-gen] | How we generate source code from config schema. |
| [Binary Format][binary-format] | How Reloaded3 configuration files are written to disk. |

## Extra Info

- For 'external' configurations in foreign formats within Reloaded3 system, see: [external-config.bin].

[binary-format]: ./Binary-Format.md
[config-schema]: ./Config-Schema.md
[hardware-configs]: ./Hardware-Configs/About.md
[loadouts]: ../../Server/Storage/Loadouts/About.md
[source-gen]: ./Source-Generation.md
[game-config]: ../../Server/Storage/Games/About.md
[game-config]: ../../Server/Storage/Games/About.md
[external-config.bin]: ../../Server/Storage/Loadouts/File-Format/Unpacked.md#external-configbin
4 changes: 3 additions & 1 deletion docs/Common/Configuration/Hardware-Configs/About.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ Let's be good citizens of the open source space.
| Section | Description |
| ------------------------------------- | -------------------------------------- |
| [Displays](./Displays.md) | Settings tied to a specific monitor. |
| [Controllers](./Controllers/About.md) | SDL3 Based Cross Platform Controllers. |
| [Controllers](./Controllers/About.md) | SDL3 Based Cross Platform Controllers. |

[config-schema]: ../Config-Schema.md
3 changes: 1 addition & 2 deletions docs/Loader/Backends/About.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
This is present for high performance dependencies, where every nanosecond counts.

Generally, it is not expected that mod authors will manually leverage this functionality however,
that said; it is hoped we can make it easy to use during the [publish process][mod-publishing] if possible.
that said; it is hoped we can make it easy to use during the `publish process` if possible.

| Type | Name | Description |
| ------ | ------ | --------------------------------------------- |
Expand Down Expand Up @@ -128,5 +128,4 @@ For the following reasons:
[regular-mods]: ../Core-Architecture.md#regular-mods-layer-3
[Package Metadata]: ../../Server/Packaging/Package-Metadata.md
[microarchitecture-levels]: https://en.wikipedia.org/wiki/X86-64#Microarchitecture_levels
[mod-publishing]: ../../Server/Packaging/Publishing-Packages.md
[research-march-levels]: ../../Research/Microarchitecture-Levels.md
2 changes: 1 addition & 1 deletion docs/Research/Library-Sizes/Serializers.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct DependencyInfo {
id: String,
name: String,
author: String,
// Additional fields for UpdateData can be added here
// Additional fields for UpdateSourceData can be added here
}

#[derive(Archive, Deserialize, Serialize, Debug, Eq, PartialEq)]
Expand Down
256 changes: 256 additions & 0 deletions docs/Research/Mod-Download-URLs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
!!! info "This section provides examples of how to retrieve download information from various sources using their respective APIs."

The examples below already have URL segments filled in, they are placeholders for easier understanding.

## Reasoning

!!! info "In some locations, we need to uniquely identify an externally hosted file."

In order for the `rollback` feature to work properly, we must be able to uniquely identify the location
from which the mod was downloaded.

Likewise the [Central Server] needs a way to know which version of a package is tied to which file.

In order to achieve this, we must look at the external site APIs and see if they provide a way to
uniquely identify a file.

## API Request Examples

!!! info "These are some relevant API requests and responses."

### GameBanana

#### Obtain a Mod Page

**Example URL:**
```
https://gamebanana.com/apiv11/Mod/302016?_csvProperties=_aFiles
```

**Response Data (simplified):**
```json
{
"_aFiles": [
{
"_idRow": 610939,
"_sFile": "example_mod.zip",
"_nFilesize": 1048576,
"_sDownloadUrl": "https:\/\/gamebanana.com\/dl\/610939",
}
]
}
```

**Data Explanation:**

- `_idRow`: Unique identifier for the download (use this as `downloadId`)
- `_sFile`: Filename of the download
- `_nFilesize`: File size in bytes
- `_sDownloadUrl`: URL of the file

#### Obtain an Individual File

!!! info "The last part of the url is the obtained `_idRow` from the previous request."

**Example URL:**

```
https://gamebanana.com/apiv11/File/610939
```

```json
{
"_idRow": 610939,
"_sFile": "screenshot-commandmenu-02.zip",
"_nFilesize": 552,
"_sDownloadUrl": "https://gamebanana.com/dl/610939",
}
```

### GitHub

**Example URL:**
```
https://api.github.com/repos/Sewer56/nanokit-rs/releases?per_page=1&page=1
```

**Response Data (simplified):**
```json
[
{
"tag_name": "0.1.0",
"name": "0.1.0",
"published_at": "2024-04-05T14:45:15Z",
"assets": [
{
"url": "https://api.github.com/repos/Sewer56/nanokit-rs/releases/assets/160499684",
"id": 160499684,
"name": "Changelog.md",
"size": 495,
"browser_download_url": "https://github.com/Sewer56/nanokit-rs/releases/download/0.1.0/Changelog.md",
"created_at": "2024-04-05T14:45:15Z"
}
]
}
]
```

**Data Explanation:**

- `tag_name`: The tag name of the release (often corresponds to the version)
- `name`: The name of the release
- `published_at`: Timestamp of when the release was published
- `assets`: Array of assets (downloadable files) associated with the release
- `url`: Stable URL for this file.
- `id`: Unique identifier for the asset (use this as `assetId`)
- `name`: Filename of the asset
- `size`: File size in bytes
- `browser_download_url`: Direct download URL for the asset (don't use this one!!)
- `created_at`: Timestamp of when the asset was created

!!! danger "Do not use `browser_download_url`, it changes with file name."

Instead use the `url` field, it is stable as it is tied to the asset id.

!!! note "Max 100 items per page per file."

GitHub doesn't return error, just caps it to 100 silently.

### NexusMods

#### Obtain a Mod Page

**Example GraphQL Query:**

```
query Mods {
mods {
totalCount
nodes {
modId
gameId
}
}
}
```

**Response Data (simplified, truncated):**
```json
{
"data": {
"mods": {
"totalCount": 607400,
"nodes": [
{
"modId": 27329,
"gameId": 1303
},
{
"modId": 127700,
"gameId": 1704
}
]
}
}
}
```

!!! tip "Use `pageInfo` for pagination"

```json
pageInfo {
hasNextPage
endCursor
}
```

#### Obtain Mod Files

!!! info "Use `modId` and `gameId` from the previous query."

**Example GraphQL Query:**

```graphql
query ModFiles($modId: ID!, $gameId: ID!) {
modFiles(modId: $modId, gameId: $gameId) {
uid
size
name
uri
}
}
```

**Variables:**
```json
{
"modId": 127772,
"gameId": 1704
}
```

**Response Data (simplified):**
```json
{
"data": {
"modFiles": [
{
"uid": "7318624808113",
"size": 1048576,
"name": "Interesting NPCs SE - Loose Files",
"uri": "Interesting NPCs SE - Alternative Locations-29194-3-42Beta-1569342731.7z",
}
]
}
}
```

**Data Explanation:**

- `uid`: Unique identifier for the file (use this as unique identifier)
- `size`: File size in bytes
- `name`: User friendly name of the file
- `uri`: URL to download the file (reportedly).
- Maybe not yet fully functional.

**Alternative Query for Specific UIDs:**

```graphql
query ModFilesByUid($uids: [String!]!) {
modFilesByUid(uids: $uids) {
uid
size
name
uri
}
}
```

This fetches us the mod files by specific UID.

!!! note "No currently known V2 API for download links."

You have to use V1 API.

## What to Persist

!!! info "What should we persist to uniquely access files in the future?"

***GameBanana:***

- `u64`: id_row

***GitHub:***

- `String8` user_name
- `String8` repository_name
- `u64` asset_id

***NexusMods:***

- `u64` uid
- This is a tuple of `modId` and `gameId` in NexusMods.
- First 4 bytes are `modId`, last 4 bytes are `gameId`.
- These are little endian.

[Central Server]: ../Services/Central-Server.md
22 changes: 20 additions & 2 deletions docs/Server/Packaging/About.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Packaging

!!! info "This page contains all information related to how mods are packaged and distributed."
!!! info "This page contains all information related to how packages are structured and distributed."

The following sections contain information specifically about how *reloaded3* packages are structured.

Other systems may use slightly different layout and/or feature set.

## Package Structure

Expand Down Expand Up @@ -40,6 +44,12 @@ reloaded3.utility.examplemod.s56
└── package.toml
```

The specification for `package.toml` can be found at [Package Metadata].

The specification for `config.toml` can be found at [Configuration Schema].

The specification for the `languages` folder can be found at [Localisation].

### Changelog

!!! info "Located in `package/docs/changelog`."
Expand Down Expand Up @@ -141,7 +151,15 @@ That means including the following in each package:

!!! note "A package does not need to contain assets for previous versions, only changelogs."

## Where are Packages Stored?

!!! info "Reloaded3 packages are by default stored in a [machine persistent `Packages` folder][packages-folder]."

[cc-by-nc-sa-4.0]: https://creativecommons.org/licenses/by-nc-sa/4.0/
[docs-file]: ./Package-Metadata.md#docsfile
[gallery-items]: ./Package-Metadata.md#gallery
[images]: ../../Common/Images.md
[images]: ../../Common/Images.md
[Package Metadata]: ./Package-Metadata.md
[Configuration Schema]: ../../Common/Configuration/Config-Schema.md
[Localisation]: ../../Common/Localisation/File-Format.md
[packages-folder]: ../Storage/Locations.md#machine-non-persistent
Loading

0 comments on commit e9ab3d5

Please sign in to comment.