# Class: ResourceRegistry

Central registry for tracking plugin resource requirements. Deduplication uses type + resourceKey (machine-stable); alias is for display only.

## Constructors[​](#constructors "Direct link to Constructors")

### Constructor[​](#constructor "Direct link to Constructor")

```ts
new ResourceRegistry(): ResourceRegistry;

```

#### Returns[​](#returns "Direct link to Returns")

`ResourceRegistry`

## Methods[​](#methods "Direct link to Methods")

### clear()[​](#clear "Direct link to clear()")

```ts
clear(): void;

```

Clears all registered resources. Useful for testing or when rebuilding the registry.

#### Returns[​](#returns-1 "Direct link to Returns")

`void`

***

### collectResources()[​](#collectresources "Direct link to collectResources()")

```ts
collectResources(rawPlugins: PluginData<PluginConstructor, unknown, string>[]): void;

```

Collects and registers resource requirements from an array of plugins. For each plugin, loads its manifest (required) and runtime resource requirements.

#### Parameters[​](#parameters "Direct link to Parameters")

| Parameter    | Type                                                      | Description                                               |
| ------------ | --------------------------------------------------------- | --------------------------------------------------------- |
| `rawPlugins` | `PluginData`<`PluginConstructor`, `unknown`, `string`>\[] | Array of plugin data entries from createApp configuration |

#### Returns[​](#returns-2 "Direct link to Returns")

`void`

#### Throws[​](#throws "Direct link to Throws")

If any plugin is missing a manifest or manifest is invalid

***

### enforceValidation()[​](#enforcevalidation "Direct link to enforceValidation()")

```ts
enforceValidation(): ValidationResult;

```

Validates all registered resources and enforces the result.

* In production: throws a [ConfigurationError](/appkit/docs/api/appkit/Class.ConfigurationError.md) if any required resources are missing.
* In development (`NODE_ENV=development`): logs a warning but continues, unless `APPKIT_STRICT_VALIDATION=true` is set, in which case throws like production.
* When all resources are valid: logs a debug message with the count.

#### Returns[​](#returns-3 "Direct link to Returns")

[`ValidationResult`](/appkit/docs/api/appkit/Interface.ValidationResult.md)

ValidationResult with validity status, missing resources, and all resources

#### Throws[​](#throws-1 "Direct link to Throws")

In production when required resources are missing, or in dev when APPKIT\_STRICT\_VALIDATION=true

***

### get()[​](#get "Direct link to get()")

```ts
get(type: string, resourceKey: string): ResourceEntry | undefined;

```

Gets a specific resource by type and resourceKey (dedup key).

#### Parameters[​](#parameters-1 "Direct link to Parameters")

| Parameter     | Type     | Description                                               |
| ------------- | -------- | --------------------------------------------------------- |
| `type`        | `string` | Resource type                                             |
| `resourceKey` | `string` | Stable machine key (not alias; alias is for display only) |

#### Returns[​](#returns-4 "Direct link to Returns")

[`ResourceEntry`](/appkit/docs/api/appkit/Interface.ResourceEntry.md) | `undefined`

The resource entry if found, undefined otherwise

***

### getAll()[​](#getall "Direct link to getAll()")

```ts
getAll(): ResourceEntry[];

```

Retrieves all registered resources. Returns a copy of the array to prevent external mutations.

#### Returns[​](#returns-5 "Direct link to Returns")

[`ResourceEntry`](/appkit/docs/api/appkit/Interface.ResourceEntry.md)\[]

Array of all registered resource entries

***

### getByPlugin()[​](#getbyplugin "Direct link to getByPlugin()")

```ts
getByPlugin(pluginName: string): ResourceEntry[];

```

Gets all resources required by a specific plugin.

#### Parameters[​](#parameters-2 "Direct link to Parameters")

| Parameter    | Type     | Description        |
| ------------ | -------- | ------------------ |
| `pluginName` | `string` | Name of the plugin |

#### Returns[​](#returns-6 "Direct link to Returns")

[`ResourceEntry`](/appkit/docs/api/appkit/Interface.ResourceEntry.md)\[]

