Page MenuHomeSealhub

uuid.ts
No OneTemporary

import { v4 as uuid } from "uuid";
import Field, { ValidationResult } from "../../../chip-types/field.js";
import type Context from "../../../context.js";
export class Uuid extends Field<string> {
typeName = "uuid";
async hasIndex(): Promise<boolean> {
return true;
}
isOldValueSensitive = (): boolean => true;
async isProperValue(): Promise<ValidationResult> {
return Field.valid();
}
async encode(_: Context, __: unknown, old_value: string): Promise<string> {
const ret = old_value ? old_value : uuid();
return ret;
}
async getMatchQueryValue(
context: Context,
filter: string
): Promise<string> {
return filter;
}
async decode(_: Context, value: string): Promise<string> {
return value;
}
async filterToQuery(
_: Context,
filter: unknown
): Promise<{
$eq: unknown;
}> {
return { $eq: filter };
}
async getDefaultValue(): Promise<string> {
return uuid();
}
}

File Metadata

Mime Type
text/x-java
Expires
Sat, Nov 23, 17:32 (1 d, 16 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
548011
Default Alt Text
uuid.ts (915 B)

Event Timeline