Skip to content

Commit

Permalink
rename getIdsAll functions to getIds
Browse files Browse the repository at this point in the history
  • Loading branch information
sugat009 committed Dec 3, 2024
1 parent 3ea31ef commit a7a9272
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions shared-libs/cht-datasource/src/contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export namespace v1 {
* @param context the current data context
* @returns a function for retrieving a paged array of contact identifiers
* @throws Error if a data context is not provided
* @see {@link getIdsAll} which provides the same data, but without having to manually account for paging
* @see {@link getIds} which provides the same data, but without having to manually account for paging
*/
export const getIdsPage = (context: DataContext): typeof curriedFn => {
assertDataContext(context);
Expand Down Expand Up @@ -125,7 +125,7 @@ export namespace v1 {
* @returns a function for getting a generator that fetches contact identifiers
* @throws Error if a data context is not provided
*/
export const getIdsAll = (context: DataContext): typeof curriedGen => {
export const getIds = (context: DataContext): typeof curriedGen => {
assertDataContext(context);
const getPage = context.bind(v1.getIdsPage);

Expand Down
4 changes: 2 additions & 2 deletions shared-libs/cht-datasource/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const getDatasource = (ctx: DataContext) => {
getIds: (
freetext: Nullable<string> = null,
type: Nullable<string> = null
) => ctx.bind(Contact.v1.getIdsAll)(Contact.v1.createQualifier(freetext, type)),
) => ctx.bind(Contact.v1.getIds)(Contact.v1.createQualifier(freetext, type)),
},
place: {
/**
Expand Down Expand Up @@ -240,7 +240,7 @@ export const getDatasource = (ctx: DataContext) => {
getIds: (
qualifier: string,
// eslint-disable-next-line compat/compat
) => ctx.bind(Report.v1.getIdsAll)(Qualifier.byFreetext(qualifier)),
) => ctx.bind(Report.v1.getIds)(Qualifier.byFreetext(qualifier)),
},
},
};
Expand Down
4 changes: 2 additions & 2 deletions shared-libs/cht-datasource/src/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export namespace v1 {
* @param context the current data context
* @returns a function for retrieving a paged array of report identifiers
* @throws Error if a data context is not provided
* @see {@link getIdsAll} which provides the same data, but without having to manually account for paging
* @see {@link getIds} which provides the same data, but without having to manually account for paging
*/
export const getIdsPage = (context: DataContext): typeof curriedFn => {
assertDataContext(context);
Expand Down Expand Up @@ -98,7 +98,7 @@ export namespace v1 {
* @returns a function for getting a generator that fetches report identifiers
* @throws Error if a data context is not provided
*/
export const getIdsAll = (context: DataContext): typeof curriedGen => {
export const getIds = (context: DataContext): typeof curriedGen => {
assertDataContext(context);
const getPage = context.bind(v1.getIdsPage);

Expand Down
8 changes: 4 additions & 4 deletions shared-libs/cht-datasource/test/contact.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ describe('contact', () => {
isFreetextQualifier.returns(true);
getPagedGenerator.returns(mockGenerator);

const generator = Contact.v1.getIdsAll(dataContext)(qualifier);
const generator = Contact.v1.getIds(dataContext)(qualifier);

expect(generator).to.deep.equal(mockGenerator);
expect(assertDataContext.calledOnceWithExactly(dataContext)).to.be.true;
Expand All @@ -350,7 +350,7 @@ describe('contact', () => {
isFreetextQualifier.returns(true);
assertDataContext.throws(new Error(errMsg));

expect(() => Contact.v1.getIdsAll(dataContext)).to.throw(errMsg);
expect(() => Contact.v1.getIds(dataContext)).to.throw(errMsg);
expect(assertDataContext.calledOnceWithExactly(dataContext)).to.be.true;
expect(contactGetIdsPage.notCalled).to.be.true;
expect(isContactTypeQualifier.notCalled).to.be.true;
Expand All @@ -360,7 +360,7 @@ describe('contact', () => {
it('should throw an error for invalid contactType', () => {
isContactTypeQualifier.returns(false);

expect(() => Contact.v1.getIdsAll(dataContext)(invalidContactTypeQualifier))
expect(() => Contact.v1.getIds(dataContext)(invalidContactTypeQualifier))
.to.throw(`Invalid contact type [${JSON.stringify(invalidContactTypeQualifier)}]`);
expect(assertDataContext.calledOnceWithExactly(dataContext)).to.be.true;
expect(contactGetIdsPage.notCalled).to.be.true;
Expand All @@ -372,7 +372,7 @@ describe('contact', () => {
isContactTypeQualifier.returns(false);
isFreetextQualifier.returns(false);

expect(() => Contact.v1.getIdsAll(dataContext)(invalidFreetextQualifier))
expect(() => Contact.v1.getIds(dataContext)(invalidFreetextQualifier))
.to.throw(`Invalid freetext [${JSON.stringify(invalidFreetextQualifier)}]`);
expect(assertDataContext.calledOnceWithExactly(dataContext)).to.be.true;
expect(contactGetIdsPage.notCalled).to.be.true;
Expand Down
4 changes: 2 additions & 2 deletions shared-libs/cht-datasource/test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ describe('CHT Script API - getDatasource', () => {
const res = contact.getIds(freetext, contactType);

expect(res).to.deep.equal(mockAsyncGenerator);
expect(dataContextBind.calledOnceWithExactly(Contact.v1.getIdsAll)).to.be.true;
expect(dataContextBind.calledOnceWithExactly(Contact.v1.getIds)).to.be.true;
expect(contactGetIds.calledOnceWithExactly(qualifier)).to.be.true;
expect(createQualifier.calledOnceWithExactly(freetext, contactType)).to.be.true;
});
Expand Down Expand Up @@ -349,7 +349,7 @@ describe('CHT Script API - getDatasource', () => {

expect(res).to.deep.equal(mockAsyncGenerator);
// eslint-disable-next-line compat/compat
expect(dataContextBind.calledOnceWithExactly(Report.v1.getIdsAll)).to.be.true;
expect(dataContextBind.calledOnceWithExactly(Report.v1.getIds)).to.be.true;
expect(contactGetIds.calledOnceWithExactly(qualifier)).to.be.true;
expect(byFreetext.calledOnceWithExactly(freetext)).to.be.true;
});
Expand Down
6 changes: 3 additions & 3 deletions shared-libs/cht-datasource/test/report.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ describe('report', () => {
getPagedGenerator.returns(mockGenerator);

// eslint-disable-next-line compat/compat
const generator = Report.v1.getIdsAll(dataContext)(freetextQualifier);
const generator = Report.v1.getIds(dataContext)(freetextQualifier);

expect(generator).to.deep.equal(mockGenerator);
expect(assertDataContext.calledOnceWithExactly(dataContext)).to.be.true;
Expand All @@ -229,7 +229,7 @@ describe('report', () => {
assertDataContext.throws(new Error(errMsg));

// eslint-disable-next-line compat/compat
expect(() => Report.v1.getIdsAll(dataContext)).to.throw(errMsg);
expect(() => Report.v1.getIds(dataContext)).to.throw(errMsg);
expect(assertDataContext.calledOnceWithExactly(dataContext)).to.be.true;
expect(reportGetIdsPage.notCalled).to.be.true;
expect(isFreetextQualifier.notCalled).to.be.true;
Expand All @@ -239,7 +239,7 @@ describe('report', () => {
isFreetextQualifier.returns(false);

// eslint-disable-next-line compat/compat
expect(() => Report.v1.getIdsAll(dataContext)(freetextQualifier))
expect(() => Report.v1.getIds(dataContext)(freetextQualifier))
.to.throw(`Invalid freetext [${JSON.stringify(freetextQualifier)}]`);
expect(assertDataContext.calledOnceWithExactly(dataContext)).to.be.true;
expect(reportGetIdsPage.notCalled).to.be.true;
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/api/controllers/contact.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,11 +410,11 @@ describe('Contact API', () => {
});
});

describe('Contact.v1.getIdsAll', async () => {
describe('Contact.v1.getIds', async () => {
it('fetches all data by iterating through generator', async () => {
const docs = [];

const generator = Contact.v1.getIdsAll(dataContext)(Qualifier.byContactType(personType));
const generator = Contact.v1.getIds(dataContext)(Qualifier.byContactType(personType));

for await (const doc of generator) {
docs.push(doc);
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/api/controllers/report.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,12 @@ describe('Report API', () => {
});
});

describe('Report.v1.getIdsAll', async () => {
describe('Report.v1.getIds', async () => {
it('fetches all data by iterating through generator', async () => {
const freetext = 'report';
const docs = [];

const generator = Report.v1.getIdsAll(dataContext)(Qualifier.byFreetext(freetext));
const generator = Report.v1.getIds(dataContext)(Qualifier.byFreetext(freetext));

for await (const doc of generator) {
docs.push(doc);
Expand Down

0 comments on commit a7a9272

Please sign in to comment.