Skip to content
module@warp-drive/legacy/model/migration-support @legacy

Class DelegatingSchemaService

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:557

See the class documentation above for usage.

Implements

Constructors

Constructor

ts
new DelegatingSchemaService(store, schema): DelegatingSchemaService;

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:583

Parameters

store

Store

schema

SchemaService

Returns

DelegatingSchemaService

Methods

attributesDefinitionFor()?

ts
optional attributesDefinitionFor(resource): AttributesSchema;

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:562

Delegates to whichever of the primary/fallback schema services has a schema for the resource, preferring the primary. See isDelegated.

Parameters

resource

| ResourceKey | { type: string; }

Returns

AttributesSchema


cacheFields()?

ts
optional cacheFields(resource): Map<string, 
  | LegacyBelongsToField
  | LegacyHasManyField
  | LinksModeBelongsToField
  | LinksModeHasManyField
  | LegacyAttributeField
  | GenericField
  | ObjectField
  | SchemaObjectField
  | ArrayField
  | SchemaArrayField
  | ResourceField
| CollectionField>;

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:621

Queries for the fields of a given resource type or resource identity.

Should error if the resource type is not recognized.

Parameters

resource
type

string

Returns

Map<string, | LegacyBelongsToField | LegacyHasManyField | LinksModeBelongsToField | LinksModeHasManyField | LegacyAttributeField | GenericField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField | ResourceField | CollectionField>


CAUTION_MEGA_DANGER_ZONE_arrayExtensions()

ts
CAUTION_MEGA_DANGER_ZONE_arrayExtensions(field): 
  | Map<string | symbol, ExtensionDef>
  | null;

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:682

Retrieve the extension map for an array field

Parameters

field

ExtensibleField

Returns

| Map<string | symbol, ExtensionDef> | null


CAUTION_MEGA_DANGER_ZONE_hasExtension()

ts
CAUTION_MEGA_DANGER_ZONE_hasExtension(ext): boolean;

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:661

Check if a specific extension has been registered previously

Parameters

ext
kind

"object" | "array"

name

string

Returns

boolean


CAUTION_MEGA_DANGER_ZONE_objectExtensions()

ts
CAUTION_MEGA_DANGER_ZONE_objectExtensions(field, resolvedType): 
  | Map<string | symbol, ExtensionDef>
  | null;

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:675

Retrieve the extension map for an object field

Parameters

field

ExtensibleField

resolvedType

string | null

Returns

| Map<string | symbol, ExtensionDef> | null


CAUTION_MEGA_DANGER_ZONE_registerExtension()

ts
CAUTION_MEGA_DANGER_ZONE_registerExtension(extension): void;

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:665

Register an extension for either objects or arrays

See also CAUTION_MEGA_DANGER_ZONE_Extension

Parameters

extension

CAUTION_MEGA_DANGER_ZONE_Extension

Returns

void


CAUTION_MEGA_DANGER_ZONE_resourceExtensions()

ts
CAUTION_MEGA_DANGER_ZONE_resourceExtensions(resource): 
  | Map<string | symbol, ExtensionDef>
  | null;

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:669

Retrieve the extension map for a resource

Parameters

resource

| ResourceKey | { type: string; }

Returns

| Map<string | symbol, ExtensionDef> | null


derivation()

ts
derivation(field): Derivation;

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:636

Returns the derivation registered with the name provided by field.type. Validates that the field is a valid DerivedField.

Parameters

field

| DerivedField | { type: string; }

Returns

Derivation


doesTypeExist()?

ts
optional doesTypeExist(type): boolean;

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:572

Whether either the primary or fallback schema service has a schema for the given type.

Parameters

type

string

Returns

boolean


fields()

ts
fields(resource): Map<string, FieldSchema>;

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:615

Queries for the fields of a given resource type or resource identity.

Should error if the resource type is not recognized.

Parameters

resource

| ResourceKey | { type: string; }

Returns

Map<string, FieldSchema>


hashFn()

ts
hashFn(field): HashFn;

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:633

Returns the hash function registered with the name provided by field.type. Validates that the field is a valid HashField.

Parameters

field

| HashField | { type: string; }

Returns

HashFn


hasResource()

ts
hasResource(resource): boolean;

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:600

Queries whether the SchemaService recognizes type as a resource type

Parameters

resource

| ResourceKey | { type: string; }

Returns

boolean


hasTrait()

ts
hasTrait(type): boolean;

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:603

Queries whether the SchemaService recognizes type as a resource trait

Parameters

type

string

Returns

boolean


isDelegated()

ts
isDelegated(resource): boolean;

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:592

Whether the given resource's schema is being served by the fallback (legacy Model-derived) schema service rather than the primary one.

Parameters

resource

| ResourceKey | { type: string; }

Returns

boolean


registerDerivation()

ts
registerDerivation<R, T, FM>(derivation): void;

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:654

Enables registration of a derivation.

The derivation can later be retrieved by the name attached to it's [Type] property.

Type Parameters

R

R

T

T

FM

FM extends | ObjectValue | null

Parameters

derivation

Derivation<R, T, FM>

Returns

void


registerHashFn()

ts
registerHashFn(hashFn): void;

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:657

Enables registration of a hashing function

The hashing function can later be retrieved by the name attached to it's [Type] property.

Parameters

hashFn

HashFn

Returns

void


registerResource()

ts
registerResource(schema): void;

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:648

Enables registration of a single Schema representing either a resource in PolarisMode or LegacyMode or an ObjectSchema representing an embedded structure in other schemas.

This can be useful for either pre-loading schema information or for registering schema information delivered by API calls or other sources just-in-time.

Parameters

schema

| ResourceSchema | ObjectSchema

Returns

void


registerResources()

ts
registerResources(schemas): void;

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:645

Enables registration of multiple Schemas at once.

This can be useful for either pre-loading schema information or for registering schema information delivered by API calls or other sources just-in-time.

Parameters

schemas

( | ResourceSchema | ObjectSchema)[]

Returns

void


registerTransformation()

ts
registerTransformation(transform): void;

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:651

Enables registration of a transformation.

The transformation can later be retrieved by the name attached to it's [Type] property.

Parameters

transform

Transformation

Returns

void


relationshipsDefinitionFor()?

ts
optional relationshipsDefinitionFor(resource): RelationshipsSchema;

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:567

Delegates to whichever of the primary/fallback schema services has a schema for the resource, preferring the primary. See isDelegated.

Parameters

resource

| ResourceKey | { type: string; }

Returns

RelationshipsSchema


resource()

ts
resource(resource): 
  | ResourceSchema
  | ObjectSchema;

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:639

Returns the schema for the provided resource type.

Parameters

resource

| ResourceKey | { type: string; }

Returns

| ResourceSchema | ObjectSchema


resourceHasTrait()

ts
resourceHasTrait(resource, trait): boolean;

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:609

Queries whether the given resource has the given trait

Parameters

resource

| ResourceKey | { type: string; }

trait

string

Returns

boolean


resourceTypes()

ts
resourceTypes(): readonly string[];

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:596

Returns all known resource types

Returns

readonly string[]


transformation()

ts
transformation(field): Transformation;

Defined in: warp-drive-packages/legacy/src/model/migration-support.ts:630

Returns the transformation registered with the name provided by field.type. Validates that the field is a valid transformable.

Parameters

field

| GenericField | ObjectField | ArrayField | { type: string; }

Returns

Transformation

Released under the MIT License.