import { Effect } from "@effect/io/Effect"; import { Chunk } from "@fp-ts/data/Chunk"; import { Opt } from "@effect-ts-app/core/Option"; import { NonEmptyReadonlyArray } from "@fp-ts/data/ReadonlyArray"; import { ROMap } from "@effect-ts-app/boilerplate-prelude"; import { Tag } from "@fp-ts/data/Context"; import { ConfigSecret } from "@effect/io/Config/Secret"; import type { UniqueKey } from "@azure/cosmos"; import type { ParserEnv } from "@effect-ts-app/schema/custom/Parser"; import type { OptimisticConcurrencyException } from "../../errors.js"; export type StoreConfig = { uniqueKeys?: UniqueKey[]; maxBulkSize?: number; partitionValue: (e: E) => string | undefined; }; export type SupportedValues = string | boolean | number | null; export type Where = { key: string; t?: "eq" | "not-eq"; value: SupportedValues; } | { key: string; t: "in" | "not-in"; value: readonly (SupportedValues)[]; }; export type StoreWhereFilter = { type?: "where"; mode?: "and" | "or"; where: readonly [ Where, ...(Where[]) ]; }; export type LegacyFilter = { by: keyof E; type: "startsWith"; value: any; } | { by: keyof E; type: "endsWith"; value: any; } | { by: keyof E; type: "contains"; value: any; }; export type JoinFindFilter = { type: "join_find"; keys: readonly string[]; valueKey: string; value: any; }; export type Filter = JoinFindFilter | StoreWhereFilter | LegacyFilter; export type FilterJoinSelect = { type: "filter_join_select"; keys: readonly string[]; valueKey: string; value: any; }; export interface Store, Id extends string> { all: Effect>; filter: (filter: Filter, cursor?: { limit?: number; skip?: number; }) => Effect>; filterJoinSelect: (filter: FilterJoinSelect) => Effect>; find: (id: Id) => Effect>; set: (e: PM) => Effect; batchSet: (items: NonEmptyReadonlyArray) => Effect>; bulkSet: (items: NonEmptyReadonlyArray) => Effect>; /** * Requires the PM type, not Id, because various stores may need to calculate e.g partition keys. */ remove: (e: PM) => Effect; } export interface StoreMaker { make: , Id extends string, Id2 extends Id>(name: string, existing?: Effect>, config?: StoreConfig) => Effect>; } /** * @tsplus type StoreMaker.Ops */ export interface StoreMakerOps extends Tag { } export declare const StoreMaker: StoreMakerOps; /** * @tsplus static ContextMap.Ops Make * @tsplus location "@effect-ts-app/boilerplate-infra/services/Store/service" */ export declare const makeMap: import("@effect/io/Effect").Effect string | undefined; set: (id: string, eTag: string | undefined) => void; parserEnv: ParserEnv; }>; export interface ContextMap extends Effect.Success { } /** * @tsplus type ContextMap.Ops */ export interface ContextMapOps extends Tag { } export declare const ContextMap: ContextMapOps; export interface PersistenceModelType { id: Id; _etag: string | undefined; } export interface StorageConfig { url: ConfigSecret; prefix: string; dbName: string; } //# sourceMappingURL=service.d.ts.map