@things-factory/biz-base 10.1.244 → 10.1.246
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -83,8 +83,8 @@ function accountTailOf(number) {
|
|
|
83
83
|
}
|
|
84
84
|
/** One page of a domain's counterparties - the list door and the choice door read through this one function. */
|
|
85
85
|
async function counterpartyPage(repository, domain, params, rules) {
|
|
86
|
-
|
|
87
|
-
queryBuilder.
|
|
86
|
+
/* Counterparties are found by name - their order is the name's, after any column the reader sorts by. */
|
|
87
|
+
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({ domain: domain, params, repository, ...rules, alias: 'counterparty', defaultSortings: [{ name: 'name' }] });
|
|
88
88
|
const [items, total] = await queryBuilder.getManyAndCount();
|
|
89
89
|
return { items, total };
|
|
90
90
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"counterparty-choice.js","sourceRoot":"","sources":["../../../server/service/counterparty/counterparty-choice.ts"],"names":[],"mappings":";;;AA6CA,sCAGC;AAYD,4CAKC;AAMD,sDAWC;AAGD,oEAGC;;AAxFD,+CAAyD;AAGzD,iDAAgF;AAEhF,iDAA+D;AAG/D;;;;GAIG;AAEH,oEAAoE;AACvD,QAAA,wBAAwB,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAA;AACxG,+HAA+H;AAClH,QAAA,kBAAkB,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;AAC5D,iFAAiF;AACpE,QAAA,kBAAkB,GAAG,CAAC,GAAG,0BAAkB,EAAE,QAAQ,CAAC,CAAA;AACnE,8DAA8D;AACjD,QAAA,YAAY,GAAG,EAAE,CAAA;AAGvB,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;CAK9B,CAAA;AALY,gDAAkB;AACV;IAAlB,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;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AY,EAAE,oBAAY;QAC1B,QAAQ,EAAE,oBAAY;KACvB,CAAC,CAAA;IACF,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,cAAc,EAAE,GAAG,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAA;AACjI,CAAC;AAED,qEAAqE;AAC9D,KAAK,UAAU,4BAA4B,CAAC,UAA+C,EAAE,MAAsB,EAAE,cAAsB;IAChJ,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,EAAE,cAAc,EAAE,EAAS,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,EAAS,EAAE,IAAI,EAAE,oBAAY,EAAE,CAAC,CAAA;IACrL,OAAO,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,WAAW,EAAE,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAA;AACrH,CAAC","sourcesContent":["import { Field, ID, Int, ObjectType } from 'type-graphql'\nimport { Repository } from 'typeorm'\n\nimport { getQueryBuilderFromListParams, ListParam } from '@things-factory/shell'\n\nimport { Counterparty, CounterpartyKind } from './counterparty'\nimport { CounterpartyBankAccount } from './counterparty-bank-account'\n\n/*\n * Choosing a counterparty without reading it (ADR-0139, design/published-read-privilege): `counterparty-published`\n * opens what points at a counterparty and nothing else. Its types are its own - no relation to follow - so the closed\n * fields of Counterparty cannot be reached from a choice.\n */\n\n/** What the list door searches - the counterparty keeper's door. */\nexport const COUNTERPARTY_SEARCHABLES = ['name', 'aliases', 'businessNumber', 'representative', 'notes']\n/** What a choice is searched, filtered and sorted by - the fields it shows, so a search tells nothing about a closed field. */\nexport const CHOICE_SEARCHABLES = ['name', 'businessNumber']\n/* `active` is the door's own filter: an inactive counterparty is not offered. */\nexport const CHOICE_FILTERABLES = [...CHOICE_SEARCHABLES, 'active']\n/** A choice door is no way to read the whole list at once. */\nexport const CHOICE_LIMIT = 50\n\n@ObjectType({ description: 'A counterparty as one picks it: which one, and nothing about it' })\nexport class CounterpartyChoice {\n @Field(type => ID) id: string\n @Field({ description: 'The name the business knows it by' }) name: string\n @Field(type => CounterpartyKind, { description: 'A business, an institution, a person, or our own company' }) kind: CounterpartyKind\n @Field({ nullable: true, description: 'Business registration number - tells apart two counterparties of one name (ADR-0132)' }) businessNumber?: string\n}\n\n@ObjectType({ description: 'A page of counterparties to pick from' })\nexport class CounterpartyChoiceList {\n @Field(type => [CounterpartyChoice]) items: CounterpartyChoice[]\n @Field(type => Int) total: number\n}\n\n@ObjectType({ description: \"An account a counterparty is paid into, as one picks it: the bank and the number's last four digits\" })\nexport class CounterpartyAccountChoice {\n @Field(type => ID) id: string\n @Field({ nullable: true, description: 'The bank' }) bankName?: string\n @Field({ nullable: true, description: \"The account number's last four digits\" }) accountTail?: string\n}\n\n/** An account number's last four digits - what a chooser and a summary show of it. */\nexport function accountTailOf(number: string | null | undefined): string | undefined {\n const digits = String(number ?? '').replace(/\\D/g, '')\n return digits ? digits.slice(-4) : undefined\n}\n\n/** What a door lets a list be read by. */\nexport interface ListRules {\n searchables: string[]\n filterables?: string[]\n sortables?: string[]\n defaultLimit?: number\n maxLimit?: number\n}\n\n/** One page of a domain's counterparties - the list door and the choice door read through this one function. */\nexport async function counterpartyPage(repository: Repository<Counterparty>, domain: { id: string }, params: ListParam, rules: ListRules) {\n /* Counterparties are found by name - their order is the name's, after any column the reader sorts by. */\n const queryBuilder = getQueryBuilderFromListParams({ domain: domain as any, params, repository, ...rules, alias: 'counterparty', defaultSortings: [{ name: 'name' }] })\n const [items, total] = await queryBuilder.getManyAndCount()\n return { items, total }\n}\n\n/**\n * Counterparties to pick from - asked as any list is (a picker sends filters, a page and sortings), answered only by\n * what a choice shows: active ones, searched, filtered and sorted by the shown fields, a capped page at a time.\n */\nexport async function counterpartyChoicesOf(repository: Repository<Counterparty>, domain: { id: string }, params: ListParam | undefined) {\n const asked = (params ?? {}) as ListParam\n const filters = [...(asked.filters ?? []), { name: 'active', operator: 'eq', value: true }]\n const { items, total } = await counterpartyPage(repository, domain, { ...asked, filters } as ListParam, {\n searchables: CHOICE_SEARCHABLES,\n filterables: CHOICE_FILTERABLES,\n sortables: CHOICE_SEARCHABLES,\n defaultLimit: CHOICE_LIMIT,\n maxLimit: CHOICE_LIMIT\n })\n return { items: items.map(one => ({ id: one.id, name: one.name, kind: one.kind, businessNumber: one.businessNumber })), total }\n}\n\n/** The accounts one counterparty is paid into, as one picks them. */\nexport async function counterpartyAccountChoicesOf(repository: Repository<CounterpartyBankAccount>, domain: { id: string }, counterpartyId: string) {\n const accounts = await repository.find({ where: { domain: { id: domain.id }, counterparty: { id: counterpartyId } } as any, order: { createdAt: 'ASC' } as any, take: CHOICE_LIMIT })\n return accounts.map(one => ({ id: one.id, bankName: one.bankName, accountTail: accountTailOf(one.accountNumber) }))\n}\n"]}
|