@coopenomics/factory 2025.7.1-1 → 2025.7.1
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.
- package/dist/index.cjs +50 -80
- package/dist/index.mjs +50 -80
- package/package.json +4 -5
package/dist/index.cjs
CHANGED
|
@@ -2916,7 +2916,7 @@ class PDFService {
|
|
|
2916
2916
|
|
|
2917
2917
|
const name = "@coopenomics/factory";
|
|
2918
2918
|
const type = "module";
|
|
2919
|
-
const version = "2025.7.1
|
|
2919
|
+
const version = "2025.7.1";
|
|
2920
2920
|
const packageManager = "pnpm@9.0.6";
|
|
2921
2921
|
const description = "";
|
|
2922
2922
|
const author = "Alex Ant <chairman.voskhod@gmail.com>";
|
|
@@ -2959,15 +2959,14 @@ const scripts = {
|
|
|
2959
2959
|
prepublishOnly: "nr build",
|
|
2960
2960
|
release: "bumpp && npm publish",
|
|
2961
2961
|
test: "vitest --dir test --testTimeout=240000 --exclude documents --watch=false",
|
|
2962
|
-
typecheck: "tsc --noEmit"
|
|
2963
|
-
"setup-indexes": "tsx scripts/setup-indexes.ts"
|
|
2962
|
+
typecheck: "tsc --noEmit"
|
|
2964
2963
|
};
|
|
2965
2964
|
const dependencies = {
|
|
2966
2965
|
ajv: "^8.13.0",
|
|
2967
2966
|
"ajv-formats": "^3.0.1",
|
|
2968
2967
|
"ajv-i18n": "^4.2.0",
|
|
2969
2968
|
axios: "^1.7.2",
|
|
2970
|
-
cooptypes: "2025.7.1
|
|
2969
|
+
cooptypes: "2025.7.1",
|
|
2971
2970
|
dotenv: "^16.4.5",
|
|
2972
2971
|
"eosjs-ecc": "^4.0.7",
|
|
2973
2972
|
handlebars: "^4.7.8",
|
|
@@ -3008,7 +3007,7 @@ const pnpm = {
|
|
|
3008
3007
|
"vite@>=5.1.0 <=5.1.6": ">=5.1.7"
|
|
3009
3008
|
}
|
|
3010
3009
|
};
|
|
3011
|
-
const gitHead = "
|
|
3010
|
+
const gitHead = "ac8836628eb82672b481dbf86050918f41bf24ca";
|
|
3012
3011
|
const packageJson = {
|
|
3013
3012
|
name: name,
|
|
3014
3013
|
type: type,
|
|
@@ -4686,40 +4685,28 @@ class SearchService {
|
|
|
4686
4685
|
__publicField$1(this, "storage");
|
|
4687
4686
|
this.storage = storage;
|
|
4688
4687
|
}
|
|
4689
|
-
// Экранирование специальных символов регулярных выражений
|
|
4690
|
-
escapeRegex(text) {
|
|
4691
|
-
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4692
|
-
}
|
|
4693
4688
|
async search(query) {
|
|
4694
4689
|
if (!query || query.trim().length === 0) {
|
|
4695
4690
|
return [];
|
|
4696
4691
|
}
|
|
4697
4692
|
const results = [];
|
|
4698
4693
|
const trimmedQuery = query.trim();
|
|
4699
|
-
|
|
4700
|
-
const escapedQuery = this.escapeRegex(trimmedQuery);
|
|
4694
|
+
const regex = new RegExp(trimmedQuery, "i");
|
|
4701
4695
|
const queryWords = trimmedQuery.split(/\s+/).filter((word) => word.length > 0);
|
|
4702
4696
|
try {
|
|
4703
|
-
|
|
4704
|
-
const individualResults = await this.searchIndividuals(escapedQuery, queryWords, trimmedQuery);
|
|
4705
|
-
console.log(`[SearchService] \u041D\u0430\u0439\u0434\u0435\u043D\u043E individuals: ${individualResults.length}`);
|
|
4697
|
+
const individualResults = await this.searchIndividuals(regex, queryWords);
|
|
4706
4698
|
results.push(...individualResults);
|
|
4707
|
-
|
|
4708
|
-
const entrepreneurResults = await this.searchEntrepreneurs(escapedQuery, queryWords, trimmedQuery);
|
|
4709
|
-
console.log(`[SearchService] \u041D\u0430\u0439\u0434\u0435\u043D\u043E entrepreneurs: ${entrepreneurResults.length}`);
|
|
4699
|
+
const entrepreneurResults = await this.searchEntrepreneurs(regex, queryWords);
|
|
4710
4700
|
results.push(...entrepreneurResults);
|
|
4711
|
-
|
|
4712
|
-
const organizationResults = await this.searchOrganizations(escapedQuery);
|
|
4713
|
-
console.log(`[SearchService] \u041D\u0430\u0439\u0434\u0435\u043D\u043E organizations: ${organizationResults.length}`);
|
|
4701
|
+
const organizationResults = await this.searchOrganizations(regex);
|
|
4714
4702
|
results.push(...organizationResults);
|
|
4715
|
-
console.log(`[SearchService] \u041E\u0431\u0449\u0435\u0435 \u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u0440\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442\u043E\u0432: ${results.length}`);
|
|
4716
4703
|
return results.slice(0, 10);
|
|
4717
4704
|
} catch (error) {
|
|
4718
|
-
console.error("
|
|
4705
|
+
console.error("Error during search:", error);
|
|
4719
4706
|
return [];
|
|
4720
4707
|
}
|
|
4721
4708
|
}
|
|
4722
|
-
async searchIndividuals(
|
|
4709
|
+
async searchIndividuals(regex, queryWords) {
|
|
4723
4710
|
const individualModel = new Individual(this.storage);
|
|
4724
4711
|
const results = [];
|
|
4725
4712
|
let filter;
|
|
@@ -4728,16 +4715,16 @@ class SearchService {
|
|
|
4728
4715
|
deleted: false,
|
|
4729
4716
|
$or: [
|
|
4730
4717
|
// Поиск по отдельным полям
|
|
4731
|
-
{ first_name: { $regex:
|
|
4732
|
-
{ last_name: { $regex:
|
|
4733
|
-
{ middle_name: { $regex:
|
|
4718
|
+
{ first_name: { $regex: regex } },
|
|
4719
|
+
{ last_name: { $regex: regex } },
|
|
4720
|
+
{ middle_name: { $regex: regex } },
|
|
4734
4721
|
// Поиск по полному ФИО (все слова должны быть найдены)
|
|
4735
4722
|
{
|
|
4736
4723
|
$and: queryWords.map((word) => ({
|
|
4737
4724
|
$or: [
|
|
4738
|
-
{ first_name: { $regex:
|
|
4739
|
-
{ last_name: { $regex:
|
|
4740
|
-
{ middle_name: { $regex:
|
|
4725
|
+
{ first_name: { $regex: new RegExp(word, "i") } },
|
|
4726
|
+
{ last_name: { $regex: new RegExp(word, "i") } },
|
|
4727
|
+
{ middle_name: { $regex: new RegExp(word, "i") } }
|
|
4741
4728
|
]
|
|
4742
4729
|
}))
|
|
4743
4730
|
}
|
|
@@ -4747,30 +4734,22 @@ class SearchService {
|
|
|
4747
4734
|
filter = {
|
|
4748
4735
|
deleted: false,
|
|
4749
4736
|
$or: [
|
|
4750
|
-
{ first_name: { $regex:
|
|
4751
|
-
{ last_name: { $regex:
|
|
4752
|
-
{ middle_name: { $regex:
|
|
4737
|
+
{ first_name: { $regex: regex } },
|
|
4738
|
+
{ last_name: { $regex: regex } },
|
|
4739
|
+
{ middle_name: { $regex: regex } }
|
|
4753
4740
|
]
|
|
4754
4741
|
};
|
|
4755
4742
|
}
|
|
4756
|
-
console.log(`[SearchService] \u0424\u0438\u043B\u044C\u0442\u0440 \u0434\u043B\u044F individuals:`, JSON.stringify(filter, null, 2));
|
|
4757
4743
|
const individuals = await individualModel.getMany(filter);
|
|
4758
|
-
console.log(`[SearchService] \u0420\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442\u044B \u043F\u043E\u0438\u0441\u043A\u0430 individuals:`, {
|
|
4759
|
-
total: individuals.totalResults,
|
|
4760
|
-
found: individuals.results.length,
|
|
4761
|
-
query: originalQuery,
|
|
4762
|
-
names: individuals.results.map((ind) => `${ind.last_name} ${ind.first_name} ${ind.middle_name || ""} (deleted: ${ind.deleted || false})`)
|
|
4763
|
-
});
|
|
4764
4744
|
for (const individual of individuals.results) {
|
|
4765
4745
|
const highlightedFields = [];
|
|
4766
|
-
|
|
4767
|
-
if (individual.first_name && testRegex.test(individual.first_name))
|
|
4746
|
+
if (regex.test(individual.first_name))
|
|
4768
4747
|
highlightedFields.push("first_name");
|
|
4769
|
-
if (
|
|
4748
|
+
if (regex.test(individual.last_name))
|
|
4770
4749
|
highlightedFields.push("last_name");
|
|
4771
|
-
if (
|
|
4750
|
+
if (regex.test(individual.middle_name))
|
|
4772
4751
|
highlightedFields.push("middle_name");
|
|
4773
|
-
const fullName = `${individual.last_name
|
|
4752
|
+
const fullName = `${individual.last_name} ${individual.first_name} ${individual.middle_name}`.trim();
|
|
4774
4753
|
if (this.matchesFullName(fullName, queryWords)) {
|
|
4775
4754
|
highlightedFields.push("full_name");
|
|
4776
4755
|
}
|
|
@@ -4782,7 +4761,7 @@ class SearchService {
|
|
|
4782
4761
|
}
|
|
4783
4762
|
return results;
|
|
4784
4763
|
}
|
|
4785
|
-
async searchEntrepreneurs(
|
|
4764
|
+
async searchEntrepreneurs(regex, queryWords) {
|
|
4786
4765
|
const entrepreneurModel = new Entrepreneur(this.storage);
|
|
4787
4766
|
const results = [];
|
|
4788
4767
|
let filter;
|
|
@@ -4791,18 +4770,18 @@ class SearchService {
|
|
|
4791
4770
|
deleted: false,
|
|
4792
4771
|
$or: [
|
|
4793
4772
|
// Поиск по отдельным полям
|
|
4794
|
-
{ first_name: { $regex:
|
|
4795
|
-
{ last_name: { $regex:
|
|
4796
|
-
{ middle_name: { $regex:
|
|
4797
|
-
{ "details.inn": { $regex:
|
|
4798
|
-
{ "details.ogrn": { $regex:
|
|
4773
|
+
{ first_name: { $regex: regex } },
|
|
4774
|
+
{ last_name: { $regex: regex } },
|
|
4775
|
+
{ middle_name: { $regex: regex } },
|
|
4776
|
+
{ "details.inn": { $regex: regex } },
|
|
4777
|
+
{ "details.ogrn": { $regex: regex } },
|
|
4799
4778
|
// Поиск по полному ФИО
|
|
4800
4779
|
{
|
|
4801
4780
|
$and: queryWords.map((word) => ({
|
|
4802
4781
|
$or: [
|
|
4803
|
-
{ first_name: { $regex:
|
|
4804
|
-
{ last_name: { $regex:
|
|
4805
|
-
{ middle_name: { $regex:
|
|
4782
|
+
{ first_name: { $regex: new RegExp(word, "i") } },
|
|
4783
|
+
{ last_name: { $regex: new RegExp(word, "i") } },
|
|
4784
|
+
{ middle_name: { $regex: new RegExp(word, "i") } }
|
|
4806
4785
|
]
|
|
4807
4786
|
}))
|
|
4808
4787
|
}
|
|
@@ -4812,36 +4791,28 @@ class SearchService {
|
|
|
4812
4791
|
filter = {
|
|
4813
4792
|
deleted: false,
|
|
4814
4793
|
$or: [
|
|
4815
|
-
{ first_name: { $regex:
|
|
4816
|
-
{ last_name: { $regex:
|
|
4817
|
-
{ middle_name: { $regex:
|
|
4818
|
-
{ "details.inn": { $regex:
|
|
4819
|
-
{ "details.ogrn": { $regex:
|
|
4794
|
+
{ first_name: { $regex: regex } },
|
|
4795
|
+
{ last_name: { $regex: regex } },
|
|
4796
|
+
{ middle_name: { $regex: regex } },
|
|
4797
|
+
{ "details.inn": { $regex: regex } },
|
|
4798
|
+
{ "details.ogrn": { $regex: regex } }
|
|
4820
4799
|
]
|
|
4821
4800
|
};
|
|
4822
4801
|
}
|
|
4823
|
-
console.log(`[SearchService] \u0424\u0438\u043B\u044C\u0442\u0440 \u0434\u043B\u044F entrepreneurs:`, JSON.stringify(filter, null, 2));
|
|
4824
4802
|
const entrepreneurs = await entrepreneurModel.getMany(filter);
|
|
4825
|
-
console.log(`[SearchService] \u0420\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442\u044B \u043F\u043E\u0438\u0441\u043A\u0430 entrepreneurs:`, {
|
|
4826
|
-
total: entrepreneurs.totalResults,
|
|
4827
|
-
found: entrepreneurs.results.length,
|
|
4828
|
-
query: originalQuery,
|
|
4829
|
-
names: entrepreneurs.results.map((ent) => `${ent.last_name} ${ent.first_name} ${ent.middle_name || ""} (deleted: ${ent.deleted || false})`)
|
|
4830
|
-
});
|
|
4831
4803
|
for (const entrepreneur of entrepreneurs.results) {
|
|
4832
4804
|
const highlightedFields = [];
|
|
4833
|
-
|
|
4834
|
-
if (entrepreneur.first_name && testRegex.test(entrepreneur.first_name))
|
|
4805
|
+
if (regex.test(entrepreneur.first_name))
|
|
4835
4806
|
highlightedFields.push("first_name");
|
|
4836
|
-
if (
|
|
4807
|
+
if (regex.test(entrepreneur.last_name))
|
|
4837
4808
|
highlightedFields.push("last_name");
|
|
4838
|
-
if (
|
|
4809
|
+
if (regex.test(entrepreneur.middle_name))
|
|
4839
4810
|
highlightedFields.push("middle_name");
|
|
4840
|
-
if (entrepreneur.details?.inn &&
|
|
4811
|
+
if (entrepreneur.details?.inn && regex.test(entrepreneur.details.inn))
|
|
4841
4812
|
highlightedFields.push("details.inn");
|
|
4842
|
-
if (entrepreneur.details?.ogrn &&
|
|
4813
|
+
if (entrepreneur.details?.ogrn && regex.test(entrepreneur.details.ogrn))
|
|
4843
4814
|
highlightedFields.push("details.ogrn");
|
|
4844
|
-
const fullName = `${entrepreneur.last_name
|
|
4815
|
+
const fullName = `${entrepreneur.last_name} ${entrepreneur.first_name} ${entrepreneur.middle_name}`.trim();
|
|
4845
4816
|
if (this.matchesFullName(fullName, queryWords)) {
|
|
4846
4817
|
highlightedFields.push("full_name");
|
|
4847
4818
|
}
|
|
@@ -4853,25 +4824,24 @@ class SearchService {
|
|
|
4853
4824
|
}
|
|
4854
4825
|
return results;
|
|
4855
4826
|
}
|
|
4856
|
-
async searchOrganizations(
|
|
4827
|
+
async searchOrganizations(regex) {
|
|
4857
4828
|
const organizationModel = new Organization(this.storage);
|
|
4858
4829
|
const results = [];
|
|
4859
4830
|
const organizations = await organizationModel.getMany({
|
|
4860
4831
|
deleted: false,
|
|
4861
4832
|
$or: [
|
|
4862
|
-
{ short_name: { $regex:
|
|
4863
|
-
{ "details.inn": { $regex:
|
|
4864
|
-
{ "details.ogrn": { $regex:
|
|
4833
|
+
{ short_name: { $regex: regex } },
|
|
4834
|
+
{ "details.inn": { $regex: regex } },
|
|
4835
|
+
{ "details.ogrn": { $regex: regex } }
|
|
4865
4836
|
]
|
|
4866
4837
|
});
|
|
4867
4838
|
for (const organization of organizations.results) {
|
|
4868
4839
|
const highlightedFields = [];
|
|
4869
|
-
|
|
4870
|
-
if (testRegex.test(organization.short_name))
|
|
4840
|
+
if (regex.test(organization.short_name))
|
|
4871
4841
|
highlightedFields.push("short_name");
|
|
4872
|
-
if (organization.details?.inn &&
|
|
4842
|
+
if (organization.details?.inn && regex.test(organization.details.inn))
|
|
4873
4843
|
highlightedFields.push("details.inn");
|
|
4874
|
-
if (organization.details?.ogrn &&
|
|
4844
|
+
if (organization.details?.ogrn && regex.test(organization.details.ogrn))
|
|
4875
4845
|
highlightedFields.push("details.ogrn");
|
|
4876
4846
|
results.push({
|
|
4877
4847
|
type: "organization",
|
package/dist/index.mjs
CHANGED
|
@@ -2903,7 +2903,7 @@ class PDFService {
|
|
|
2903
2903
|
|
|
2904
2904
|
const name = "@coopenomics/factory";
|
|
2905
2905
|
const type = "module";
|
|
2906
|
-
const version = "2025.7.1
|
|
2906
|
+
const version = "2025.7.1";
|
|
2907
2907
|
const packageManager = "pnpm@9.0.6";
|
|
2908
2908
|
const description = "";
|
|
2909
2909
|
const author = "Alex Ant <chairman.voskhod@gmail.com>";
|
|
@@ -2946,15 +2946,14 @@ const scripts = {
|
|
|
2946
2946
|
prepublishOnly: "nr build",
|
|
2947
2947
|
release: "bumpp && npm publish",
|
|
2948
2948
|
test: "vitest --dir test --testTimeout=240000 --exclude documents --watch=false",
|
|
2949
|
-
typecheck: "tsc --noEmit"
|
|
2950
|
-
"setup-indexes": "tsx scripts/setup-indexes.ts"
|
|
2949
|
+
typecheck: "tsc --noEmit"
|
|
2951
2950
|
};
|
|
2952
2951
|
const dependencies = {
|
|
2953
2952
|
ajv: "^8.13.0",
|
|
2954
2953
|
"ajv-formats": "^3.0.1",
|
|
2955
2954
|
"ajv-i18n": "^4.2.0",
|
|
2956
2955
|
axios: "^1.7.2",
|
|
2957
|
-
cooptypes: "2025.7.1
|
|
2956
|
+
cooptypes: "2025.7.1",
|
|
2958
2957
|
dotenv: "^16.4.5",
|
|
2959
2958
|
"eosjs-ecc": "^4.0.7",
|
|
2960
2959
|
handlebars: "^4.7.8",
|
|
@@ -2995,7 +2994,7 @@ const pnpm = {
|
|
|
2995
2994
|
"vite@>=5.1.0 <=5.1.6": ">=5.1.7"
|
|
2996
2995
|
}
|
|
2997
2996
|
};
|
|
2998
|
-
const gitHead = "
|
|
2997
|
+
const gitHead = "ac8836628eb82672b481dbf86050918f41bf24ca";
|
|
2999
2998
|
const packageJson = {
|
|
3000
2999
|
name: name,
|
|
3001
3000
|
type: type,
|
|
@@ -4673,40 +4672,28 @@ class SearchService {
|
|
|
4673
4672
|
__publicField$1(this, "storage");
|
|
4674
4673
|
this.storage = storage;
|
|
4675
4674
|
}
|
|
4676
|
-
// Экранирование специальных символов регулярных выражений
|
|
4677
|
-
escapeRegex(text) {
|
|
4678
|
-
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4679
|
-
}
|
|
4680
4675
|
async search(query) {
|
|
4681
4676
|
if (!query || query.trim().length === 0) {
|
|
4682
4677
|
return [];
|
|
4683
4678
|
}
|
|
4684
4679
|
const results = [];
|
|
4685
4680
|
const trimmedQuery = query.trim();
|
|
4686
|
-
|
|
4687
|
-
const escapedQuery = this.escapeRegex(trimmedQuery);
|
|
4681
|
+
const regex = new RegExp(trimmedQuery, "i");
|
|
4688
4682
|
const queryWords = trimmedQuery.split(/\s+/).filter((word) => word.length > 0);
|
|
4689
4683
|
try {
|
|
4690
|
-
|
|
4691
|
-
const individualResults = await this.searchIndividuals(escapedQuery, queryWords, trimmedQuery);
|
|
4692
|
-
console.log(`[SearchService] \u041D\u0430\u0439\u0434\u0435\u043D\u043E individuals: ${individualResults.length}`);
|
|
4684
|
+
const individualResults = await this.searchIndividuals(regex, queryWords);
|
|
4693
4685
|
results.push(...individualResults);
|
|
4694
|
-
|
|
4695
|
-
const entrepreneurResults = await this.searchEntrepreneurs(escapedQuery, queryWords, trimmedQuery);
|
|
4696
|
-
console.log(`[SearchService] \u041D\u0430\u0439\u0434\u0435\u043D\u043E entrepreneurs: ${entrepreneurResults.length}`);
|
|
4686
|
+
const entrepreneurResults = await this.searchEntrepreneurs(regex, queryWords);
|
|
4697
4687
|
results.push(...entrepreneurResults);
|
|
4698
|
-
|
|
4699
|
-
const organizationResults = await this.searchOrganizations(escapedQuery);
|
|
4700
|
-
console.log(`[SearchService] \u041D\u0430\u0439\u0434\u0435\u043D\u043E organizations: ${organizationResults.length}`);
|
|
4688
|
+
const organizationResults = await this.searchOrganizations(regex);
|
|
4701
4689
|
results.push(...organizationResults);
|
|
4702
|
-
console.log(`[SearchService] \u041E\u0431\u0449\u0435\u0435 \u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u0440\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442\u043E\u0432: ${results.length}`);
|
|
4703
4690
|
return results.slice(0, 10);
|
|
4704
4691
|
} catch (error) {
|
|
4705
|
-
console.error("
|
|
4692
|
+
console.error("Error during search:", error);
|
|
4706
4693
|
return [];
|
|
4707
4694
|
}
|
|
4708
4695
|
}
|
|
4709
|
-
async searchIndividuals(
|
|
4696
|
+
async searchIndividuals(regex, queryWords) {
|
|
4710
4697
|
const individualModel = new Individual(this.storage);
|
|
4711
4698
|
const results = [];
|
|
4712
4699
|
let filter;
|
|
@@ -4715,16 +4702,16 @@ class SearchService {
|
|
|
4715
4702
|
deleted: false,
|
|
4716
4703
|
$or: [
|
|
4717
4704
|
// Поиск по отдельным полям
|
|
4718
|
-
{ first_name: { $regex:
|
|
4719
|
-
{ last_name: { $regex:
|
|
4720
|
-
{ middle_name: { $regex:
|
|
4705
|
+
{ first_name: { $regex: regex } },
|
|
4706
|
+
{ last_name: { $regex: regex } },
|
|
4707
|
+
{ middle_name: { $regex: regex } },
|
|
4721
4708
|
// Поиск по полному ФИО (все слова должны быть найдены)
|
|
4722
4709
|
{
|
|
4723
4710
|
$and: queryWords.map((word) => ({
|
|
4724
4711
|
$or: [
|
|
4725
|
-
{ first_name: { $regex:
|
|
4726
|
-
{ last_name: { $regex:
|
|
4727
|
-
{ middle_name: { $regex:
|
|
4712
|
+
{ first_name: { $regex: new RegExp(word, "i") } },
|
|
4713
|
+
{ last_name: { $regex: new RegExp(word, "i") } },
|
|
4714
|
+
{ middle_name: { $regex: new RegExp(word, "i") } }
|
|
4728
4715
|
]
|
|
4729
4716
|
}))
|
|
4730
4717
|
}
|
|
@@ -4734,30 +4721,22 @@ class SearchService {
|
|
|
4734
4721
|
filter = {
|
|
4735
4722
|
deleted: false,
|
|
4736
4723
|
$or: [
|
|
4737
|
-
{ first_name: { $regex:
|
|
4738
|
-
{ last_name: { $regex:
|
|
4739
|
-
{ middle_name: { $regex:
|
|
4724
|
+
{ first_name: { $regex: regex } },
|
|
4725
|
+
{ last_name: { $regex: regex } },
|
|
4726
|
+
{ middle_name: { $regex: regex } }
|
|
4740
4727
|
]
|
|
4741
4728
|
};
|
|
4742
4729
|
}
|
|
4743
|
-
console.log(`[SearchService] \u0424\u0438\u043B\u044C\u0442\u0440 \u0434\u043B\u044F individuals:`, JSON.stringify(filter, null, 2));
|
|
4744
4730
|
const individuals = await individualModel.getMany(filter);
|
|
4745
|
-
console.log(`[SearchService] \u0420\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442\u044B \u043F\u043E\u0438\u0441\u043A\u0430 individuals:`, {
|
|
4746
|
-
total: individuals.totalResults,
|
|
4747
|
-
found: individuals.results.length,
|
|
4748
|
-
query: originalQuery,
|
|
4749
|
-
names: individuals.results.map((ind) => `${ind.last_name} ${ind.first_name} ${ind.middle_name || ""} (deleted: ${ind.deleted || false})`)
|
|
4750
|
-
});
|
|
4751
4731
|
for (const individual of individuals.results) {
|
|
4752
4732
|
const highlightedFields = [];
|
|
4753
|
-
|
|
4754
|
-
if (individual.first_name && testRegex.test(individual.first_name))
|
|
4733
|
+
if (regex.test(individual.first_name))
|
|
4755
4734
|
highlightedFields.push("first_name");
|
|
4756
|
-
if (
|
|
4735
|
+
if (regex.test(individual.last_name))
|
|
4757
4736
|
highlightedFields.push("last_name");
|
|
4758
|
-
if (
|
|
4737
|
+
if (regex.test(individual.middle_name))
|
|
4759
4738
|
highlightedFields.push("middle_name");
|
|
4760
|
-
const fullName = `${individual.last_name
|
|
4739
|
+
const fullName = `${individual.last_name} ${individual.first_name} ${individual.middle_name}`.trim();
|
|
4761
4740
|
if (this.matchesFullName(fullName, queryWords)) {
|
|
4762
4741
|
highlightedFields.push("full_name");
|
|
4763
4742
|
}
|
|
@@ -4769,7 +4748,7 @@ class SearchService {
|
|
|
4769
4748
|
}
|
|
4770
4749
|
return results;
|
|
4771
4750
|
}
|
|
4772
|
-
async searchEntrepreneurs(
|
|
4751
|
+
async searchEntrepreneurs(regex, queryWords) {
|
|
4773
4752
|
const entrepreneurModel = new Entrepreneur(this.storage);
|
|
4774
4753
|
const results = [];
|
|
4775
4754
|
let filter;
|
|
@@ -4778,18 +4757,18 @@ class SearchService {
|
|
|
4778
4757
|
deleted: false,
|
|
4779
4758
|
$or: [
|
|
4780
4759
|
// Поиск по отдельным полям
|
|
4781
|
-
{ first_name: { $regex:
|
|
4782
|
-
{ last_name: { $regex:
|
|
4783
|
-
{ middle_name: { $regex:
|
|
4784
|
-
{ "details.inn": { $regex:
|
|
4785
|
-
{ "details.ogrn": { $regex:
|
|
4760
|
+
{ first_name: { $regex: regex } },
|
|
4761
|
+
{ last_name: { $regex: regex } },
|
|
4762
|
+
{ middle_name: { $regex: regex } },
|
|
4763
|
+
{ "details.inn": { $regex: regex } },
|
|
4764
|
+
{ "details.ogrn": { $regex: regex } },
|
|
4786
4765
|
// Поиск по полному ФИО
|
|
4787
4766
|
{
|
|
4788
4767
|
$and: queryWords.map((word) => ({
|
|
4789
4768
|
$or: [
|
|
4790
|
-
{ first_name: { $regex:
|
|
4791
|
-
{ last_name: { $regex:
|
|
4792
|
-
{ middle_name: { $regex:
|
|
4769
|
+
{ first_name: { $regex: new RegExp(word, "i") } },
|
|
4770
|
+
{ last_name: { $regex: new RegExp(word, "i") } },
|
|
4771
|
+
{ middle_name: { $regex: new RegExp(word, "i") } }
|
|
4793
4772
|
]
|
|
4794
4773
|
}))
|
|
4795
4774
|
}
|
|
@@ -4799,36 +4778,28 @@ class SearchService {
|
|
|
4799
4778
|
filter = {
|
|
4800
4779
|
deleted: false,
|
|
4801
4780
|
$or: [
|
|
4802
|
-
{ first_name: { $regex:
|
|
4803
|
-
{ last_name: { $regex:
|
|
4804
|
-
{ middle_name: { $regex:
|
|
4805
|
-
{ "details.inn": { $regex:
|
|
4806
|
-
{ "details.ogrn": { $regex:
|
|
4781
|
+
{ first_name: { $regex: regex } },
|
|
4782
|
+
{ last_name: { $regex: regex } },
|
|
4783
|
+
{ middle_name: { $regex: regex } },
|
|
4784
|
+
{ "details.inn": { $regex: regex } },
|
|
4785
|
+
{ "details.ogrn": { $regex: regex } }
|
|
4807
4786
|
]
|
|
4808
4787
|
};
|
|
4809
4788
|
}
|
|
4810
|
-
console.log(`[SearchService] \u0424\u0438\u043B\u044C\u0442\u0440 \u0434\u043B\u044F entrepreneurs:`, JSON.stringify(filter, null, 2));
|
|
4811
4789
|
const entrepreneurs = await entrepreneurModel.getMany(filter);
|
|
4812
|
-
console.log(`[SearchService] \u0420\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442\u044B \u043F\u043E\u0438\u0441\u043A\u0430 entrepreneurs:`, {
|
|
4813
|
-
total: entrepreneurs.totalResults,
|
|
4814
|
-
found: entrepreneurs.results.length,
|
|
4815
|
-
query: originalQuery,
|
|
4816
|
-
names: entrepreneurs.results.map((ent) => `${ent.last_name} ${ent.first_name} ${ent.middle_name || ""} (deleted: ${ent.deleted || false})`)
|
|
4817
|
-
});
|
|
4818
4790
|
for (const entrepreneur of entrepreneurs.results) {
|
|
4819
4791
|
const highlightedFields = [];
|
|
4820
|
-
|
|
4821
|
-
if (entrepreneur.first_name && testRegex.test(entrepreneur.first_name))
|
|
4792
|
+
if (regex.test(entrepreneur.first_name))
|
|
4822
4793
|
highlightedFields.push("first_name");
|
|
4823
|
-
if (
|
|
4794
|
+
if (regex.test(entrepreneur.last_name))
|
|
4824
4795
|
highlightedFields.push("last_name");
|
|
4825
|
-
if (
|
|
4796
|
+
if (regex.test(entrepreneur.middle_name))
|
|
4826
4797
|
highlightedFields.push("middle_name");
|
|
4827
|
-
if (entrepreneur.details?.inn &&
|
|
4798
|
+
if (entrepreneur.details?.inn && regex.test(entrepreneur.details.inn))
|
|
4828
4799
|
highlightedFields.push("details.inn");
|
|
4829
|
-
if (entrepreneur.details?.ogrn &&
|
|
4800
|
+
if (entrepreneur.details?.ogrn && regex.test(entrepreneur.details.ogrn))
|
|
4830
4801
|
highlightedFields.push("details.ogrn");
|
|
4831
|
-
const fullName = `${entrepreneur.last_name
|
|
4802
|
+
const fullName = `${entrepreneur.last_name} ${entrepreneur.first_name} ${entrepreneur.middle_name}`.trim();
|
|
4832
4803
|
if (this.matchesFullName(fullName, queryWords)) {
|
|
4833
4804
|
highlightedFields.push("full_name");
|
|
4834
4805
|
}
|
|
@@ -4840,25 +4811,24 @@ class SearchService {
|
|
|
4840
4811
|
}
|
|
4841
4812
|
return results;
|
|
4842
4813
|
}
|
|
4843
|
-
async searchOrganizations(
|
|
4814
|
+
async searchOrganizations(regex) {
|
|
4844
4815
|
const organizationModel = new Organization(this.storage);
|
|
4845
4816
|
const results = [];
|
|
4846
4817
|
const organizations = await organizationModel.getMany({
|
|
4847
4818
|
deleted: false,
|
|
4848
4819
|
$or: [
|
|
4849
|
-
{ short_name: { $regex:
|
|
4850
|
-
{ "details.inn": { $regex:
|
|
4851
|
-
{ "details.ogrn": { $regex:
|
|
4820
|
+
{ short_name: { $regex: regex } },
|
|
4821
|
+
{ "details.inn": { $regex: regex } },
|
|
4822
|
+
{ "details.ogrn": { $regex: regex } }
|
|
4852
4823
|
]
|
|
4853
4824
|
});
|
|
4854
4825
|
for (const organization of organizations.results) {
|
|
4855
4826
|
const highlightedFields = [];
|
|
4856
|
-
|
|
4857
|
-
if (testRegex.test(organization.short_name))
|
|
4827
|
+
if (regex.test(organization.short_name))
|
|
4858
4828
|
highlightedFields.push("short_name");
|
|
4859
|
-
if (organization.details?.inn &&
|
|
4829
|
+
if (organization.details?.inn && regex.test(organization.details.inn))
|
|
4860
4830
|
highlightedFields.push("details.inn");
|
|
4861
|
-
if (organization.details?.ogrn &&
|
|
4831
|
+
if (organization.details?.ogrn && regex.test(organization.details.ogrn))
|
|
4862
4832
|
highlightedFields.push("details.ogrn");
|
|
4863
4833
|
results.push({
|
|
4864
4834
|
type: "organization",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coopenomics/factory",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2025.7.1
|
|
4
|
+
"version": "2025.7.1",
|
|
5
5
|
"packageManager": "pnpm@9.0.6",
|
|
6
6
|
"description": "",
|
|
7
7
|
"author": "Alex Ant <chairman.voskhod@gmail.com>",
|
|
@@ -43,15 +43,14 @@
|
|
|
43
43
|
"prepublishOnly": "nr build",
|
|
44
44
|
"release": "bumpp && npm publish",
|
|
45
45
|
"test": "vitest --dir test --testTimeout=240000 --exclude documents --watch=false",
|
|
46
|
-
"typecheck": "tsc --noEmit"
|
|
47
|
-
"setup-indexes": "tsx scripts/setup-indexes.ts"
|
|
46
|
+
"typecheck": "tsc --noEmit"
|
|
48
47
|
},
|
|
49
48
|
"dependencies": {
|
|
50
49
|
"ajv": "^8.13.0",
|
|
51
50
|
"ajv-formats": "^3.0.1",
|
|
52
51
|
"ajv-i18n": "^4.2.0",
|
|
53
52
|
"axios": "^1.7.2",
|
|
54
|
-
"cooptypes": "2025.7.1
|
|
53
|
+
"cooptypes": "2025.7.1",
|
|
55
54
|
"dotenv": "^16.4.5",
|
|
56
55
|
"eosjs-ecc": "^4.0.7",
|
|
57
56
|
"handlebars": "^4.7.8",
|
|
@@ -92,5 +91,5 @@
|
|
|
92
91
|
"vite@>=5.1.0 <=5.1.6": ">=5.1.7"
|
|
93
92
|
}
|
|
94
93
|
},
|
|
95
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "ac8836628eb82672b481dbf86050918f41bf24ca"
|
|
96
95
|
}
|