API reference / @jsprismarine/addon-tools / addonIndex
addonIndex
Interfaces
AddonCommand
Defined in: addonIndex.ts:101
A command an addon's scripts register with customCommandRegistry.registerCommand.
Properties
cheatsRequired
readonlycheatsRequired:boolean
Defined in: addonIndex.ts:111
Whether it needs cheats on, as the script asked.
description
readonlydescription:string
Defined in: addonIndex.ts:107
name
readonlyname:string
Defined in: addonIndex.ts:106
The name with its namespace, such as jsp:tpsbar. It is also the permission node that grants or takes away the command in a server's permissions.json.
parameters
readonlyparameters: readonlyAddonCommandParameter[]
Defined in: addonIndex.ts:113
The mandatory parameters, then the optional ones.
permissionLevel
readonlypermissionLevel:number
Defined in: addonIndex.ts:109
The CommandPermissionLevel it needs, an index into COMMAND_PERMISSION_LEVELS.
AddonCommandParameter
Defined in: addonIndex.ts:117
One parameter of an AddonCommand.
Properties
name
readonlyname:string
Defined in: addonIndex.ts:118
optional
readonlyoptional:boolean
Defined in: addonIndex.ts:121
type
readonlytype:string
Defined in: addonIndex.ts:120
The CustomCommandParamType member, such as String or Enum.
values?
readonlyoptionalvalues?: readonlystring[]
Defined in: addonIndex.ts:123
The values an Enum parameter takes, when its enum was registered.
AddonIndex
Defined in: addonIndex.ts:127
A parsed addon index.
Properties
addons
readonlyaddons: readonlyAddonIndexEntry[]
Defined in: addonIndex.ts:130
Every published version, sorted by name and then by version, oldest first.
schemaVersion
readonlyschemaVersion:1
Defined in: addonIndex.ts:128
AddonIndexEntry
Defined in: addonIndex.ts:28
One published version of one addon.
Properties
description
readonlydescription:string
Defined in: addonIndex.ts:34
A one-line description of what the addon does.
listing?
readonlyoptionallisting?:AddonListing
Defined in: addonIndex.ts:45
What the marketplace shows for this version. Versions built before listings existed have none, and a reader that predates listings drops the key.
minServer
readonlyminServer:string
Defined in: addonIndex.ts:36
The oldest JSPrismarine version the addon runs on, major.minor.patch.
name
readonlyname:string
Defined in: addonIndex.ts:30
The addon's name: its folder in the source repository and its name in addon install.
sha256
readonlysha256:string
Defined in: addonIndex.ts:40
The pack's SHA-256, in lowercase hexadecimal.
url
readonlyurl:string
Defined in: addonIndex.ts:38
Where the .mcpack downloads from, an https: URL.
version
readonlyversion:string
Defined in: addonIndex.ts:32
The pack's version, major.minor.patch, from its manifest header.
AddonListing
Defined in: addonIndex.ts:67
The page content for one published version of an addon, read from its addon.json, README and icon when it was built. The files sit beside the pack on the release and are fixed with it.
Properties
authors
readonlyauthors: readonlystring[]
Defined in: addonIndex.ts:75
Who wrote the addon, as its author lists them.
commands?
readonlyoptionalcommands?: readonlyAddonCommand[]
Defined in: addonIndex.ts:90
The commands the addon's scripts register, in the order they register them. A version built before listings recorded commands, or whose scripts could not be run to read them, has none.
deprecated?
readonlyoptionaldeprecated?:string
Defined in: addonIndex.ts:77
Why the addon should no longer be installed, when its author has deprecated it.
icon?
readonlyoptionalicon?:AddonListingFile
Defined in: addonIndex.ts:83
The pack's pack_icon.png, when it has one.
license
readonlylicense:string
Defined in: addonIndex.ts:71
The addon's license, as an SPDX expression.
readme
readonlyreadme:AddonListingFile
Defined in: addonIndex.ts:81
The addon's README.md.
replacedBy?
readonlyoptionalreplacedBy?:string
Defined in: addonIndex.ts:79
The install id of the addon that replaces this one, such as warps-plus or owner/repo/name.
screenshots
readonlyscreenshots: readonlyAddonListingScreenshot[]
Defined in: addonIndex.ts:85
The screenshots, in the order addon.json lists them.
tags
readonlytags: readonlystring[]
Defined in: addonIndex.ts:73
Tags the marketplace filters by.
title
readonlytitle:string
Defined in: addonIndex.ts:69
The addon's name for people, such as TPS Bar.
AddonListingFile
Defined in: addonIndex.ts:49
A file a listing names: where it downloads from and its SHA-256.
Extended by
Properties
sha256
readonlysha256:string
Defined in: addonIndex.ts:53
The file's SHA-256, in lowercase hexadecimal.
url
readonlyurl:string
Defined in: addonIndex.ts:51
An https: URL.
AddonListingScreenshot
Defined in: addonIndex.ts:57
A screenshot a listing shows, with the text that describes it.
Extends
Properties
alt
readonlyalt:string
Defined in: addonIndex.ts:58
file?
readonlyoptionalfile?:string
Defined in: addonIndex.ts:60
Its path in the addon's folder, such as media/bar.png, which the README's images name.
sha256
readonlysha256:string
Defined in: addonIndex.ts:53
The file's SHA-256, in lowercase hexadecimal.
Inherited from
url
readonlyurl:string
Defined in: addonIndex.ts:51
An https: URL.
Inherited from
MergedAddonIndex
Defined in: addonIndex.ts:396
An index with a build's entries merged in, and which of those it did not list before.
Properties
added
readonlyadded: readonlyAddonIndexEntry[]
Defined in: addonIndex.ts:399
The built entries the earlier index did not have, in index order.
index
readonlyindex:AddonIndex
Defined in: addonIndex.ts:397
Variables
ADDON_INDEX_BACKUP_FILE
constADDON_INDEX_BACKUP_FILE:"index.previous.json"='index.previous.json'
Defined in: addonIndex.ts:25
The name the release workflow gives the old index while it uploads a new one. GitHub deletes an asset before replacing it, so the old index is renamed first; when the upload fails, this file still holds every published version, and the next build merges with it.
ADDON_INDEX_FILE
constADDON_INDEX_FILE:"index.json"='index.json'
Defined in: addonIndex.ts:18
The file name of the index on the release.
ADDON_INDEX_SCHEMA_VERSION
constADDON_INDEX_SCHEMA_VERSION:1=1
Defined in: addonIndex.ts:12
The schema version this module writes and reads.
ADDON_RELEASE_TAG
constADDON_RELEASE_TAG:"addons"='addons'
Defined in: addonIndex.ts:15
The release tag a source publishes its packs and index on.
COMMAND_PERMISSION_LEVELS
constCOMMAND_PERMISSION_LEVELS: readonly ["Any","GameDirectors","Admin","Host","Owner"]
Defined in: addonIndex.ts:98
The names of CommandPermissionLevel in @minecraft/server, in the order of their values, from Any at 0 to Owner. A command's level is stored as the number, which the server compares with a player's level.
Functions
addonVersionsInRange()
addonVersionsInRange(
index,name,range):AddonIndexEntry[]
Defined in: addonIndex.ts:219
The versions of one addon an index lists that fall in a range, newest first: the order an installer tries them in.
Parameters
index
name
string
range
string
Returns
compareAddonVersions()
compareAddonVersions(
a,b):number
Defined in: addonIndex.ts:169
Compares two major.minor.patch versions.
Parameters
a
string
b
string
Returns
number
Negative when a is older than b, zero when they are equal.
createAddonIndex()
createAddonIndex(
entries):AddonIndex
Defined in: addonIndex.ts:362
Builds an index from entries, sorted the way an index keeps them.
Parameters
entries
Iterable<AddonIndexEntry>
Returns
Throws
When two entries share a name and a version.
isAddonInstallId()
isAddonInstallId(
id):boolean
Defined in: addonIndex.ts:149
Whether a string is an addon's install id, the name addon install takes without a range: an addon name such as tps-bar for JSPrismarine's own addons, or <owner>/<repo>/<name>.
Parameters
id
string
Returns
boolean
isAddonName()
isAddonName(
name):boolean
Defined in: addonIndex.ts:140
Whether a name is an addon name: lowercase letters and digits, with single hyphens between.
Parameters
name
string
Returns
boolean
isAddonRange()
isAddonRange(
range):boolean
Defined in: addonIndex.ts:185
Whether a string is a version range satisfiesAddonRange reads.
Parameters
range
string
Returns
boolean
isAddonRepository()
isAddonRepository(
repository):boolean
Defined in: addonIndex.ts:143
Whether a string names a GitHub repository, <owner>/<repo>.
Parameters
repository
string
Returns
boolean
isAddonVersion()
isAddonVersion(
version):boolean
Defined in: addonIndex.ts:159
Whether a version is major.minor.patch with no leading zeros, the form an index uses. Each part must be a safe integer, since versions compare as numbers and two larger parts could read as one.
Parameters
version
string
Returns
boolean
mergeAddonIndex()
mergeAddonIndex(
published,built):MergedAddonIndex
Defined in: addonIndex.ts:417
Merges a build's entries into the index already published. Every published version stays, so a lockfile's URL keeps downloading the pack it hashed; a built version that is already listed must match its hash, and its listing files must match theirs. A version published before listings existed keeps its entry without one.
Parameters
published
AddonIndex | undefined
The index on the release, or undefined before the first release.
built
readonly AddonIndexEntry[]
One entry for each addon the build packed.
Returns
Throws
PublishedVersionChanged when a built pack's version is published with another hash, and PublishedListingChanged when its listing files are published with others.
packFileName()
packFileName(
name,version):string
Defined in: addonIndex.ts:163
The file name of an addon's pack on the release: <name>-<version>.mcpack.
Parameters
name
string
version
string
Returns
string
parseAddonCommands()
parseAddonCommands(
value):AddonCommand[] |undefined
Defined in: addonIndex.ts:258
Reads a listing's commands. Keys beyond the schema are dropped, as they are elsewhere in the index.
Parameters
value
unknown
Returns
AddonCommand[] | undefined
The commands, or undefined when the value is not a list of them.
parseAddonIndex()
parseAddonIndex(
value):AddonIndex
Defined in: addonIndex.ts:380
Validates a decoded index.json against the schema. Keys an entry has beyond the schema's are dropped, so an index that gains fields under the same schema version still reads.
Parameters
value
unknown
The index, as JSON.parse returned it.
Returns
Throws
When the index does not follow the schema, has a schema version other than ADDON_INDEX_SCHEMA_VERSION, or lists one version of an addon twice.
satisfiesAddonRange()
satisfiesAddonRange(
version,range):boolean
Defined in: addonIndex.ts:199
Whether a version falls in a range, as npm reads the same range:
1.2.3matches that version only.~1.2.3matches1.2.3and later patches of1.2.^1.2.3matches1.2.3and anything later with the same major version. Below1.0.0the first non-zero part is the one that stays:^0.2.3stops before0.3.0, and^0.0.3matches0.0.3only.*matches every version.
Parameters
version
string
range
string
Returns
boolean
False for a version or a range neither form takes.
serializeAddonIndex()
serializeAddonIndex(
index):string
Defined in: addonIndex.ts:393
An index as the text of index.json: four-space indented, ending in a newline.
Parameters
index
Returns
string