import { A as APIBase } from './kimlikApi-7350588e.js';
import { D as DataTransferField } from './data-transfer-field-918730a3.js';
import { C as Comparison } from './filter-cbaa3d7d.js';

class DataApiImpl {
  constructor(endpoint, defaultHeaders = {}) {
    this.query = (collection, query) => this.api.post(`${collection}/query`, query);
    this.get = (collection, id, query) => new Promise((resolve, reject) => this.query(collection, {
      fields: [...(query.fields || []), new DataTransferField('_id')],
      filter: {
        comparison: Comparison.Eq,
        id: '_id',
        value: id,
      },
      limit: 1,
      skip: 0,
    }).then(response => resolve(response.results.pop()))
      .catch(error => reject(error)));
    this.update = (collection, id, body) => this.api.post(`${collection}/${id}/update`, body);
    this.addAuthInterceptor = (token) => {
      this.api.addAuthInterceptor(token);
    };
    this.api = new APIBase(endpoint, defaultHeaders);
  }
}

export { DataApiImpl as D };
