This module provides a collection of DECAF record identifier type
definitions. It is not exhaustive and it will be improved on an ongoing
basis.
Typically, a DECAF record identifier is either number or string. Some DECAF
API endoints can consume string values even though a number is expected. We
are sticking here to the original type: No number | string definitions.
Methodologically, we are using a type trick to emulate newtypes in this
module: For example, DECAF artifact identifier type is defined as:
exporttypeDecafArtifactId = number & { readonly__tag: uniquesymbol };
In runtime, there is only a number. The & { readonly __tag: unique symbol }
is provided to the compiler to distinguish in between number identifier
values which are representing different DECAF record types.
The construction and deconstruction of DECAF record identifiers are done via,
respecively, mkDecafRecordId and unDecafRecordId:
constexampleDecafArtifactIdValue: number = unDecafRecordId(exampleDecafArtifactId); constexampleDecafArtifactId: DecafArtifactId = mkDecafRecordId(42); expect(exampleDecafArtifactIdValue).toBe(42);
constexampleDecafActionId: DecafActionId = mkDecafRecordId(42); constexampleDecafActionIdValue: number = unDecafRecordId(exampleDecafActionId); expect(exampleDecafActionIdValue).toBe(42);
This module provides a collection of DECAF record identifier type definitions. It is not exhaustive and it will be improved on an ongoing basis.
Typically, a DECAF record identifier is either number or string. Some DECAF API endoints can consume string values even though a number is expected. We are sticking here to the original type: No
number | string
definitions.Methodologically, we are using a type trick to emulate newtypes in this module: For example, DECAF artifact identifier type is defined as:
In runtime, there is only a number. The
& { readonly __tag: unique symbol }
is provided to the compiler to distinguish in betweennumber
identifier values which are representing different DECAF record types.The construction and deconstruction of DECAF record identifiers are done via, respecively,
mkDecafRecordId
andunDecafRecordId
:To re-iterate, the runtime representation is not affected by how DECAF record identifier types are defined: