Skip to content

AIDC Toolkit / GS1 / PrefixManager

Class: PrefixManager

Defined in: src/prefix-manager.ts:56

Prefix manager. This is the core class for identifier creation.

A prefix manager may be created for any prefix type. As most applications work with a limited number of prefixes for creating identifiers, prefix managers are cached in memory and may be reused.

Prefix managers are keyed by GS1 Company Prefix, so the prefix type that is requested may not match the prefix type of the returned prefix manager. For example, the prefix manager for GS1 Company Prefix 0614141 is identical to the one for U.P.C. Company Prefix 614141, with the prefix type equal to PrefixTypes.UPCCompanyPrefix and the prefix equal to "614141".

To support the creation of sparse identifiers, a prefix manager maintains a tweak which is used, along with a type-specific multiplier, as the tweak when creating numeric identifiers. The default tweak factor is the numeric value of the GS1 Company Prefix representation of the prefix preceded by '1' to ensure uniqueness (i.e., so that prefixes 0 N1 N2 N3... and N1 N2 N3... produce different tweak factors). This is usually sufficient for obfuscation, but as the sparse creation algorithm is reversible and as the GS1 Company Prefix is discoverable via Verified by GS1, a user-defined tweak factor should be used if a higher degree of obfuscation is required. When using a tweak factor other than the default, care should be taken to restore it when resuming the application. A tweak factor of 0 creates a straight sequence.

Implements

  • PrefixProvider

Accessors

prefixType

Get Signature

get prefixType(): PrefixType

Defined in: src/prefix-manager.ts:149

Get the prefix type.

Returns

PrefixType

Implementation of

PrefixProvider.prefixType


prefix

Get Signature

get prefix(): string

Defined in: src/prefix-manager.ts:156

Get the prefix.

Returns

string

Implementation of

PrefixProvider.prefix


gs1CompanyPrefix

Get Signature

get gs1CompanyPrefix(): string

Defined in: src/prefix-manager.ts:163

Get the GS1 Company Prefix.

Returns

string

Implementation of

PrefixProvider.gs1CompanyPrefix


upcCompanyPrefix

Get Signature

get upcCompanyPrefix(): string | undefined

Defined in: src/prefix-manager.ts:170

Get the U.P.C. Company Prefix if prefix type is PrefixTypes.UPCCompanyPrefix or undefined if not.

Returns

string | undefined

Implementation of

PrefixProvider.upcCompanyPrefix


gs18Prefix

Get Signature

get gs18Prefix(): string | undefined

Defined in: src/prefix-manager.ts:177

Get the GS1-8 Prefix if prefix type is PrefixTypes.GS18Prefix or undefined if not.

Returns

string | undefined

Implementation of

PrefixProvider.gs18Prefix


tweakFactor

Get Signature

get tweakFactor(): bigint

Defined in: src/prefix-manager.ts:200

Get the tweak factor.

Returns

bigint

Set Signature

set tweakFactor(value): void

Defined in: src/prefix-manager.ts:210

Set the tweak factor.

Parameters
value

Tweak factor.

number | bigint

Returns

void


gtinCreator

Get Signature

get gtinCreator(): GTINCreator

Defined in: src/prefix-manager.ts:349

Get GTIN creator.

Returns

GTINCreator


glnCreator

Get Signature

get glnCreator(): NonGTINNumericIdentifierCreator

Defined in: src/prefix-manager.ts:374

Get GLN creator.

Returns

NonGTINNumericIdentifierCreator


ssccCreator

Get Signature

get ssccCreator(): NonGTINNumericIdentifierCreator

Defined in: src/prefix-manager.ts:381

Get SSCC creator.

Returns

NonGTINNumericIdentifierCreator


graiCreator

Get Signature

get graiCreator(): SerializableNumericIdentifierCreator

Defined in: src/prefix-manager.ts:388

Get GRAI creator.

Returns

SerializableNumericIdentifierCreator


giaiCreator

Get Signature

get giaiCreator(): NonNumericIdentifierCreator

Defined in: src/prefix-manager.ts:395

Get GIAI creator.

Returns

NonNumericIdentifierCreator


gsrnCreator

Get Signature

get gsrnCreator(): NonGTINNumericIdentifierCreator

Defined in: src/prefix-manager.ts:402

Get GSRN creator.

Returns

NonGTINNumericIdentifierCreator


gdtiCreator

Get Signature

get gdtiCreator(): SerializableNumericIdentifierCreator

Defined in: src/prefix-manager.ts:409

Get GDTI creator.

Returns

SerializableNumericIdentifierCreator


gincCreator

Get Signature

get gincCreator(): NonNumericIdentifierCreator

Defined in: src/prefix-manager.ts:416

Get GINC creator.

Returns

NonNumericIdentifierCreator


gsinCreator

Get Signature

get gsinCreator(): NonGTINNumericIdentifierCreator

Defined in: src/prefix-manager.ts:423

Get GSIN creator.

Returns

NonGTINNumericIdentifierCreator


gcnCreator

Get Signature

get gcnCreator(): SerializableNumericIdentifierCreator

Defined in: src/prefix-manager.ts:430

Get GCN creator.

Returns

SerializableNumericIdentifierCreator


cpidCreator

Get Signature

get cpidCreator(): NonNumericIdentifierCreator

Defined in: src/prefix-manager.ts:437

Get CPID creator.

Returns

NonNumericIdentifierCreator


gmnCreator

Get Signature

get gmnCreator(): NonNumericIdentifierCreator

Defined in: src/prefix-manager.ts:444

Get GMN creator.

Returns

NonNumericIdentifierCreator

Methods

get()

static get(prefixType, prefix): PrefixManager

Defined in: src/prefix-manager.ts:241

Get a prefix manager.

Parameters

prefixType

PrefixType

Prefix type.

prefix

string

Prefix.

Returns

PrefixManager

Prefix manager with normalized prefix type and prefix.


resetTweakFactor()

resetTweakFactor(): void

Defined in: src/prefix-manager.ts:225

Reset the tweak factor to its default (numeric value of the GS1 Company Prefix preceded by '1').

Returns

void