{"version":3,"file":"index.cjs","names":["ZDatabaseDocumentCollectionBuilder","_collection","name","join","target","local","foreign","as","concat","build","structuredClone","ZDatabaseOptionsBuilder","_options","database","val","url","timeout","assign","other","Object","copy","build"],"sources":["../src/database/database-document-collection.mts","../src/options/database-options.mts"],"sourcesContent":["/**\n * Represents a collection of documents in a document db.\n */\nexport interface IZDatabaseDocumentCollection {\n  /**\n   * The collection name.\n   */\n  name: string;\n  /**\n   * A list of left outer join targets.\n   */\n  join: Array<{ target: string; local: string; foreign: string; as: string }>;\n}\n\n/**\n * A builder that builds a collection for a document database.\n */\nexport class ZDatabaseDocumentCollectionBuilder {\n  private _collection: IZDatabaseDocumentCollection;\n\n  /**\n   * Initializes a new instance of this object.\n   *\n   * @param name -\n   *        The name of the collection.\n   */\n  public constructor(name: string) {\n    this._collection = {\n      name,\n      join: [],\n    };\n  }\n\n  /**\n   * Adds a left outer join to the collection.\n   *\n   * @param target -\n   *        The target collection to join against.\n   * @param local -\n   *        The local field to match on.\n   * @param foreign -\n   *        The foreign field to match the local to.\n   * @param as -\n   *        The output property.\n   *\n   * @returns\n   *        This object.\n   */\n  public join(target: string, local: string, foreign: string, as: string) {\n    this._collection.join = this._collection.join.concat({\n      target,\n      local,\n      foreign,\n      as,\n    });\n    return this;\n  }\n\n  /**\n   * Returns the built collection.\n   *\n   * @returns\n   *        The built collection.\n   */\n  public build() {\n    return structuredClone(this._collection);\n  }\n}\n","/**\n * Represents options for a database.\n */\nexport interface IZDatabaseOptions {\n  /**\n   * The name of the database to connect to and modify.\n   */\n  database?: string;\n  /**\n   * The database connection string.\n   */\n  url?: string;\n  /**\n   * The timeout value for connections.\n   */\n  timeout?: number;\n}\n\n/**\n * Represents an object that can be used to build a database options object.\n */\nexport class ZDatabaseOptionsBuilder {\n  private _options: IZDatabaseOptions;\n\n  /**\n   * Initializes a new instance of this object.\n   */\n  public constructor() {\n    this._options = {};\n  }\n\n  /**\n   * Sets the database to connect to.\n   *\n   * @param val -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public database(val: string): this {\n    this._options.database = val;\n    return this;\n  }\n\n  /**\n   * Sets the connection string.\n   *\n   * @param val -\n   *        The connection string.\n   *\n   * @returns\n   *        This object.\n   */\n  public url(val: string): this {\n    this._options.url = val;\n    return this;\n  }\n\n  /**\n   * Sets the timeout.\n   *\n   * @param val -\n   *        The value to set.\n   *\n   * @returns\n   *        This object.\n   */\n  public timeout(val: number): this {\n    this._options.timeout = val;\n    return this;\n  }\n\n  /**\n   * Assigns values from a subset of database options to this object.\n   *\n   * @param other -\n   *        The partial object to assign values from.\n   *\n   * @returns\n   *        This object.\n   */\n  public assign(other: Partial<IZDatabaseOptions>): this {\n    this._options = Object.assign(this._options, other);\n    return this;\n  }\n\n  /**\n   * Copies values from another database options structure to this object.\n   *\n   * @param other -\n   *        The object to copy.\n   *\n   * @returns\n   *        This object.\n   */\n  public copy(other: IZDatabaseOptions): this {\n    this._options = Object.assign({}, other);\n    return this;\n  }\n\n  /**\n   * Builds the options.\n   *\n   * @returns\n   *        A copy of the current options structure.\n   */\n  public build(): IZDatabaseOptions {\n    return { ...this._options };\n  }\n}\n"],"mappings":";;;;;;GAiBA,IAAaA,qCAAb,MAAaA;CACHC;;;;;;IAQR,YAAmBC,MAAc;EAC/B,KAAKD,cAAc;GACjBC;GACAC,MAAM,CAAA;EACR;CACF;;;;;;;;;;;;;;;IAiBA,KAAYC,QAAgBC,OAAeC,SAAiBC,IAAY;EACtE,KAAKN,YAAYE,OAAO,KAAKF,YAAYE,KAAKK,OAAO;GACnDJ;GACAC;GACAC;GACAC;EACF,CAAA;EACA,OAAO;CACT;;;;;;IAQA,QAAe;EACb,OAAOG,gBAAgB,KAAKT,WAAW;CACzC;AACF;;;;;;;GC9CA,IAAaU,0BAAb,MAAaA;CACHC;;;IAKR,cAAqB;EACnB,KAAKA,WAAW,CAAC;CACnB;;;;;;;;;IAWA,SAAgBE,KAAmB;EACjC,KAAKF,SAASC,WAAWC;EACzB,OAAO;CACT;;;;;;;;;IAWA,IAAWA,KAAmB;EAC5B,KAAKF,SAASG,MAAMD;EACpB,OAAO;CACT;;;;;;;;;IAWA,QAAeA,KAAmB;EAChC,KAAKF,SAASI,UAAUF;EACxB,OAAO;CACT;;;;;;;;;IAWA,OAAcI,OAAyC;EACrD,KAAKN,WAAWO,OAAOF,OAAO,KAAKL,UAAUM,KAAAA;EAC7C,OAAO;CACT;;;;;;;;;IAWA,KAAYA,OAAgC;EAC1C,KAAKN,WAAWO,OAAOF,OAAO,CAAC,GAAGC,KAAAA;EAClC,OAAO;CACT;;;;;;IAQA,QAAkC;EAChC,OAAO,EAAE,GAAG,KAAKN,SAAS;CAC5B;AACF"}