[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/script-host](https://jsprismarine.dev/api/@jsprismarine/script-host/index.md) / shape/resolve

# shape/resolve

## Interfaces

### ModuleDependency

Defined in: [script-host/src/shape/resolve.ts:8](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/resolve.ts#L8)

A pack's native module dependency, as its manifest writes it.

#### Properties

##### module\_name

> `readonly` **module\_name**: `string`

Defined in: [script-host/src/shape/resolve.ts:9](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/resolve.ts#L9)

##### version

> `readonly` **version**: `string`

Defined in: [script-host/src/shape/resolve.ts:10](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/resolve.ts#L10)

***

### PackIdentity

Defined in: [script-host/src/shape/resolve.ts:14](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/resolve.ts#L14)

A pack as BDS's content log names it: its header name and version.

#### Properties

##### name

> `readonly` **name**: `string`

Defined in: [script-host/src/shape/resolve.ts:15](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/resolve.ts#L15)

##### version

> `readonly` **version**: `string`

Defined in: [script-host/src/shape/resolve.ts:16](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/resolve.ts#L16)

***

### ResolveOptions

Defined in: [script-host/src/shape/resolve.ts:20](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/resolve.ts#L20)

What a resolution needs besides the dependency.

#### Properties

##### allowedModules

> `readonly` **allowedModules**: readonly `string`[]

Defined in: [script-host/src/shape/resolve.ts:23](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/resolve.ts#L23)

The world's `allowed_modules`, from `permissions.json`.

##### betaApis?

> `readonly` `optional` **betaApis?**: `boolean`

Defined in: [script-host/src/shape/resolve.ts:25](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/resolve.ts#L25)

Whether the world turns on the Beta APIs experiment.

##### histories?

> `readonly` `optional` **histories?**: `Readonly`\<`Record`\<`string`, [`ModuleHistory`](https://jsprismarine.dev/api/@jsprismarine/script-host/shape/format/index.md#modulehistory)\>\>

Defined in: [script-host/src/shape/resolve.ts:27](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/resolve.ts#L27)

The module histories to resolve against. The generated ones when absent.

##### pack

> `readonly` **pack**: [`PackIdentity`](#packidentity)

Defined in: [script-host/src/shape/resolve.ts:21](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/resolve.ts#L21)

## Type Aliases

### Resolution

> **Resolution** = \{ `ok`: `true`; `requested`: `string`; `shape`: [`ModuleShape`](https://jsprismarine.dev/api/@jsprismarine/script-host/shape/history/index.md#moduleshape); \} \| \{ `message`: `string`; `ok`: `false`; `reason`: [`ResolveFailure`](#resolvefailure); \}

Defined in: [script-host/src/shape/resolve.ts:39](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/resolve.ts#L39)

The API BDS serves for a dependency, or the content log line it refuses the pack with.

***

### ResolveFailure

> **ResolveFailure** = `"not-allowed"` \| `"unknown-module"` \| `"unknown-version"` \| `"beta-disabled"` \| `"internal"` \| `"alpha"`

Defined in: [script-host/src/shape/resolve.ts:35](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/resolve.ts#L35)

Why BDS refuses a dependency. BDS creates no context for a pack refused for an unknown module
or version, and logs that beside the reason; the other refusals it logs alone. `alpha` is the one
BDS does not make: it loads an alpha API that this server has no shape for.

## Functions

### currentBeta()

> **currentBeta**(`history`): `string` \| `undefined`

Defined in: [script-host/src/shape/resolve.ts:49](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/resolve.ts#L49)

The beta a module's history serves: its newest beta version, which BDS calls the current one.

#### Parameters

##### history

[`ModuleHistory`](https://jsprismarine.dev/api/@jsprismarine/script-host/shape/format/index.md#modulehistory)

#### Returns

`string` \| `undefined`

***

### resolveDependency()

> **resolveDependency**(`dependency`, `options`): [`Resolution`](#resolution)

Defined in: [script-host/src/shape/resolve.ts:71](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/resolve.ts#L71)

Resolves a pack's native module dependency the way the pinned BDS does
(section 2 of `docs/research/bedrock-script-api.md`):

- A module the world's `allowed_modules` leaves out is refused before BDS looks it up, so an
  unknown module that is also not allowed gets the not-allowed message.
- A stable version gets the newest stable minor of its major version, so 2.0.0 gets 2.10.0 and
  1.3.0 gets 1.19.0.
- A beta version, `-beta` or the word `beta`, needs the Beta APIs experiment, which BDS checks
  before it checks the version. Beta versions do not follow semver: a pack gets the one beta BDS
  ships, and the word `beta` names it.
- An alpha version, `-alpha` or the word `alpha`, loads on BDS without the experiment, but no
  metadata describes its API, so there is nothing to bind it to. It is refused with a message of
  this server's that says so, where BDS would load the pack
  ([#3233](https://github.com/JSPrismarine/JSPrismarine/issues/3233)).
- Any other version is refused with the versions BDS ships. BDS's list also has a `0.1.0` and an
  `-alpha` version for each module, which the metadata does not describe, so this list leaves
  them out.

#### Parameters

##### dependency

[`ModuleDependency`](#moduledependency)

##### options

[`ResolveOptions`](#resolveoptions)

#### Returns

[`Resolution`](#resolution)