Array of resources where the plugin is listed as a requester

***

### getOptional()[​](#getoptional "Direct link to getOptional()")

```ts
getOptional(): ResourceEntry[];

```

Gets all optional resources (where required=false).

#### Returns[​](#returns-7 "Direct link to Returns")

[`ResourceEntry`](/appkit/docs/api/appkit/Interface.ResourceEntry.md)\[]

Array of optional resource entries

***

### getRequired()[​](#getrequired "Direct link to getRequired()")

```ts
getRequired(): ResourceEntry[];

```

Gets all required resources (where required=true).

#### Returns[​](#returns-8 "Direct link to Returns")

[`ResourceEntry`](/appkit/docs/api/appkit/Interface.ResourceEntry.md)\[]

Array of required resource entries

***

### register()[​](#register "Direct link to register()")

```ts
register(plugin: string, resource: ResourceRequirement): void;

```

Registers a resource requirement for a plugin. If a resource with the same type+resourceKey already exists, merges them:

* Combines plugin names (comma-separated)
* Uses the most permissive permission (per-type hierarchy)
* Marks as required if any plugin requires it
* Combines descriptions if they differ
* Merges fields; warns when same field name uses different env vars

#### Parameters[​](#parameters-3 "Direct link to Parameters")

| Parameter  | Type                                                                              | Description                                 |
| ---------- | --------------------------------------------------------------------------------- | ------------------------------------------- |
| `plugin`   | `string`                                                                          | Name of the plugin registering the resource |
| `resource` | [`ResourceRequirement`](/appkit/docs/api/appkit/Interface.ResourceRequirement.md) | Resource requirement specification          |

#### Returns[​](#returns-9 "Direct link to Returns")

`void`

***

### size()[​](#size "Direct link to size()")

```ts
size(): number;

```

Returns the number of registered resources.

#### Returns[​](#returns-10 "Direct link to Returns")

`number`

***

### validate()[​](#validate "Direct link to validate()")

```ts
validate(): ValidationResult;

```

Validates all registered resources against the environment.

Checks each resource's field environment variables to determine if it's resolved. Updates the `resolved` and `values` fields on each resource entry.

Only required resources affect the `valid` status - optional resources are checked but don't cause validation failure.

#### Returns[​](#returns-11 "Direct link to Returns")

[`ValidationResult`](/appkit/docs/api/appkit/Interface.ValidationResult.md)

ValidationResult with validity status, missing resources, and all resources

#### Example[​](#example "Direct link to Example")

```typescript
const registry = ResourceRegistry.getInstance();
const result = registry.validate();

if (!result.valid) {
  console.error("Missing resources:", result.missing.map(r => Object.values(r.fields).map(f => f.env)));
}

```

***

### formatDevWarningBanner()[​](#formatdevwarningbanner "Direct link to formatDevWarningBanner()")

```ts
static formatDevWarningBanner(missing: ResourceEntry[]): string;

```

Formats a highly visible warning banner for dev-mode missing resources. Uses box drawing to ensure the message is impossible to miss in scrolling logs.

#### Parameters[​](#parameters-4 "Direct link to Parameters")

| Parameter | Type                                                                     | Description                       |
| --------- | ------------------------------------------------------------------------ | --------------------------------- |
| `missing` | [`ResourceEntry`](/appkit/docs/api/appkit/Interface.ResourceEntry.md)\[] | Array of missing resource entries |

#### Returns[​](#returns-12 "Direct link to Returns")

`string`

Formatted banner string

***

### formatMissingResources()[​](#formatmissingresources "Direct link to formatMissingResources()")

```ts
static formatMissingResources(missing: ResourceEntry[]): string;

```

Formats missing resources into a human-readable error message.

#### Parameters[​](#parameters-5 "Direct link to Parameters")

| Parameter | Type                                                                     | Description                       |
| --------- | ------------------------------------------------------------------------ | --------------------------------- |
| `missing` | [`ResourceEntry`](/appkit/docs/api/appkit/Interface.ResourceEntry.md)\[] | Array of missing resource entries |

#### Returns[​](#returns-13 "Direct link to Returns")

`string`

Formatted error message string
