UNPKG

angular-odata

Version:

Client side OData typescript library for Angular

1 lines 1.15 MB
{"version":3,"file":"angular-odata.mjs","sources":["../../../projects/angular-odata/src/lib/types.ts","../../../projects/angular-odata/src/lib/constants.ts","../../../projects/angular-odata/src/lib/helper.ts","../../../projects/angular-odata/src/lib/resources/query/builder.ts","../../../projects/angular-odata/src/lib/utils/dates.ts","../../../projects/angular-odata/src/lib/utils/durations.ts","../../../projects/angular-odata/src/lib/utils/enums.ts","../../../projects/angular-odata/src/lib/utils/types.ts","../../../projects/angular-odata/src/lib/utils/http.ts","../../../projects/angular-odata/src/lib/utils/objects.ts","../../../projects/angular-odata/src/lib/utils/odata.ts","../../../projects/angular-odata/src/lib/utils/strings.ts","../../../projects/angular-odata/src/lib/utils/urls.ts","../../../projects/angular-odata/src/lib/resources/query/expressions/base.ts","../../../projects/angular-odata/src/lib/schema/annotation.ts","../../../projects/angular-odata/src/lib/schema/element.ts","../../../projects/angular-odata/src/lib/utils/arraybuffers.ts","../../../projects/angular-odata/src/lib/schema/parsers/edm.ts","../../../projects/angular-odata/src/lib/schema/parsers/enum-type.ts","../../../projects/angular-odata/src/lib/schema/parsers/structured-type.ts","../../../projects/angular-odata/src/lib/schema/parsers/callable.ts","../../../projects/angular-odata/src/lib/schema/callable.ts","../../../projects/angular-odata/src/lib/schema/entity-set.ts","../../../projects/angular-odata/src/lib/schema/singleton.ts","../../../projects/angular-odata/src/lib/schema/entity-container.ts","../../../projects/angular-odata/src/lib/schema/enum-type.ts","../../../projects/angular-odata/src/lib/schema/structured-type.ts","../../../projects/angular-odata/src/lib/schema/schema.ts","../../../projects/angular-odata/src/lib/resources/query/expressions/count.ts","../../../projects/angular-odata/src/lib/resources/query/expressions/filter.ts","../../../projects/angular-odata/src/lib/resources/query/expressions/search.ts","../../../projects/angular-odata/src/lib/resources/query/expressions/apply.ts","../../../projects/angular-odata/src/lib/resources/query/expressions/orderby.ts","../../../projects/angular-odata/src/lib/resources/query/expressions/select.ts","../../../projects/angular-odata/src/lib/resources/query/expressions/expand.ts","../../../projects/angular-odata/src/lib/resources/query/expressions/syntax.ts","../../../projects/angular-odata/src/lib/resources/query/expressions/compute.ts","../../../projects/angular-odata/src/lib/resources/query/handlers.ts","../../../projects/angular-odata/src/lib/resources/query/options.ts","../../../projects/angular-odata/src/lib/resources/path/handlers.ts","../../../projects/angular-odata/src/lib/resources/path/segments.ts","../../../projects/angular-odata/src/lib/resources/request.ts","../../../projects/angular-odata/src/lib/resources/resource.ts","../../../projects/angular-odata/src/lib/resources/types/action.ts","../../../projects/angular-odata/src/lib/utils/arrays.ts","../../../projects/angular-odata/src/lib/resources/types/batch.ts","../../../projects/angular-odata/src/lib/resources/types/count.ts","../../../projects/angular-odata/src/lib/resources/types/function.ts","../../../projects/angular-odata/src/lib/resources/types/media.ts","../../../projects/angular-odata/src/lib/resources/types/value.ts","../../../projects/angular-odata/src/lib/resources/types/property.ts","../../../projects/angular-odata/src/lib/resources/types/reference.ts","../../../projects/angular-odata/src/lib/resources/types/navigation-property.ts","../../../projects/angular-odata/src/lib/resources/types/entity.ts","../../../projects/angular-odata/src/lib/resources/types/entity-set.ts","../../../projects/angular-odata/src/lib/metadata/csdl/csdl-annotation.ts","../../../projects/angular-odata/src/lib/metadata/csdl/csdl-reference.ts","../../../projects/angular-odata/src/lib/metadata/csdl/csdl-type-definition.ts","../../../projects/angular-odata/src/lib/metadata/csdl/csdl-enum-type.ts","../../../projects/angular-odata/src/lib/metadata/csdl/csdl-structural-property.ts","../../../projects/angular-odata/src/lib/metadata/csdl/csdl-structured-type.ts","../../../projects/angular-odata/src/lib/metadata/csdl/csdl-function-action.ts","../../../projects/angular-odata/src/lib/metadata/csdl/csdl-navigation-property-binding.ts","../../../projects/angular-odata/src/lib/metadata/csdl/csdl-entity-set.ts","../../../projects/angular-odata/src/lib/metadata/csdl/csdl-singleton.ts","../../../projects/angular-odata/src/lib/metadata/csdl/csdl-entity-container.ts","../../../projects/angular-odata/src/lib/metadata/csdl/csdl-schema.ts","../../../projects/angular-odata/src/lib/metadata/metadata.ts","../../../projects/angular-odata/src/lib/metadata/parser.ts","../../../projects/angular-odata/src/lib/resources/types/metadata.ts","../../../projects/angular-odata/src/lib/resources/types/singleton.ts","../../../projects/angular-odata/src/lib/annotations.ts","../../../projects/angular-odata/src/lib/resources/options.ts","../../../projects/angular-odata/src/lib/resources/response.ts","../../../projects/angular-odata/src/lib/models/collection.ts","../../../projects/angular-odata/src/lib/models/model.ts","../../../projects/angular-odata/src/lib/models/options.ts","../../../projects/angular-odata/src/lib/options.ts","../../../projects/angular-odata/src/lib/api.ts","../../../projects/angular-odata/src/lib/settings.ts","../../../projects/angular-odata/src/lib/loaders.ts","../../../projects/angular-odata/src/lib/client.ts","../../../projects/angular-odata/src/lib/services/base.ts","../../../projects/angular-odata/src/lib/services/entity.ts","../../../projects/angular-odata/src/lib/services/entity-set.ts","../../../projects/angular-odata/src/lib/services/singleton.ts","../../../projects/angular-odata/src/lib/services/factory.ts","../../../projects/angular-odata/src/lib/module.ts","../../../projects/angular-odata/src/lib/cache/cache.ts","../../../projects/angular-odata/src/lib/cache/memory.ts","../../../projects/angular-odata/src/lib/cache/storage.ts","../../../projects/angular-odata/src/public-api.ts","../../../projects/angular-odata/src/angular-odata.ts"],"sourcesContent":["import { Observable } from 'rxjs';\n\nexport type ODataVersion = '2.0' | '3.0' | '4.0';\nexport type FetchPolicy =\n | 'cache-first'\n | 'cache-and-network'\n | 'network-only'\n | 'no-cache'\n | 'cache-only';\nexport type ODataMetadataType = 'minimal' | 'full' | 'none';\nexport type CacheCacheability = 'public' | 'private' | 'no-cache' | 'no-store';\n\nexport enum PathSegment {\n batch = 'batch',\n metadata = 'metadata',\n entitySet = 'entitySet',\n singleton = 'singleton',\n type = 'type',\n property = 'property',\n navigationProperty = 'navigationProperty',\n reference = 'reference',\n value = 'value',\n count = 'count',\n function = 'function',\n action = 'action',\n}\n\nexport enum QueryOption {\n select = 'select',\n expand = 'expand',\n compute = 'compute',\n apply = 'apply',\n filter = 'filter',\n search = 'search',\n transform = 'transform',\n orderBy = 'orderBy',\n top = 'top',\n skip = 'skip',\n skiptoken = 'skiptoken',\n format = 'format',\n levels = 'levels',\n count = 'count',\n}\nexport enum EdmType {\n //Edm.Guid 16-byte (128-bit) unique identifier\n Guid = 'Edm.Guid',\n //Edm.Int16 Signed 16-bit integer\n Int16 = 'Edm.Int16',\n //Edm.String Sequence of UTF-8 characters\n String = 'Edm.String',\n //Edm.Boolean Binary-valued logic\n Boolean = 'Edm.Boolean',\n //Edm.Byte Unsigned 8-bit integer\n Byte = 'Edm.Byte',\n //Edm.SByte Signed 8-bit integer\n SByte = 'Edm.SByte',\n //Edm.Int32 Signed 16-bit integer\n Int32 = 'Edm.Int32',\n //Edm.Int64 Signed 16-bit integer\n Int64 = 'Edm.Int64',\n //Edm.Date Date without a time-zone offset\n Date = 'Edm.Date',\n //Edm.TimeOfDay Clock time 00:00-23:59:59.999999999999\n TimeOfDay = 'Edm.TimeOfDay',\n //Edm.DateTimeOffset Date and time with a time-zone offset, no leap seconds\n DateTimeOffset = 'Edm.DateTimeOffset',\n //Edm.Duration Signed duration in days, hours, minutes, and (sub)seconds\n Duration = 'Edm.Duration',\n //Edm.Decimal Numeric values with fixed precision and scale\n Decimal = 'Edm.Decimal',\n //Edm.Double IEEE 754 binary64 floating-point number (15-17 decimal digits)\n Double = 'Edm.Double',\n //Edm.Single IEEE 754 binary32 floating-point number (6-9 decimal digits)\n Single = 'Edm.Single',\n //Edm.Binary Binary data\n Binary = 'Edm.Binary',\n //Edm.Stream Binary data stream\n Stream = 'Edm.Stream',\n //Edm.Geography Abstract base type for all Geography types\n Geography = 'Edm.Geography',\n //Edm.GeographyPoint A point in a round-earth coordinate system\n GeographyPoint = 'Edm.GeographyPoint',\n //Edm.GeographyLineString Line string in a round-earth coordinate system\n GeographyLineString = 'Edm.GeographyLineString',\n //Edm.GeographyPolygon Polygon in a round-earth coordinate system\n GeographyPolygon = 'Edm.GeographyPolygon',\n //Edm.GeographyMultiPoint Collection of points in a round-earth coordinate system\n GeographyMultiPoint = 'Edm.GeographyMultiPoint',\n //Edm.GeographyMultiLineString Collection of line strings in a round-earth coordinate system\n GeographyMultiLineString = 'Edm.GeographyMultiLineString',\n //Edm.GeographyMultiPolygon Collection of polygons in a round-earth coordinate system\n GeographyMultiPolygon = 'Edm.GeographyMultiPolygon',\n //Edm.GeographyCollection Collection of arbitrary Geography values\n GeographyCollection = 'Edm.GeographyCollection',\n //Edm.Geometry Abstract base type for all Geometry types\n Geometry = 'Edm.Geometry',\n //Edm.GeometryPoint Point in a flat-earth coordinate system\n GeometryPoint = 'Edm.GeometryPoint',\n //Edm.GeometryLineString Line string in a flat-earth coordinate system\n GeometryLineString = 'Edm.GeometryLineString',\n //Edm.GeometryPolygon Polygon in a flat-earth coordinate system\n GeometryPolygon = 'Edm.GeometryPolygon',\n //Edm.GeometryMultiPoint Collection of points in a flat-earth coordinate system\n GeometryMultiPoint = 'Edm.GeometryMultiPoint',\n //Edm.GeometryMultiLineString Collection of line strings in a flat-earth coordinate system\n GeometryMultiLineString = 'Edm.GeometryMultiLineString',\n //Edm.GeometryMultiPolygon Collection of polygons in a flat-earth coordinate system\n GeometryMultiPolygon = 'Edm.GeometryMultiPolygon',\n //Edm.GeometryCollection Collection of arbitrary Geometry values\n GeometryCollection = 'Edm.GeometryCollection',\n}\n\nexport enum JsonType {\n string = 'string',\n number = 'number',\n integer = 'integer',\n object = 'object',\n array = 'array',\n boolean = 'boolean',\n null = 'null',\n}\n\nexport interface ParserOptions {\n version?: ODataVersion;\n exponentialDecimals?: boolean;\n metadata?: ODataMetadataType;\n ieee754Compatible?: boolean;\n streaming?: boolean;\n stringAsEnum?: boolean;\n deleteRefBy?: 'path' | 'id';\n nonParenthesisForEmptyParameterFunction?: boolean;\n}\n\nexport interface ResponseOptions extends ParserOptions {\n cacheability?: CacheCacheability;\n maxAge?: number;\n}\n\nexport interface StructuredTypeFieldOptions extends ParserOptions {\n field: ODataStructuredTypeFieldConfig;\n}\n\nexport interface Parser<T> {\n // Deserialize value/s from request body.\n deserialize(value: any, options?: ParserOptions | StructuredTypeFieldOptions): T | T[];\n // Serialize value/s for request body.\n serialize(value: T, options?: ParserOptions | StructuredTypeFieldOptions): any;\n //Encode value/s for URL parameter or query-string.\n encode(value: T, options?: ParserOptions | StructuredTypeFieldOptions): any;\n}\n\nexport interface FieldParser<T> extends Parser<T> {\n nullable?: boolean;\n default?: any;\n maxLength?: number;\n precision?: number;\n scale?: number | 'variable';\n}\n\nexport const NONE_PARSER = {\n deserialize: (value: any) => value,\n serialize: (value: any) => value,\n encode: (value: any) => value,\n} as Parser<any>;\n\nexport interface ODataCache {\n put<T>(key: string, payload: T, ...opts: any[]): void;\n get<T>(key: string, ...opts: any[]): T | undefined;\n handleRequest(req: any, res$: Observable<any>): Observable<any>;\n flush(): void;\n}\n\nexport interface ODataApiConfigOptions {\n version?: ODataVersion;\n params?: { [param: string]: string | string[] };\n headers?: { [param: string]: string | string[] };\n withCredentials?: boolean;\n //Headers\n accept?: {\n exponentialDecimals?: boolean;\n metadata?: ODataMetadataType;\n ieee754Compatible?: boolean;\n streaming?: boolean;\n };\n etag?: {\n ifMatch?: boolean;\n ifNoneMatch?: boolean;\n };\n prefer?: {\n maxPageSize?: number;\n return?: 'representation' | 'minimal';\n continueOnError?: boolean;\n includeAnnotations?: string;\n };\n stripMetadata?: ODataMetadataType;\n fetchPolicy?: FetchPolicy;\n bodyQueryOptions?: QueryOption[];\n stringAsEnum?: boolean;\n //https://github.com/OData/WebApi/issues/1974\n //https://github.com/OData/WebApi/issues/1647\n deleteRefBy?: 'path' | 'id';\n //https://github.com/OData/AspNetCoreOData/issues/171\n nonParenthesisForEmptyParameterFunction?: boolean;\n jsonBatchFormat?: boolean;\n relativeUrls?: boolean;\n}\n\n//#region Configs\nexport type ODataApiConfig = {\n serviceRootUrl: string;\n metadataUrl?: string;\n name?: string;\n version?: ODataVersion;\n default?: boolean;\n creation?: Date;\n cache?: ODataCache;\n errorHandler?: (error: any, caught: Observable<any>) => Observable<never>;\n options?: ODataApiConfigOptions;\n parsers?: { [type: string]: Parser<any> };\n schemas?: ODataSchemaConfig[];\n references?: ODataReferenceConfig[];\n};\nexport type ODataAnnotationConfig = {\n term: string;\n string?: string;\n bool?: boolean;\n int?: number;\n permissions?: string[];\n properties?: string[];\n};\nexport type ODataReferenceConfig = {\n uri: string;\n includes?: string;\n annotations?: ODataAnnotationConfig[];\n enums?: ODataEnumTypeConfig[];\n entities?: ODataStructuredTypeConfig[];\n callables?: ODataCallableConfig[];\n containers?: ODataEntityContainerConfig[];\n};\nexport type ODataSchemaConfig = {\n namespace: string;\n alias?: string;\n annotations?: ODataAnnotationConfig[];\n enums?: ODataEnumTypeConfig[];\n entities?: ODataStructuredTypeConfig[];\n callables?: ODataCallableConfig[];\n containers?: ODataEntityContainerConfig[];\n};\n\nexport type ODataEntityContainerConfig = {\n name: string;\n annotations?: ODataAnnotationConfig[];\n entitySets?: ODataEntitySetConfig[];\n singletons?: ODataSingletonConfig[];\n};\n\nexport type ODataEnumTypeFieldConfig = {\n value: number;\n annotations?: ODataAnnotationConfig[];\n};\n\nexport type ODataEnumTypeConfig = {\n name: string;\n flags?: boolean;\n annotations?: ODataAnnotationConfig[];\n members: { [name: string]: number } | { [value: number]: string };\n fields: { [member: string]: ODataEnumTypeFieldConfig };\n};\n\nexport type ODataStructuredTypeFieldConfig = {\n type: string;\n default?: any;\n maxLength?: number;\n key?: boolean;\n collection?: boolean;\n nullable?: boolean;\n navigation?: boolean;\n precision?: number;\n annotations?: ODataAnnotationConfig[];\n scale?: number | 'variable';\n referentials?: { property: string; referencedProperty: string }[];\n referential?: string;\n referenced?: string;\n};\n\nexport type ODataStructuredTypeConfig = {\n name: string;\n base?: string;\n open?: boolean;\n model?: { new (...params: any[]): any };\n collection?: { new (...params: any[]): any };\n annotations?: ODataAnnotationConfig[];\n keys?: { name: string; alias?: string }[];\n fields?: { [name: string]: ODataStructuredTypeFieldConfig };\n};\n\nexport type ODataParameterConfig = {\n type: string;\n nullable?: boolean;\n collection?: boolean;\n};\n\nexport type ODataCallableConfig = {\n name: string;\n entitySetPath?: string;\n bound?: boolean;\n composable?: boolean;\n parameters?: { [name: string]: ODataParameterConfig };\n return?: { type: string; collection?: boolean };\n};\n\nexport type ODataEntitySetConfig = {\n name: string;\n entityType: string;\n service: { new (...params: any[]): any };\n annotations?: ODataAnnotationConfig[];\n};\n\nexport type ODataSingletonConfig = {\n name: string;\n type: string;\n service: { new (...params: any[]): any };\n annotations?: ODataAnnotationConfig[];\n};\n//#endregion\n","export const $ID = '$id';\nexport const ODATA_ID = '@odata.id';\n\n// SEGMENTS\nexport const $METADATA = '$metadata';\nexport const $BATCH = '$batch';\nexport const $REF = '$ref';\nexport const $VALUE = '$value';\nexport const $COUNT = '$count';\nexport const $QUERY = '$query';\nexport const $INLINECOUNT = '$inlinecount';\n\n// HTTP HEADERS\nexport const IF_MATCH_HEADER = 'If-Match';\nexport const IF_NONE_MATCH_HEADER = 'If-None-Match';\nexport const CONTENT_TYPE = 'Content-Type';\nexport const HTTP11 = 'HTTP/1.1';\nexport const ACCEPT = 'Accept';\nexport const PREFER = 'Prefer';\nexport const CACHE_CONTROL = 'Cache-Control';\nexport const CACHE_CONTROL_HEADERS = [CACHE_CONTROL, CACHE_CONTROL.toLowerCase()];\nexport const ODATA_VERSION = 'OData-Version';\nexport const ODATA_VERSION_HEADERS = [\n ODATA_VERSION,\n ODATA_VERSION.toLowerCase(),\n 'dataserviceversion',\n];\nexport const LOCATION_HEADER = 'Location';\nexport const LOCATION_HEADERS = [LOCATION_HEADER, LOCATION_HEADER.toLowerCase()];\nexport const ODATA_ENTITYID = 'OData-EntityId';\nexport const ODATA_ENTITYID_HEADERS = [ODATA_ENTITYID, ODATA_ENTITYID.toLowerCase()];\nexport const PREFERENCE_APPLIED = 'Preference-Applied';\nexport const PREFERENCE_APPLIED_HEADERS = [PREFERENCE_APPLIED, PREFERENCE_APPLIED.toLowerCase()];\nexport const ETAG_HEADER = 'ETag';\nexport const ETAG_HEADERS = [ETAG_HEADER, ETAG_HEADER.toLowerCase()];\n\nexport const RETRY_AFTER = 'Retry-After';\nexport const RETRY_AFTER_HEADERS = [RETRY_AFTER, RETRY_AFTER.toLowerCase()];\n\n// HTTP HEADER VALUES\nexport const APPLICATION_JSON = 'application/json';\nexport const APPLICATION_HTTP = 'application/http';\nexport const APPLICATION_XHTML = 'application/xhtml+xml';\nexport const APPLICATION_XML = 'application/xml';\nexport const TEXT_PLAIN = 'text/plain';\nexport const CONTENT_TYPE_ANY = '*/*';\nexport const MULTIPART_MIXED = 'multipart/mixed';\nexport const MULTIPART_MIXED_BOUNDARY = 'multipart/mixed;boundary=';\nexport const CONTENT_TRANSFER_ENCODING = 'Content-Transfer-Encoding';\nexport const CONTENT_ID = 'Content-ID';\nexport const MAX_AGE = 'max-age';\n\n// VERSIONS\nexport const VERSION_4_0 = '4.0';\nexport const VERSION_3_0 = '3.0';\nexport const VERSION_2_0 = '2.0';\nexport const DEFAULT_VERSION = VERSION_4_0;\n\nexport const BINARY = 'binary';\nexport const BOUNDARY_PREFIX_SUFFIX = '--';\nexport const BATCH_PREFIX = 'batch_';\nexport const CHANGESET_PREFIX = 'changeset_';\nexport const DEFAULT_METADATA = 'minimal';\nexport const DEFAULT_STRIP_METADATA = 'full';\nexport const DEFAULT_FETCH_POLICY = 'network-only';\nexport const DEFAULT_TIMEOUT = 60; // Time in seconds\nexport const CALLABLE_BINDING_PARAMETER = 'bindingParameter';\nexport const XSSI_PREFIX = /^\\)\\]\\}',?\\n/;\n\n// URL PARTS\nexport const QUERY_SEPARATOR = '?';\nexport const PARAM_SEPARATOR = '&';\nexport const VALUE_SEPARATOR = '=';\nexport const PATH_SEPARATOR = '/';\nexport const ODATA_PARAM_PREFIX = '$';\nexport const ODATA_ALIAS_PREFIX = '@';\n\nexport const NEWLINE = '\\r\\n';\nexport const NEWLINE_REGEXP = /\\r?\\n/;\nexport const CACHE_KEY_SEPARATOR = ':';\n\n// Models\nexport const CID_FIELD_NAME = '_cid';\nexport const EVENT_SPLITTER = /\\s+/;\n\n// Standard vocabularies for annotating OData services\n// https://github.com/oasis-tcs/odata-vocabularies/blob/main/vocabularies/Org.OData.Core.V1.md\n\nexport const COMPUTED = /.*Computed$/;\nexport const OPTIMISTIC_CONCURRENCY = /.*OptimisticConcurrency$/;\nexport const DESCRIPTION = /.*Description$/;\nexport const LONG_DESCRIPTION = /.*LongDescription$/;\nexport const OPTIONARL_PARAMETER = /.*OptionalParameter$/;\n","import { VERSION_3_0, VERSION_2_0, VERSION_4_0, $COUNT, $INLINECOUNT } from './constants';\nimport { ODataMetadataType } from './types';\n\nexport const COLLECTION = /Collection\\(([\\w\\.]+)\\)/;\nexport const PROPERTY = /([\\w\\d\\-_]+)\\(([\\'\\w\\d\\-_=]+)\\)/;\nexport const EXPAND = /([\\w\\d\\-_]+)\\(([\\w\\d\\,\\(\\)]+)\\)/;\n\nexport type ODataContext = {\n serviceRootUrl?: string;\n metadataUrl?: string;\n entitySet?: string;\n key?: string;\n expand?: string;\n type?: string;\n property?: string;\n entity?: boolean;\n};\n\nexport interface ODataVersionHelper {\n VALUE: string;\n ODATA_ANNOTATION_PREFIX: string;\n ODATA_FUNCTION_PREFIX: string;\n ODATA_ID: string;\n ODATA_TYPE: string;\n ODATA_COUNT: string;\n ODATA_ETAG: string;\n ODATA_CONTEXT: string;\n ODATA_MEDIA_ETAG: string;\n ODATA_NEXTLINK: string;\n ODATA_DEFERRED: string;\n ODATA_ANNOTATION: string;\n\n entity(value: { [name: string]: any }): any;\n entities(value: { [name: string]: any }): any;\n property(value: { [name: string]: any }): any;\n annotations(value: { [name: string]: any }): Map<string, any>;\n attributes(value: { [name: string]: any }, metadata: ODataMetadataType): any;\n\n context(annots: Map<string, any> | { [name: string]: any }): ODataContext;\n id(annots: Map<string, any> | { [name: string]: any }): string | undefined;\n etag(annots: Map<string, any> | { [name: string]: any }): string | undefined;\n type(annots: Map<string, any> | { [name: string]: any }): string | undefined;\n count(annots: Map<string, any>): number | undefined;\n functions(annots: Map<string, any>): Map<string, any>;\n properties<T>(annots: Map<string, any>): Map<keyof T, Map<string, any>>;\n mediaEtag(annots: Map<string, any>): string | undefined;\n metadataEtag(annots: Map<string, any>): string | undefined;\n nextLink(annots: Map<string, any>): string | undefined;\n readLink(annots: Map<string, any>): string | undefined;\n mediaReadLink(annots: Map<string, any>): string | undefined;\n editLink(annots: Map<string, any>): string | undefined;\n mediaEditLink(annots: Map<string, any>): string | undefined;\n mediaContentType(annots: Map<string, any>): string | undefined;\n deltaLink(annots: Map<string, any>): string | undefined;\n countParam(): { [name: string]: string };\n}\n\nconst ODataVersionBaseHelper = <any>{\n entity(data: { [name: string]: any }) {\n return data;\n },\n entities(data: { [name: string]: any }) {\n return data[this.VALUE];\n },\n property(data: { [name: string]: any }) {\n return this.VALUE in data ? data[this.VALUE] : data;\n },\n functions(annots: Map<string, any>) {\n const funcs = new Map<string, any>();\n [...annots.keys()]\n .filter((key) => key.startsWith(this.ODATA_FUNCTION_PREFIX))\n .forEach((key) =>\n funcs.set(key.substring(this.ODATA_FUNCTION_PREFIX.length), annots.get(key)),\n );\n return funcs;\n },\n properties(annots: Map<string, any>) {\n const props = new Map<string, Map<string, any>>();\n [...annots.keys()]\n .filter((key) => key.indexOf(this.ODATA_ANNOTATION_PREFIX) > 0)\n .forEach((key) => {\n let name = key.substring(0, key.indexOf(this.ODATA_ANNOTATION_PREFIX));\n let prop = props.has(name) ? props.get(name)! : new Map<string, any>();\n prop.set(key.substring(key.indexOf(this.ODATA_ANNOTATION_PREFIX)), annots.get(key));\n props.set(name, prop);\n });\n return props;\n },\n id(annots: Map<string, any> | { [name: string]: any }) {\n return annots instanceof Map ? annots.get(this.ODATA_ID) : annots[this.ODATA_ID];\n },\n etag(annots: Map<string, any> | { [name: string]: any }) {\n return annots instanceof Map ? annots.get(this.ODATA_ETAG) : annots[this.ODATA_ETAG];\n },\n type(annots: Map<string, any> | { [name: string]: any }) {\n let type = annots instanceof Map ? annots.get(this.ODATA_TYPE) : annots[this.ODATA_TYPE];\n if (!type) return undefined;\n type = type.substring(1);\n const matches = COLLECTION.exec(type);\n if (matches) return matches[1].indexOf('.') === -1 ? `Edm.${matches[1]}` : matches[1];\n return type;\n },\n mediaEtag(annots: Map<string, any>) {\n return annots.has(this.ODATA_MEDIA_ETAG)\n ? decodeURIComponent(annots.get(this.ODATA_MEDIA_ETAG) as string)\n : undefined;\n },\n metadataEtag(annots: Map<string, any>) {\n return annots.has(this.ODATA_METADATA_ETAG)\n ? decodeURIComponent(annots.get(this.ODATA_METADATA_ETAG) as string)\n : undefined;\n },\n count(annots: Map<string, any>) {\n return annots.has(this.ODATA_COUNT) ? Number(annots.get(this.ODATA_COUNT)) : undefined;\n },\n annotations(value: { [name: string]: any }) {\n const annots = new Map<string, any>();\n Object.entries(value)\n .filter(\n ([key]) =>\n key.indexOf(this.ODATA_ANNOTATION_PREFIX) !== -1 ||\n key.startsWith(this.ODATA_FUNCTION_PREFIX),\n )\n .forEach(([key, value]) => annots.set(key, value));\n return annots;\n },\n attributes(value: { [name: string]: any }, metadata: ODataMetadataType) {\n return Object.entries(value)\n .filter(\n ([k]) =>\n metadata === 'none' ||\n (metadata === 'minimal' &&\n (k.indexOf(this.ODATA_ANNOTATION_PREFIX) === -1 ||\n k.startsWith(this.ODATA_ANNOTATION_PREFIX)) &&\n !k.startsWith(this.ODATA_FUNCTION_PREFIX)) ||\n (metadata === 'full' &&\n k.indexOf(this.ODATA_ANNOTATION_PREFIX) === -1 &&\n !k.startsWith(this.ODATA_FUNCTION_PREFIX)),\n )\n .reduce((acc, e) => ({ ...acc, [e[0]]: e[1] }), {});\n },\n nextLink(annots: Map<string, any>) {\n return annots.has(this.ODATA_NEXTLINK)\n ? decodeURIComponent(annots.get(this.ODATA_NEXTLINK) as string)\n : undefined;\n },\n readLink(annots: Map<string, any>) {\n return annots.has(this.ODATA_READLINK)\n ? decodeURIComponent(annots.get(this.ODATA_READLINK) as string)\n : undefined;\n },\n mediaReadLink(annots: Map<string, any>) {\n return annots.has(this.ODATA_MEDIA_READLINK)\n ? decodeURIComponent(annots.get(this.ODATA_MEDIA_READLINK) as string)\n : undefined;\n },\n editLink(annots: Map<string, any>) {\n return annots.has(this.ODATA_EDITLINK)\n ? decodeURIComponent(annots.get(this.ODATA_EDITLINK) as string)\n : undefined;\n },\n mediaEditLink(annots: Map<string, any>) {\n return annots.has(this.ODATA_MEDIA_EDITLINK)\n ? decodeURIComponent(annots.get(this.ODATA_MEDIA_EDITLINK) as string)\n : undefined;\n },\n deltaLink(annots: Map<string, any>) {\n return annots.has(this.ODATA_DELTALINK)\n ? decodeURIComponent(annots.get(this.ODATA_DELTALINK) as string)\n : undefined;\n },\n mediaContentType(annots: Map<string, any>) {\n return annots.has(this.ODATA_MEDIA_CONTENTTYPE)\n ? decodeURIComponent(annots.get(this.ODATA_MEDIA_CONTENTTYPE) as string)\n : undefined;\n },\n};\n\nexport const ODataHelper = {\n //#region Version 4.0\n [VERSION_4_0]: <ODataVersionHelper>{\n ...ODataVersionBaseHelper,\n VALUE: 'value',\n ODATA_ANNOTATION_PREFIX: '@odata',\n ODATA_FUNCTION_PREFIX: '#',\n //odata.id: the ID of the entity\n ODATA_ID: '@odata.id',\n //odata.count: the total count of a collection of entities or collection of entity references, if requested.\n ODATA_COUNT: '@odata.count',\n //odata.context: the context URL for a collection, entity, primitive value, or service document.\n ODATA_CONTEXT: '@odata.context',\n //odata.etag: the ETag of the entity\n ODATA_ETAG: '@odata.etag',\n ODATA_METADATA_ETAG: '@odata.metadataEtag',\n //odata.type: the type of the containing {[name: string]: any} or targeted property if the type of the {[name: string]: any} or targeted property cannot be heuristically determined\n ODATA_TYPE: '@odata.type',\n //odata.delta\n ODATA_DELTA: '@odata.delta',\n //odata.remove\n ODATA_REMOVE: '@odata.remove',\n //odata.nextLink: the next link of a collection with partial results\n ODATA_NEXTLINK: '@odata.nextLink',\n //odata.deltaLink: the delta link for obtaining changes to the result, if requested\n ODATA_DELTALINK: '@odata.deltaLink',\n //odata.readLink: the link used to read the entity, if the edit link cannot be used to read the entity\n ODATA_READLINK: '@odata.readLink',\n //odata.editLink: the link used to edit/update the entity, if the entity is updatable and the odata.id does not represent a URL that can be used to edit the entity\n ODATA_EDITLINK: '@odata.editLink',\n //odata.associationLink: the link used to describe the relationship between this entity and related entities\n ODATA_ASSOCIATIONLINK: '@odata.associationLink',\n //odata.navigationLink: the link used to retrieve the values of a navigation property\n ODATA_NAVIGATIONLINK: '@odata.navigationLink',\n //Media entities and stream properties may in addition contain the following annotations:\n //odata.mediaEtag: the ETag of the stream, as appropriate\n ODATA_MEDIA_ETAG: '@odata.mediaEtag',\n //odata.mediaContentType: the content type of the stream\n ODATA_MEDIA_CONTENTTYPE: '@odata.mediaContentType',\n //odata.mediaReadLink: the link used to read the stream\n ODATA_MEDIA_READLINK: '@odata.mediaReadLink',\n //odata.mediaEditLink: the link used to edit/update the stream\n ODATA_MEDIA_EDITLINK: '@odata.mediaEditLink',\n //http://nb-mdp-dev01:57970/$metadata#recursos/$entity\n //http://nb-mdp-dev01:57970/$metadata#categorias\n //http://nb-mdp-dev01:57970/$metadata#juzgados\n //http://nb-mdp-dev01:57970/$metadata#Collection(SIU.Recursos.RecursoEntry)\n //http://nb-mdp-dev01:57970/$metadata#categorias/$entity\n //http://nb-mdp-dev01:57970/$metadata#categorias(children(children(children(children(children(children(children(children(children(children()))))))))))/$entity\n //http://nb-mdp-dev01:57970/$metadata#recursos/SIU.Documentos.Documento/$entity\n //http://nb-mdp-dev01:57970/$metadata#SIU.Api.Infrastructure.Storage.Backend.SiuUrls\n context(annots: Map<string, any> | { [name: string]: any }) {\n let ctx: ODataContext = {};\n const str =\n annots instanceof Map ? annots.get(this.ODATA_CONTEXT) : annots[this.ODATA_CONTEXT];\n if (typeof str === 'string') {\n let index = str.indexOf('$metadata');\n ctx.serviceRootUrl = str.substring(0, index);\n index = str.indexOf('#');\n ctx.metadataUrl = str.substring(0, index);\n const parts = str.substring(index + 1).split('/');\n const col = COLLECTION.exec(parts[0]);\n if (col) {\n ctx.type = col[1];\n } else if (parts[0].indexOf('.') !== -1) {\n ctx.type = parts[0];\n } else {\n const property = parts[0].match(PROPERTY);\n const expand = parts[0].match(EXPAND);\n ctx.entity = parts[1] === '$entity';\n if (property) {\n ctx.entitySet = property[1];\n ctx.key = property[2];\n ctx.property = parts[1];\n } else if (expand) {\n ctx.entitySet = expand[1];\n ctx.expand = expand[2];\n } else {\n ctx.entitySet = parts[0];\n }\n }\n }\n return ctx;\n },\n countParam() {\n return { [$COUNT]: 'true' };\n },\n },\n //#endregion\n //#region Version 3.0\n [VERSION_3_0]: <ODataVersionHelper>{\n ...ODataVersionBaseHelper,\n ODATA_ANNOTATION_PREFIX: 'odata.',\n ODATA_FUNCTION_PREFIX: '',\n ODATA_ID: 'odata.id',\n ODATA_DELTA: 'odata.delta',\n ODATA_REMOVE: 'odata.remove',\n ODATA_ETAG: 'odata.etag',\n ODATA_CONTEXT: 'odata.metadata',\n ODATA_NEXTLINK: 'odata.nextLink',\n ODATA_TYPE: 'odata.type',\n ODATA_COUNT: 'odata.count',\n VALUE: 'value',\n context(annots: Map<string, any> | { [name: string]: any }) {\n let ctx: ODataContext = {};\n const str =\n annots instanceof Map ? annots.get(this.ODATA_CONTEXT) : annots[this.ODATA_CONTEXT];\n if (typeof str === 'string') {\n let index = str.indexOf('$metadata');\n ctx.serviceRootUrl = str.substring(0, index);\n index = str.indexOf('#');\n ctx.metadataUrl = str.substring(0, index);\n const parts = str.substring(index + 1).split('/');\n ctx.entitySet = parts[0];\n }\n return ctx;\n },\n countParam() {\n return { [$INLINECOUNT]: 'allpages' };\n },\n },\n //#endregion\n //#region Version 2.0\n [VERSION_2_0]: <ODataVersionHelper>{\n ...ODataVersionBaseHelper,\n ODATA_ID: 'id',\n ODATA_DELTA: 'delta',\n ODATA_REMOVE: 'remove',\n ODATA_ETAG: 'etag',\n ODATA_ANNOTATION: '__metadata',\n ODATA_NEXTLINK: '__next',\n ODATA_COUNT: '__count',\n ODATA_DEFERRED: '__deferred',\n ODATA_TYPE: 'type',\n VALUE: 'results',\n annotations(value: { [name: string]: any }) {\n const annots = new Map<string, any>();\n if (this.ODATA_ANNOTATION in value) {\n Object.entries(value[this.ODATA_ANNOTATION]).forEach(([key, value]) =>\n annots.set(key, value),\n );\n }\n return annots;\n },\n context(annots: Map<string, any> | { [name: string]: any }) {\n let ctx: ODataContext = {};\n return ctx;\n },\n attributes(value: { [name: string]: any }, metadata: ODataMetadataType) {\n return value;\n },\n countParam() {\n return { [$INLINECOUNT]: 'allpages' };\n },\n },\n //#endregion\n};\n","const COMPARISON_OPERATORS = ['eq', 'ne', 'gt', 'ge', 'lt', 'le'];\nconst LOGICAL_OPERATORS = ['and', 'or', 'not'];\nconst COLLECTION_OPERATORS = ['any', 'all'];\nconst BOOLEAN_FUNCTIONS = ['startswith', 'endswith', 'contains'];\nconst SUPPORTED_EXPAND_PROPERTIES = [\n 'expand',\n 'levels',\n 'select',\n 'top',\n 'count',\n 'orderby',\n 'filter',\n];\n\nconst FUNCTION_REGEX = /\\((.*)\\)/;\nconst INDEXOF_REGEX = /(?!indexof)\\((\\w+)\\)/;\n\nexport type LooseUnion<U> = U | (U extends string ? Record<never, never> & string : never);\nexport type ObjectValues<T> = T[keyof T];\nexport type Unpacked<T> = NonNullable<T> extends (infer U)[] ? U : NonNullable<T>;\nexport type Select<T> = SelectType<T> | SelectType<T>[];\nexport type SelectType<T> = LooseUnion<keyof T>;\nexport type Filter<T> = FilterType<T> | FilterType<T>[];\nexport type FilterType<T> = string | Record<string | keyof T, any>;\n\nexport const StandardAggregateMethods = {\n sum: 'sum',\n min: 'min',\n max: 'max',\n average: 'average',\n countdistinct: 'countdistinct'\n} as const;\nexport type StandardAggregateMethods = ObjectValues<typeof StandardAggregateMethods>;\nexport type AggregateType<T> =\n string | Record<string | keyof T, { with: StandardAggregateMethods; as: string }>;\n\n// OrderBy\n\nexport type OrderBy<T> = OrderByType<T> | OrderByType<T>[];\nexport type OrderByType<T> = LooseUnion<OrderByObject<T>>;\nexport type OrderByObject<T> = keyof T | [keyof T | string, 'asc' | 'desc'] | NestedOrderBy<T>;\nexport type NestedOrderBy<T> = {\n [P in keyof T]?: T[P] extends Array<infer E> ? OrderBy<E> : OrderBy<T[P]>;\n};\n\n// Expand\nexport type Expand<T> = ExpandType<T> | ExpandType<T>[];\nexport type ExpandType<T> = LooseUnion<ExpandObject<T>>;\nexport type ExpandObject<T> = keyof T | NestedExpandOptions<T>;\nexport type NestedExpandOptions<T> = {\n [P in keyof T]?: ExpandOptions<Unpacked<T[P]>>;\n};\nexport type ExpandOptions<T> = {\n select?: Select<T>;\n filter?: Filter<T>;\n orderBy?: OrderBy<T>;\n top?: number;\n skip?: number;\n levels?: number | 'max';\n count?: boolean | Filter<T>;\n expand?: Expand<T>;\n};\n\nexport type Transform<T> = {\n aggregate?: AggregateType<T> | Array<AggregateType<T>>;\n filter?: Filter<T> | null;\n groupBy?: GroupByType<T>;\n};\nexport type GroupByType<T> = {\n properties: Array<LooseUnion<keyof T>>;\n transform?: Transform<T>;\n};\n\nexport const QueryCustomTypes = {\n Raw: 'Raw',\n Alias: 'Alias',\n Duration: 'Duration',\n Binary: 'Binary'\n} as const;\nexport type QueryCustomTypes = ObjectValues<typeof QueryCustomTypes>;\n\nexport type QueryCustomType = {\n type: QueryCustomTypes;\n value: any;\n name?: string;\n};\nexport type Value = string | Date | number | boolean | QueryCustomType;\n\n//https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_QueryOptions\nexport const raw = (value: string): QueryCustomType => ({\n type: QueryCustomTypes.Raw,\n value,\n});\nexport const alias = (value: any, name?: string): QueryCustomType => ({\n type: QueryCustomTypes.Alias,\n value,\n name,\n});\nexport const duration = (value: string): QueryCustomType => ({\n type: QueryCustomTypes.Duration,\n value,\n});\nexport const binary = (value: string): QueryCustomType => ({\n type: QueryCustomTypes.Binary,\n value,\n});\nexport const isQueryCustomType = (value: any) =>\n typeof value === 'object' && 'type' in value && value.type in QueryCustomTypes;\n\nexport const isRawType = (value: any) =>\n isQueryCustomType(value) && (value as QueryCustomType).type === QueryCustomTypes.Raw;\n\nexport type QueryOptions<T> = ExpandOptions<T> & {\n search: string;\n apply: string;\n transform: Transform<T> | Transform<T>[];\n compute: string;\n skip: number;\n skiptoken: string;\n key: string | number | Record<string | keyof T, any>;\n count: boolean | Filter<T>;\n action: string;\n func: string | { [functionName: string]: { [parameterName: string]: any } };\n format: string;\n aliases: QueryCustomType[];\n escape: boolean;\n};\n\nexport const ITEM_ROOT = '';\n\nexport default function <T>({\n select,\n search,\n skiptoken,\n format,\n top,\n skip,\n filter,\n transform,\n compute,\n orderBy,\n key,\n count,\n expand,\n action,\n func,\n aliases,\n escape,\n}: Partial<QueryOptions<T>> = {}) {\n const [path, params] = buildPathAndQuery({\n select,\n search,\n skiptoken,\n format,\n top,\n skip,\n filter,\n transform,\n compute,\n orderBy,\n key,\n count,\n expand,\n action,\n func,\n aliases,\n escape,\n });\n\n return buildUrl(path, params);\n}\n\nexport function buildPathAndQuery<T>({\n select,\n search,\n skiptoken,\n format,\n top,\n skip,\n filter,\n apply,\n transform,\n compute,\n orderBy,\n key,\n count,\n expand,\n action,\n func,\n aliases,\n escape,\n}: Partial<QueryOptions<T>> = {}): [string, { [name: string]: any }] {\n let path: string = '';\n aliases = aliases || [];\n\n const query: any = {};\n\n // key is not (null, undefined)\n if (key != undefined) {\n path += `(${normalizeValue(key as Value, { aliases, escape })})`;\n }\n\n // Select\n if (select) {\n query.$select = isRawType(select)\n ? (select as unknown as QueryCustomType).value\n : Array.isArray(select)\n ? select.join(',')\n : select;\n }\n\n // Compute\n if (compute) {\n query.$compute = isRawType(compute)\n ? (compute as unknown as QueryCustomType).value\n : Array.isArray(compute)\n ? compute.join(',')\n : compute;\n }\n\n // Search\n if (search) {\n query.$search = search;\n }\n\n // Skiptoken\n if (skiptoken) {\n query.$skiptoken = skiptoken;\n }\n\n // Format\n if (format) {\n query.$format = format;\n }\n\n // Filter\n if (filter || typeof count === 'object') {\n query.$filter = buildFilter(typeof count === 'object' ? count : filter, {\n aliases,\n escape,\n });\n }\n\n // Transform\n if (transform) {\n query.$apply = buildTransforms(transform, { aliases, escape });\n }\n\n // Apply\n if (apply) {\n query.$apply = query.$apply\n ? query.$apply + '/' + buildApply(apply, { aliases, escape })\n : buildApply(apply, { aliases, escape });\n }\n\n // Expand\n if (expand) {\n query.$expand = buildExpand(expand, { aliases, escape });\n }\n\n // OrderBy\n if (orderBy) {\n query.$orderby = buildOrderBy(orderBy);\n }\n\n // Count\n if (isRawType(count)) {\n query.$count = (count as QueryCustomType).value;\n } else if (typeof count === 'boolean') {\n query.$count = true;\n } else if (count) {\n path += '/$count';\n }\n\n // Top\n if (isRawType(top)) {\n query.$top = (top as unknown as QueryCustomType).value;\n } else if (typeof top === 'number') {\n query.$top = top;\n }\n\n // Skip\n if (isRawType(skip)) {\n query.$top = (skip as unknown as QueryCustomType).value;\n } else if (typeof skip === 'number') {\n query.$skip = skip;\n }\n\n if (action) {\n path += `/${action}`;\n }\n\n if (func) {\n if (typeof func === 'string') {\n path += `/${func}()`;\n } else if (typeof func === 'object') {\n const [funcName] = Object.keys(func);\n const funcArgs = normalizeValue(func[funcName] as Value, {\n aliases,\n escape,\n });\n\n path += `/${funcName}(${funcArgs})`;\n }\n }\n\n if (aliases.length > 0) {\n Object.assign(\n query,\n aliases.reduce(\n (acc, alias) =>\n Object.assign(acc, {\n [`@${alias.name}`]: normalizeValue(alias.value, {\n escape,\n }),\n }),\n {},\n ),\n );\n }\n\n // Filter empty values\n const params = Object.entries(query)\n .filter(([, value]) => value !== undefined && value !== '')\n .reduce((acc, [key, value]) => Object.assign(acc, { [key]: value }), {});\n\n return [path, params];\n}\n\nfunction renderPrimitiveValue(\n key: string,\n val: any,\n {\n aliases,\n escape,\n }: {\n aliases?: QueryCustomType[];\n escape?: boolean;\n },\n) {\n return `${key} eq ${normalizeValue(val, { aliases, escape })}`;\n}\n\nfunction buildFilter(\n filters: Filter<any> = {},\n {\n aliases,\n propPrefix,\n escape,\n }: { aliases?: QueryCustomType[]; propPrefix?: string; escape?: boolean },\n): string {\n return (\n (Array.isArray(filters) ? filters : [filters]).reduce((acc: string[], filter) => {\n if (filter) {\n const builtFilter = buildFilterCore(filter, {\n aliases,\n propPrefix,\n escape,\n });\n if (builtFilter) {\n acc.push(builtFilter);\n }\n }\n return acc;\n }, []) as string[]\n ).join(' and ');\n\n function buildFilterCore(\n filter: Filter<any> = {},\n {\n aliases,\n propPrefix,\n escape,\n }: { aliases?: QueryCustomType[]; propPrefix?: string; escape?: boolean },\n ) {\n let filterExpr = '';\n if (isRawType(filter)) {\n // Use raw query custom filter string\n filterExpr = (filter as QueryCustomType).value;\n } else if (typeof filter === 'string') {\n // Use raw filter string\n filterExpr = filter;\n } else if (filter && typeof filter === 'object') {\n const filtersArray = Object.keys(filter).reduce((result: any[], filterKey) => {\n const value = (filter as any)[filterKey];\n let propName = '';\n if (propPrefix) {\n if (filterKey === ITEM_ROOT) {\n propName = propPrefix;\n } else if (INDEXOF_REGEX.test(filterKey)) {\n propName = filterKey.replace(INDEXOF_REGEX, (_, $1) =>\n $1.trim() === ITEM_ROOT ? `(${propPrefix})` : `(${propPrefix}/${$1.trim()})`,\n );\n } else if (FUNCTION_REGEX.test(filterKey)) {\n propName = filterKey.replace(FUNCTION_REGEX, (_, $1) =>\n $1.trim() === ITEM_ROOT ? `(${propPrefix})` : `(${propPrefix}/${$1.trim()})`,\n );\n } else {\n propName = `${propPrefix}/${filterKey}`;\n }\n } else {\n propName = filterKey;\n }\n\n if (filterKey === ITEM_ROOT && Array.isArray(value)) {\n return result.concat(\n value.map((arrayValue: any) =>\n renderPrimitiveValue(propName, arrayValue, { escape, aliases }),\n ),\n );\n }\n\n if (\n ['number', 'string', 'boolean'].indexOf(typeof value) !== -1 ||\n value instanceof Date ||\n value === null\n ) {\n // Simple key/value handled as equals operator\n result.push(renderPrimitiveValue(propName, value, { aliases, escape }));\n } else if (Array.isArray(value)) {\n const op = filterKey;\n const builtFilters = value\n .map((v) => buildFilter(v, { aliases, propPrefix, escape }))\n .filter((f) => f)\n .map((f) => (LOGICAL_OPERATORS.indexOf(op) !== -1 ? `(${f})` : f));\n if (builtFilters.length) {\n if (LOGICAL_OPERATORS.indexOf(op) !== -1) {\n if (builtFilters.length) {\n if (op === 'not') {\n result.push(parseNot(builtFilters as string[]));\n } else {\n result.push(`(${builtFilters.join(` ${op} `)})`);\n }\n }\n } else {\n result.push(builtFilters.join(` ${op} `));\n }\n }\n } else if (LOGICAL_OPERATORS.indexOf(propName) !== -1) {\n const op = propName;\n const builtFilters = Object.keys(value).map((valueKey) =>\n buildFilterCore({ [valueKey]: value[valueKey] }, { aliases, escape }),\n );\n if (builtFilters.length) {\n if (op === 'not') {\n result.push(parseNot(builtFilters as string[]));\n } else {\n result.push(`${builtFilters.join(` ${op} `)}`);\n }\n }\n } else if (typeof value === 'object') {\n if ('type' in value) {\n result.push(renderPrimitiveValue(propName, value, { aliases, escape }));\n } else {\n const operators = Object.keys(value);\n operators.forEach((op) => {\n if (COMPARISON_OPERATORS.indexOf(op) !== -1) {\n result.push(\n `${propName} ${op} ${normalizeValue(value[op], {\n aliases,\n escape,\n })}`,\n );\n } else if (LOGICAL_OPERATORS.indexOf(op) !== -1) {\n if (Array.isArray(value[op])) {\n result.push(\n value[op]\n .map(\n (v: any) =>\n '(' +\n buildFilterCore(v, {\n aliases,\n propPrefix: propName,\n escape,\n }) +\n ')',\n )\n .join(` ${op} `),\n );\n } else {\n result.push(\n '(' +\n buildFilterCore(value[op], {\n aliases,\n propPrefix: propName,\n escape,\n }) +\n ')',\n );\n }\n } else if (COLLECTION_OPERATORS.indexOf(op) !== -1) {\n const collectionClause = buildCollectionClause(\n filterKey.toLowerCase(),\n value[op],\n op,\n propName,\n );\n if (collectionClause) {\n result.push(collectionClause);\n }\n } else if (op === 'has') {\n result.push(\n `${propName} ${op} ${normalizeValue(value[op], {\n aliases,\n escape,\n })}`,\n );\n } else if (op === 'in') {\n const resultingValues = Array.isArray(value[op])\n ? value[op]\n : value[op].value.map((typedValue: any) => ({\n type: value[op].type,\n value: typedValue,\n }));\n\n result.push(\n propName +\n ' in (' +\n resultingValues\n .map((v: any) => normalizeValue(v, { aliases, escape }))\n .join(',') +\n ')',\n );\n } else if (BOOLEAN_FUNCTIONS.indexOf(op) !== -1) {\n // Simple boolean functions (startswith, endswith, contains)\n result.push(\n `${op}(${propName},${normalizeValue(value[op], {\n aliases,\n escape,\n })})`,\n );\n } else {\n // Nested property\n const filter = buildFilterCore(value, {\n aliases,\n propPrefix: propName,\n escape,\n });\n if (filter) {\n result.push(filter);\n }\n }\n });\n }\n } else if (value === undefined) {\n // Ignore/omit filter if value is `undefined`\n } else {\n throw new Error(`Unexpected value type: ${value}`);\n }\n\n return result;\n }, []);\n\n filterExpr = filtersArray.join(' and ');\n } /* else {\n throw new Error(`Unexpected filters type: ${filter}`);\n } */\n return filterExpr;\n }\n\n function buildCollectionClause(\n lambdaParameter: string,\n value: any,\n op: string,\n propName: string,\n ) {\n let clause = '';\n\n if (typeof value === 'string' || value instanceof String) {\n