import { process } from 'gremlin'; import { NonEmpty } from './NonEmpty'; import Step, { ExtractStepValue } from './Step'; import ProjectStep from './ProjectStep'; import IdStep from './IdStep'; import LabelStep from './LabelStep'; import GroupByStep from './GroupByStep'; declare type GraphTraversal = process.GraphTraversal; export declare const ANY_PROPERTY: unique symbol; export declare const NO_PROPERTY: unique symbol; export declare const NO_PROPERTIES: { readonly [K: string]: never; }; declare type PrimitivePropertyDefinitionCombo = `${A} | ${B}` | `${B} | ${A}`; declare type PrimitivePropertyDefinition = 'boolean' | 'string' | 'number' | PrimitivePropertyDefinitionCombo<'boolean', 'number'> | PrimitivePropertyDefinitionCombo<'boolean', 'string'> | PrimitivePropertyDefinitionCombo<'string', 'number'> | PrimitivePropertyDefinitionCombo<'string', PrimitivePropertyDefinitionCombo<'boolean', 'number'>> | PrimitivePropertyDefinitionCombo<'number', PrimitivePropertyDefinitionCombo<'boolean', 'string'>> | PrimitivePropertyDefinitionCombo<'boolean', PrimitivePropertyDefinitionCombo<'string', 'number'>>; declare type EnumPropertyDefinition = Record; export declare type NonOptionalPropertyDefinition = PrimitivePropertyDefinition | EnumPropertyDefinition; export declare type PropertyDefinition = NonOptionalPropertyDefinition | OptionalPropertyDefinition; export declare type Definition = { readonly [K: string]: PropertyDefinition; readonly [ANY_PROPERTY]?: NonOptionalPropertyDefinition; }; declare type PrimitivePropertySingle

= P extends 'boolean' ? boolean : P extends 'string' ? string : P extends 'number' ? number : never; declare type AllPropertyTypes = PrimitivePropertySingle; declare type PrimitiveProperty = S extends `${infer T} | ${infer U}` ? PrimitivePropertySingle | PrimitiveProperty : PrimitivePropertySingle; declare type NonOptionalProperty

= P extends EnumPropertyDefinition ? P[keyof P] : PrimitiveProperty

; export declare type Property

= P extends NonOptionalPropertyDefinition ? NonOptionalProperty

: P extends OptionalPropertyDefinition ? X extends NonOptionalPropertyDefinition ? NonOptionalProperty | OptionalType : never : never; declare type Properties = { [K in Extract]: Property | AdditionalAllowedValues; }; declare type AnyProperties = D[typeof ANY_PROPERTY] extends NonOptionalPropertyDefinition ? T & Record, NonOptionalProperty | AdditionalTypes> : Record, never>; export declare type Output = Properties & AnyProperties, D, never>; export declare type Find = Partial> & AnyProperties; export declare type Update = Partial> & AnyProperties; export declare type Insert = Properties & AnyProperties; declare type Value = { readonly [K in Extract]: () => PropertyValue; } & { readonly [K: string]: D[typeof ANY_PROPERTY] extends NonOptionalPropertyDefinition ? () => PropertyValue : never; }; export declare type Id = string | number; export declare abstract class Queryable extends Step> { readonly properties: D; readonly value: Value; protected constructor(q: GraphTraversal, properties: D, _ts?: D); fetchOne(): Promise>; fetchAll(): Promise[]>; project(map: { [K in keyof M]: (_: this) => Step; }): ProjectStep; groupBy, ValueStep extends Step, KeyType = ExtractStepValue, ValueType = ExtractStepValue>(key: (_: this) => KeyStep, value: (_: this) => ValueStep): GroupByStep; id(): IdStep; label(): LabelStep; byId(ids: NonEmpty): this; find(filter?: Find): this; update(properties: Update): this; deserialize(v: unknown): Output; protected setProperties(properties: Record, dropOnNoProperty: boolean): this; protected abstract setProperty(property: K, value: unknown): void; private deserializeAndAddAnyProperties; private fetch; } export declare class OptionalPropertyDefinition { readonly type: T; constructor(type: T); } export declare const optional: (type: T) => OptionalPropertyDefinition; export declare class PropertyValue extends Step> { private readonly queryableName; private readonly propertiesDefinition; private readonly definitionProperty; private requestedProperty; constructor(g: GraphTraversal, queryableName: string, propertiesDefinition: D, definitionProperty: K, requestedProperty: string); deserialize(raw: unknown): Property; } export {};