diff --git a/ember-immer-changeset/src/changeset/immer-changeset.ts b/ember-immer-changeset/src/changeset/immer-changeset.ts index 70f620f..97cf89a 100644 --- a/ember-immer-changeset/src/changeset/immer-changeset.ts +++ b/ember-immer-changeset/src/changeset/immer-changeset.ts @@ -13,9 +13,9 @@ import type { ValidationError, ValidationFunction, } from '../types/changeset'; -import { aggregatedLastChanges } from '../utils/get-last-versions'; +import aggregatedLastChanges from '../utils/get-last-versions'; import { - ChangesetEventEmitter, + default as ChangesetEventEmitter, type OnSetCallback, } from '../utils/event-emitter'; @@ -26,8 +26,9 @@ enablePatches(); * It uses Immer to create a draft of the data object and track changes made to it. * The changes can be applied, reverted, validated, and saved. */ -export class ImmerChangeset = Record> - implements Changeset +export default class ImmerChangeset< + T extends Record = Record, +> implements Changeset { /** * The data object. diff --git a/ember-immer-changeset/src/helpers/changeset-get.ts b/ember-immer-changeset/src/helpers/changeset-get.ts index 8c876e5..ad3e4a6 100644 --- a/ember-immer-changeset/src/helpers/changeset-get.ts +++ b/ember-immer-changeset/src/helpers/changeset-get.ts @@ -1,5 +1,5 @@ import { helper } from '@ember/component/helper'; -import { ImmerChangeset } from '..'; +import type ImmerChangeset from '../changeset/immer-changeset'; function changesetGet([changeset, key]: [ImmerChangeset | undefined, string]) { return changeset?.get(key); diff --git a/ember-immer-changeset/src/index.ts b/ember-immer-changeset/src/index.ts index cf72e2b..4a77cee 100644 --- a/ember-immer-changeset/src/index.ts +++ b/ember-immer-changeset/src/index.ts @@ -1,4 +1,7 @@ export * from './types/changeset'; -export * from './changeset/immer-changeset'; -export * from './utils/is-changeset'; -export * from './helpers/changeset-get'; +import ImmerChangeset from './changeset/immer-changeset'; +import { default as isChangeset } from './utils/is-changeset'; +import { default as changesetGet } from './helpers/changeset-get'; + +export default ImmerChangeset; +export { isChangeset, changesetGet, ImmerChangeset }; diff --git a/ember-immer-changeset/src/utils/event-emitter.ts b/ember-immer-changeset/src/utils/event-emitter.ts index 458b419..a12dc49 100644 --- a/ember-immer-changeset/src/utils/event-emitter.ts +++ b/ember-immer-changeset/src/utils/event-emitter.ts @@ -1,5 +1,5 @@ import type { StringKeyOf } from 'type-fest'; -import { ImmerChangeset } from '..'; +import type ImmerChangeset from '../changeset/immer-changeset'; export type OnSetCallback< T extends ImmerChangeset, @@ -16,7 +16,7 @@ type MapValue< K extends StringKeyOf>, > = EventMap[K] extends Map ? Callback : never; -export class ChangesetEventEmitter< +export default class ChangesetEventEmitter< T extends ImmerChangeset, DTO extends Record, > { diff --git a/ember-immer-changeset/src/utils/get-last-versions.ts b/ember-immer-changeset/src/utils/get-last-versions.ts index 22b48eb..df00201 100644 --- a/ember-immer-changeset/src/utils/get-last-versions.ts +++ b/ember-immer-changeset/src/utils/get-last-versions.ts @@ -1,6 +1,6 @@ import type { Change } from '../types/changeset'; -export function aggregatedLastChanges(arr: Change[]) { +export default function aggregatedLastChanges(arr: Change[]) { const result: Change[] = []; arr.forEach((item) => { diff --git a/ember-immer-changeset/src/utils/is-changeset.ts b/ember-immer-changeset/src/utils/is-changeset.ts index f6bceb6..1e2880d 100644 --- a/ember-immer-changeset/src/utils/is-changeset.ts +++ b/ember-immer-changeset/src/utils/is-changeset.ts @@ -1,6 +1,6 @@ -import { ImmerChangeset } from '../changeset/immer-changeset'; +import ImmerChangeset from '../changeset/immer-changeset'; -export function isChangeset(obj?: InstanceType) { +export default function isChangeset(obj?: InstanceType) { if (!obj) { return false; } diff --git a/test-app/tests/unit/utils/is-changeset-test.ts b/test-app/tests/unit/utils/is-changeset-test.ts index f9a296c..1104232 100644 --- a/test-app/tests/unit/utils/is-changeset-test.ts +++ b/test-app/tests/unit/utils/is-changeset-test.ts @@ -1,5 +1,5 @@ import { ImmerChangeset } from 'ember-immer-changeset'; -import { isChangeset } from 'ember-immer-changeset/utils/is-changeset'; +import isChangeset from 'ember-immer-changeset/utils/is-changeset'; import { module, test } from 'qunit'; module('Unit | Utility | is-changeset', function () {