@coopenomics/factory 2025.6.14 → 2025.6.24
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 +282 -86
- package/dist/index.d.cts +13 -3
- package/dist/index.d.mts +13 -3
- package/dist/index.d.ts +13 -3
- package/dist/index.mjs +282 -86
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1691,9 +1691,10 @@ const Schema$4 = {
|
|
|
1691
1691
|
questions: {
|
|
1692
1692
|
type: "array",
|
|
1693
1693
|
items: AgendaQuestionSchema
|
|
1694
|
-
}
|
|
1694
|
+
},
|
|
1695
|
+
is_repeated: { type: "boolean" }
|
|
1695
1696
|
},
|
|
1696
|
-
required: ["meta", "coop", "vars", "meet", "user", "questions"],
|
|
1697
|
+
required: ["meta", "coop", "vars", "meet", "user", "questions", "is_repeated"],
|
|
1697
1698
|
additionalProperties: true
|
|
1698
1699
|
};
|
|
1699
1700
|
const Template$4 = {
|
|
@@ -1723,9 +1724,10 @@ const Schema$3 = {
|
|
|
1723
1724
|
questions: {
|
|
1724
1725
|
type: "array",
|
|
1725
1726
|
items: MeetPointSchema
|
|
1726
|
-
}
|
|
1727
|
+
},
|
|
1728
|
+
is_repeated: { type: "boolean" }
|
|
1727
1729
|
},
|
|
1728
|
-
required: ["meta", "coop", "vars", "decision", "meet", "questions"],
|
|
1730
|
+
required: ["meta", "coop", "vars", "decision", "meet", "questions", "is_repeated"],
|
|
1729
1731
|
additionalProperties: true
|
|
1730
1732
|
};
|
|
1731
1733
|
const Template$3 = {
|
|
@@ -1897,10 +1899,10 @@ const Registry = {
|
|
|
1897
1899
|
1010: InvestMembershipConvertation
|
|
1898
1900
|
};
|
|
1899
1901
|
|
|
1900
|
-
var __defProp$
|
|
1901
|
-
var __defNormalProp$
|
|
1902
|
-
var __publicField$
|
|
1903
|
-
__defNormalProp$
|
|
1902
|
+
var __defProp$d = Object.defineProperty;
|
|
1903
|
+
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1904
|
+
var __publicField$d = (obj, key, value) => {
|
|
1905
|
+
__defNormalProp$d(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1904
1906
|
return value;
|
|
1905
1907
|
};
|
|
1906
1908
|
const ajv = new Ajv__default();
|
|
@@ -1911,8 +1913,8 @@ ajv.addFormat("phone", {
|
|
|
1911
1913
|
});
|
|
1912
1914
|
class Validator {
|
|
1913
1915
|
constructor(schema, data) {
|
|
1914
|
-
__publicField$
|
|
1915
|
-
__publicField$
|
|
1916
|
+
__publicField$d(this, "schema");
|
|
1917
|
+
__publicField$d(this, "data");
|
|
1916
1918
|
this.schema = schema;
|
|
1917
1919
|
this.data = data;
|
|
1918
1920
|
}
|
|
@@ -1930,16 +1932,16 @@ class Validator {
|
|
|
1930
1932
|
}
|
|
1931
1933
|
}
|
|
1932
1934
|
|
|
1933
|
-
var __defProp$
|
|
1934
|
-
var __defNormalProp$
|
|
1935
|
-
var __publicField$
|
|
1936
|
-
__defNormalProp$
|
|
1935
|
+
var __defProp$c = Object.defineProperty;
|
|
1936
|
+
var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1937
|
+
var __publicField$c = (obj, key, value) => {
|
|
1938
|
+
__defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1937
1939
|
return value;
|
|
1938
1940
|
};
|
|
1939
1941
|
class DataService {
|
|
1940
1942
|
constructor(dbConnector, collectionName) {
|
|
1941
|
-
__publicField$
|
|
1942
|
-
__publicField$
|
|
1943
|
+
__publicField$c(this, "collection");
|
|
1944
|
+
__publicField$c(this, "state");
|
|
1943
1945
|
this.collection = dbConnector.getCollection(collectionName);
|
|
1944
1946
|
this.state = dbConnector.getCollection("sync");
|
|
1945
1947
|
}
|
|
@@ -2025,16 +2027,16 @@ async function getCurrentBlock() {
|
|
|
2025
2027
|
return block_num;
|
|
2026
2028
|
}
|
|
2027
2029
|
|
|
2028
|
-
var __defProp$
|
|
2029
|
-
var __defNormalProp$
|
|
2030
|
-
var __publicField$
|
|
2031
|
-
__defNormalProp$
|
|
2030
|
+
var __defProp$b = Object.defineProperty;
|
|
2031
|
+
var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2032
|
+
var __publicField$b = (obj, key, value) => {
|
|
2033
|
+
__defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2032
2034
|
return value;
|
|
2033
2035
|
};
|
|
2034
2036
|
class Individual {
|
|
2035
2037
|
constructor(storage, data) {
|
|
2036
|
-
__publicField$
|
|
2037
|
-
__publicField$
|
|
2038
|
+
__publicField$b(this, "individual");
|
|
2039
|
+
__publicField$b(this, "data_service");
|
|
2038
2040
|
this.individual = data;
|
|
2039
2041
|
this.data_service = new DataService$1(storage, "individuals");
|
|
2040
2042
|
}
|
|
@@ -2067,17 +2069,17 @@ class Individual {
|
|
|
2067
2069
|
}
|
|
2068
2070
|
}
|
|
2069
2071
|
|
|
2070
|
-
var __defProp$
|
|
2071
|
-
var __defNormalProp$
|
|
2072
|
-
var __publicField$
|
|
2073
|
-
__defNormalProp$
|
|
2072
|
+
var __defProp$a = Object.defineProperty;
|
|
2073
|
+
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2074
|
+
var __publicField$a = (obj, key, value) => {
|
|
2075
|
+
__defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2074
2076
|
return value;
|
|
2075
2077
|
};
|
|
2076
2078
|
class Organization {
|
|
2077
2079
|
constructor(storage, data) {
|
|
2078
|
-
__publicField$
|
|
2079
|
-
__publicField$
|
|
2080
|
-
__publicField$
|
|
2080
|
+
__publicField$a(this, "db");
|
|
2081
|
+
__publicField$a(this, "organization");
|
|
2082
|
+
__publicField$a(this, "data_service");
|
|
2081
2083
|
this.db = storage;
|
|
2082
2084
|
this.organization = data;
|
|
2083
2085
|
this.data_service = new DataService$1(storage, "organizations");
|
|
@@ -2123,17 +2125,17 @@ class Organization {
|
|
|
2123
2125
|
}
|
|
2124
2126
|
}
|
|
2125
2127
|
|
|
2126
|
-
var __defProp$
|
|
2127
|
-
var __defNormalProp$
|
|
2128
|
-
var __publicField$
|
|
2129
|
-
__defNormalProp$
|
|
2128
|
+
var __defProp$9 = Object.defineProperty;
|
|
2129
|
+
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2130
|
+
var __publicField$9 = (obj, key, value) => {
|
|
2131
|
+
__defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2130
2132
|
return value;
|
|
2131
2133
|
};
|
|
2132
2134
|
class Entrepreneur {
|
|
2133
2135
|
constructor(storage, data) {
|
|
2134
|
-
__publicField$
|
|
2135
|
-
__publicField$
|
|
2136
|
-
__publicField$
|
|
2136
|
+
__publicField$9(this, "db");
|
|
2137
|
+
__publicField$9(this, "entrepreneur");
|
|
2138
|
+
__publicField$9(this, "data_service");
|
|
2137
2139
|
this.db = storage;
|
|
2138
2140
|
this.entrepreneur = data;
|
|
2139
2141
|
this.data_service = new DataService$1(storage, "entrepreneurs");
|
|
@@ -2201,17 +2203,17 @@ function getEnvVar(key) {
|
|
|
2201
2203
|
return envVar;
|
|
2202
2204
|
}
|
|
2203
2205
|
|
|
2204
|
-
var __defProp$
|
|
2205
|
-
var __defNormalProp$
|
|
2206
|
-
var __publicField$
|
|
2207
|
-
__defNormalProp$
|
|
2206
|
+
var __defProp$8 = Object.defineProperty;
|
|
2207
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2208
|
+
var __publicField$8 = (obj, key, value) => {
|
|
2209
|
+
__defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2208
2210
|
return value;
|
|
2209
2211
|
};
|
|
2210
2212
|
class Cooperative {
|
|
2211
2213
|
constructor(storage) {
|
|
2212
|
-
__publicField$
|
|
2213
|
-
__publicField$
|
|
2214
|
-
__publicField$
|
|
2214
|
+
__publicField$8(this, "cooperative");
|
|
2215
|
+
__publicField$8(this, "db");
|
|
2216
|
+
__publicField$8(this, "data_service");
|
|
2215
2217
|
this.db = storage;
|
|
2216
2218
|
this.cooperative = null;
|
|
2217
2219
|
this.data_service = new DataService$1(storage, "cooperatives");
|
|
@@ -2269,17 +2271,17 @@ class Cooperative {
|
|
|
2269
2271
|
}
|
|
2270
2272
|
}
|
|
2271
2273
|
|
|
2272
|
-
var __defProp$
|
|
2273
|
-
var __defNormalProp$
|
|
2274
|
-
var __publicField$
|
|
2275
|
-
__defNormalProp$
|
|
2274
|
+
var __defProp$7 = Object.defineProperty;
|
|
2275
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2276
|
+
var __publicField$7 = (obj, key, value) => {
|
|
2277
|
+
__defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2276
2278
|
return value;
|
|
2277
2279
|
};
|
|
2278
2280
|
class PaymentMethod {
|
|
2279
2281
|
constructor(storage, data) {
|
|
2280
|
-
__publicField$
|
|
2281
|
-
__publicField$
|
|
2282
|
-
__publicField$
|
|
2282
|
+
__publicField$7(this, "db");
|
|
2283
|
+
__publicField$7(this, "paymentMethod");
|
|
2284
|
+
__publicField$7(this, "data_service");
|
|
2283
2285
|
this.db = storage;
|
|
2284
2286
|
this.paymentMethod = data;
|
|
2285
2287
|
this.data_service = new DataService$1(storage, "paymentMethods");
|
|
@@ -2310,16 +2312,16 @@ class PaymentMethod {
|
|
|
2310
2312
|
}
|
|
2311
2313
|
}
|
|
2312
2314
|
|
|
2313
|
-
var __defProp$
|
|
2314
|
-
var __defNormalProp$
|
|
2315
|
-
var __publicField$
|
|
2316
|
-
__defNormalProp$
|
|
2315
|
+
var __defProp$6 = Object.defineProperty;
|
|
2316
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2317
|
+
var __publicField$6 = (obj, key, value) => {
|
|
2318
|
+
__defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2317
2319
|
return value;
|
|
2318
2320
|
};
|
|
2319
2321
|
class Vars {
|
|
2320
2322
|
constructor(storage, data) {
|
|
2321
|
-
__publicField$
|
|
2322
|
-
__publicField$
|
|
2323
|
+
__publicField$6(this, "data");
|
|
2324
|
+
__publicField$6(this, "data_service");
|
|
2323
2325
|
this.data = data;
|
|
2324
2326
|
this.data_service = new DataService$1(storage, "vars");
|
|
2325
2327
|
}
|
|
@@ -2365,16 +2367,16 @@ const projectSchema = {
|
|
|
2365
2367
|
additionalProperties: true
|
|
2366
2368
|
};
|
|
2367
2369
|
|
|
2368
|
-
var __defProp$
|
|
2369
|
-
var __defNormalProp$
|
|
2370
|
-
var __publicField$
|
|
2371
|
-
__defNormalProp$
|
|
2370
|
+
var __defProp$5 = Object.defineProperty;
|
|
2371
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2372
|
+
var __publicField$5 = (obj, key, value) => {
|
|
2373
|
+
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2372
2374
|
return value;
|
|
2373
2375
|
};
|
|
2374
2376
|
class Project {
|
|
2375
2377
|
constructor(storage, data) {
|
|
2376
|
-
__publicField$
|
|
2377
|
-
__publicField$
|
|
2378
|
+
__publicField$5(this, "project");
|
|
2379
|
+
__publicField$5(this, "data_service");
|
|
2378
2380
|
this.project = data;
|
|
2379
2381
|
this.data_service = new DataService$1(storage, "projects");
|
|
2380
2382
|
}
|
|
@@ -2407,16 +2409,16 @@ class Project {
|
|
|
2407
2409
|
}
|
|
2408
2410
|
}
|
|
2409
2411
|
|
|
2410
|
-
var __defProp$
|
|
2411
|
-
var __defNormalProp$
|
|
2412
|
-
var __publicField$
|
|
2413
|
-
__defNormalProp$
|
|
2412
|
+
var __defProp$4 = Object.defineProperty;
|
|
2413
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2414
|
+
var __publicField$4 = (obj, key, value) => {
|
|
2415
|
+
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2414
2416
|
return value;
|
|
2415
2417
|
};
|
|
2416
2418
|
class TransExtension {
|
|
2417
2419
|
constructor(translation) {
|
|
2418
|
-
__publicField$
|
|
2419
|
-
__publicField$
|
|
2420
|
+
__publicField$4(this, "tags", ["trans"]);
|
|
2421
|
+
__publicField$4(this, "translation");
|
|
2420
2422
|
this.translation = translation;
|
|
2421
2423
|
}
|
|
2422
2424
|
parse(parser, nodes) {
|
|
@@ -2435,7 +2437,7 @@ class TransExtension {
|
|
|
2435
2437
|
}
|
|
2436
2438
|
class TemplateEngine {
|
|
2437
2439
|
constructor(translation) {
|
|
2438
|
-
__publicField$
|
|
2440
|
+
__publicField$4(this, "env");
|
|
2439
2441
|
this.env = new nunjucks__default.Environment();
|
|
2440
2442
|
const transExtension = new TransExtension(translation);
|
|
2441
2443
|
this.env.addExtension("TransExtension", transExtension);
|
|
@@ -2515,7 +2517,7 @@ class PDFService {
|
|
|
2515
2517
|
|
|
2516
2518
|
const name = "@coopenomics/factory";
|
|
2517
2519
|
const type = "module";
|
|
2518
|
-
const version = "2025.6.
|
|
2520
|
+
const version = "2025.6.24";
|
|
2519
2521
|
const packageManager = "pnpm@9.0.6";
|
|
2520
2522
|
const description = "";
|
|
2521
2523
|
const author = "Alex Ant <chairman.voskhod@gmail.com>";
|
|
@@ -2565,7 +2567,7 @@ const dependencies = {
|
|
|
2565
2567
|
"ajv-formats": "^3.0.1",
|
|
2566
2568
|
"ajv-i18n": "^4.2.0",
|
|
2567
2569
|
axios: "^1.7.2",
|
|
2568
|
-
cooptypes: "2025.6.
|
|
2570
|
+
cooptypes: "2025.6.24",
|
|
2569
2571
|
dotenv: "^16.4.5",
|
|
2570
2572
|
"eosjs-ecc": "^4.0.7",
|
|
2571
2573
|
handlebars: "^4.7.8",
|
|
@@ -2606,7 +2608,7 @@ const pnpm = {
|
|
|
2606
2608
|
"vite@>=5.1.0 <=5.1.6": ">=5.1.7"
|
|
2607
2609
|
}
|
|
2608
2610
|
};
|
|
2609
|
-
const gitHead = "
|
|
2611
|
+
const gitHead = "32e6a45f0597e651c2f3ab787462f7aa723c1732";
|
|
2610
2612
|
const packageJson = {
|
|
2611
2613
|
name: name,
|
|
2612
2614
|
type: type,
|
|
@@ -2667,16 +2669,16 @@ function formatDateTime(timestamp) {
|
|
|
2667
2669
|
return `${day} ${month} ${year} ${hours}:${minutes} (\u041C\u0441\u043A)`;
|
|
2668
2670
|
}
|
|
2669
2671
|
|
|
2670
|
-
var __defProp$
|
|
2671
|
-
var __defNormalProp$
|
|
2672
|
-
var __publicField$
|
|
2673
|
-
__defNormalProp$
|
|
2672
|
+
var __defProp$3 = Object.defineProperty;
|
|
2673
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2674
|
+
var __publicField$3 = (obj, key, value) => {
|
|
2675
|
+
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2674
2676
|
return value;
|
|
2675
2677
|
};
|
|
2676
2678
|
const packageVersion = packageJson.version;
|
|
2677
2679
|
class DocFactory {
|
|
2678
2680
|
constructor(storage) {
|
|
2679
|
-
__publicField$
|
|
2681
|
+
__publicField$3(this, "storage");
|
|
2680
2682
|
this.storage = storage;
|
|
2681
2683
|
}
|
|
2682
2684
|
async validate(combinedData, schema) {
|
|
@@ -3924,13 +3926,15 @@ let Factory$4 = class Factory extends DocFactory {
|
|
|
3924
3926
|
const user = super.getCommonUser(userData);
|
|
3925
3927
|
const meet = { ...data.meet };
|
|
3926
3928
|
const questions = [...data.questions];
|
|
3929
|
+
console.log("coop os: ", coop);
|
|
3927
3930
|
const combinedData = {
|
|
3928
3931
|
meta,
|
|
3929
3932
|
coop,
|
|
3930
3933
|
vars,
|
|
3931
3934
|
meet,
|
|
3932
3935
|
questions,
|
|
3933
|
-
user
|
|
3936
|
+
user,
|
|
3937
|
+
is_repeated: data.is_repeated
|
|
3934
3938
|
};
|
|
3935
3939
|
await super.validate(combinedData, template.model);
|
|
3936
3940
|
const translation = template.translations[meta.lang];
|
|
@@ -3957,6 +3961,7 @@ let Factory$3 = class Factory extends DocFactory {
|
|
|
3957
3961
|
} else {
|
|
3958
3962
|
template = await this.getTemplate(cooptypes.DraftContract.contractName.production, registry_id$3, data.block_num);
|
|
3959
3963
|
}
|
|
3964
|
+
console.log("data on gerate soviet decision", data);
|
|
3960
3965
|
const meta = await super.getMeta({ title: template.title, ...data });
|
|
3961
3966
|
const coop = await super.getCooperative(data.coopname, data.block_num);
|
|
3962
3967
|
const vars = await super.getVars(data.coopname, data.block_num);
|
|
@@ -3969,7 +3974,8 @@ let Factory$3 = class Factory extends DocFactory {
|
|
|
3969
3974
|
vars,
|
|
3970
3975
|
decision,
|
|
3971
3976
|
meet,
|
|
3972
|
-
questions
|
|
3977
|
+
questions,
|
|
3978
|
+
is_repeated: data.is_repeated
|
|
3973
3979
|
};
|
|
3974
3980
|
await super.validate(combinedData, template.model);
|
|
3975
3981
|
const translation = template.translations[meta.lang];
|
|
@@ -4116,17 +4122,17 @@ class Factory extends DocFactory {
|
|
|
4116
4122
|
}
|
|
4117
4123
|
}
|
|
4118
4124
|
|
|
4119
|
-
var __defProp$
|
|
4120
|
-
var __defNormalProp$
|
|
4121
|
-
var __publicField$
|
|
4122
|
-
__defNormalProp$
|
|
4125
|
+
var __defProp$2 = Object.defineProperty;
|
|
4126
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4127
|
+
var __publicField$2 = (obj, key, value) => {
|
|
4128
|
+
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4123
4129
|
return value;
|
|
4124
4130
|
};
|
|
4125
4131
|
class MongoDBConnector {
|
|
4126
4132
|
constructor(uri) {
|
|
4127
|
-
__publicField$
|
|
4128
|
-
__publicField$
|
|
4129
|
-
__publicField$
|
|
4133
|
+
__publicField$2(this, "client");
|
|
4134
|
+
__publicField$2(this, "db");
|
|
4135
|
+
__publicField$2(this, "documents");
|
|
4130
4136
|
this.client = new mongodb.MongoClient(uri);
|
|
4131
4137
|
const dbName = this.extractDbNameFromUri(uri);
|
|
4132
4138
|
if (!dbName)
|
|
@@ -4161,6 +4167,189 @@ class MongoDBConnector {
|
|
|
4161
4167
|
}
|
|
4162
4168
|
}
|
|
4163
4169
|
|
|
4170
|
+
var __defProp$1 = Object.defineProperty;
|
|
4171
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4172
|
+
var __publicField$1 = (obj, key, value) => {
|
|
4173
|
+
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4174
|
+
return value;
|
|
4175
|
+
};
|
|
4176
|
+
class SearchService {
|
|
4177
|
+
constructor(storage) {
|
|
4178
|
+
__publicField$1(this, "storage");
|
|
4179
|
+
this.storage = storage;
|
|
4180
|
+
}
|
|
4181
|
+
async search(query) {
|
|
4182
|
+
if (!query || query.trim().length === 0) {
|
|
4183
|
+
return [];
|
|
4184
|
+
}
|
|
4185
|
+
const results = [];
|
|
4186
|
+
const trimmedQuery = query.trim();
|
|
4187
|
+
const regex = new RegExp(trimmedQuery, "i");
|
|
4188
|
+
const queryWords = trimmedQuery.split(/\s+/).filter((word) => word.length > 0);
|
|
4189
|
+
try {
|
|
4190
|
+
const individualResults = await this.searchIndividuals(regex, queryWords);
|
|
4191
|
+
results.push(...individualResults);
|
|
4192
|
+
const entrepreneurResults = await this.searchEntrepreneurs(regex, queryWords);
|
|
4193
|
+
results.push(...entrepreneurResults);
|
|
4194
|
+
const organizationResults = await this.searchOrganizations(regex);
|
|
4195
|
+
results.push(...organizationResults);
|
|
4196
|
+
return results.slice(0, 10);
|
|
4197
|
+
} catch (error) {
|
|
4198
|
+
console.error("Error during search:", error);
|
|
4199
|
+
return [];
|
|
4200
|
+
}
|
|
4201
|
+
}
|
|
4202
|
+
async searchIndividuals(regex, queryWords) {
|
|
4203
|
+
const individualModel = new Individual(this.storage);
|
|
4204
|
+
const results = [];
|
|
4205
|
+
let filter;
|
|
4206
|
+
if (queryWords.length > 1) {
|
|
4207
|
+
filter = {
|
|
4208
|
+
deleted: false,
|
|
4209
|
+
$or: [
|
|
4210
|
+
// Поиск по отдельным полям
|
|
4211
|
+
{ first_name: { $regex: regex } },
|
|
4212
|
+
{ last_name: { $regex: regex } },
|
|
4213
|
+
{ middle_name: { $regex: regex } },
|
|
4214
|
+
// Поиск по полному ФИО (все слова должны быть найдены)
|
|
4215
|
+
{
|
|
4216
|
+
$and: queryWords.map((word) => ({
|
|
4217
|
+
$or: [
|
|
4218
|
+
{ first_name: { $regex: new RegExp(word, "i") } },
|
|
4219
|
+
{ last_name: { $regex: new RegExp(word, "i") } },
|
|
4220
|
+
{ middle_name: { $regex: new RegExp(word, "i") } }
|
|
4221
|
+
]
|
|
4222
|
+
}))
|
|
4223
|
+
}
|
|
4224
|
+
]
|
|
4225
|
+
};
|
|
4226
|
+
} else {
|
|
4227
|
+
filter = {
|
|
4228
|
+
deleted: false,
|
|
4229
|
+
$or: [
|
|
4230
|
+
{ first_name: { $regex: regex } },
|
|
4231
|
+
{ last_name: { $regex: regex } },
|
|
4232
|
+
{ middle_name: { $regex: regex } }
|
|
4233
|
+
]
|
|
4234
|
+
};
|
|
4235
|
+
}
|
|
4236
|
+
const individuals = await individualModel.getMany(filter);
|
|
4237
|
+
for (const individual of individuals.results) {
|
|
4238
|
+
const highlightedFields = [];
|
|
4239
|
+
if (regex.test(individual.first_name))
|
|
4240
|
+
highlightedFields.push("first_name");
|
|
4241
|
+
if (regex.test(individual.last_name))
|
|
4242
|
+
highlightedFields.push("last_name");
|
|
4243
|
+
if (regex.test(individual.middle_name))
|
|
4244
|
+
highlightedFields.push("middle_name");
|
|
4245
|
+
const fullName = `${individual.last_name} ${individual.first_name} ${individual.middle_name}`.trim();
|
|
4246
|
+
if (this.matchesFullName(fullName, queryWords)) {
|
|
4247
|
+
highlightedFields.push("full_name");
|
|
4248
|
+
}
|
|
4249
|
+
results.push({
|
|
4250
|
+
type: "individual",
|
|
4251
|
+
data: individual,
|
|
4252
|
+
highlightedFields
|
|
4253
|
+
});
|
|
4254
|
+
}
|
|
4255
|
+
return results;
|
|
4256
|
+
}
|
|
4257
|
+
async searchEntrepreneurs(regex, queryWords) {
|
|
4258
|
+
const entrepreneurModel = new Entrepreneur(this.storage);
|
|
4259
|
+
const results = [];
|
|
4260
|
+
let filter;
|
|
4261
|
+
if (queryWords.length > 1) {
|
|
4262
|
+
filter = {
|
|
4263
|
+
deleted: false,
|
|
4264
|
+
$or: [
|
|
4265
|
+
// Поиск по отдельным полям
|
|
4266
|
+
{ first_name: { $regex: regex } },
|
|
4267
|
+
{ last_name: { $regex: regex } },
|
|
4268
|
+
{ middle_name: { $regex: regex } },
|
|
4269
|
+
{ "details.inn": { $regex: regex } },
|
|
4270
|
+
{ "details.ogrn": { $regex: regex } },
|
|
4271
|
+
// Поиск по полному ФИО
|
|
4272
|
+
{
|
|
4273
|
+
$and: queryWords.map((word) => ({
|
|
4274
|
+
$or: [
|
|
4275
|
+
{ first_name: { $regex: new RegExp(word, "i") } },
|
|
4276
|
+
{ last_name: { $regex: new RegExp(word, "i") } },
|
|
4277
|
+
{ middle_name: { $regex: new RegExp(word, "i") } }
|
|
4278
|
+
]
|
|
4279
|
+
}))
|
|
4280
|
+
}
|
|
4281
|
+
]
|
|
4282
|
+
};
|
|
4283
|
+
} else {
|
|
4284
|
+
filter = {
|
|
4285
|
+
deleted: false,
|
|
4286
|
+
$or: [
|
|
4287
|
+
{ first_name: { $regex: regex } },
|
|
4288
|
+
{ last_name: { $regex: regex } },
|
|
4289
|
+
{ middle_name: { $regex: regex } },
|
|
4290
|
+
{ "details.inn": { $regex: regex } },
|
|
4291
|
+
{ "details.ogrn": { $regex: regex } }
|
|
4292
|
+
]
|
|
4293
|
+
};
|
|
4294
|
+
}
|
|
4295
|
+
const entrepreneurs = await entrepreneurModel.getMany(filter);
|
|
4296
|
+
for (const entrepreneur of entrepreneurs.results) {
|
|
4297
|
+
const highlightedFields = [];
|
|
4298
|
+
if (regex.test(entrepreneur.first_name))
|
|
4299
|
+
highlightedFields.push("first_name");
|
|
4300
|
+
if (regex.test(entrepreneur.last_name))
|
|
4301
|
+
highlightedFields.push("last_name");
|
|
4302
|
+
if (regex.test(entrepreneur.middle_name))
|
|
4303
|
+
highlightedFields.push("middle_name");
|
|
4304
|
+
if (entrepreneur.details?.inn && regex.test(entrepreneur.details.inn))
|
|
4305
|
+
highlightedFields.push("details.inn");
|
|
4306
|
+
if (entrepreneur.details?.ogrn && regex.test(entrepreneur.details.ogrn))
|
|
4307
|
+
highlightedFields.push("details.ogrn");
|
|
4308
|
+
const fullName = `${entrepreneur.last_name} ${entrepreneur.first_name} ${entrepreneur.middle_name}`.trim();
|
|
4309
|
+
if (this.matchesFullName(fullName, queryWords)) {
|
|
4310
|
+
highlightedFields.push("full_name");
|
|
4311
|
+
}
|
|
4312
|
+
results.push({
|
|
4313
|
+
type: "entrepreneur",
|
|
4314
|
+
data: entrepreneur,
|
|
4315
|
+
highlightedFields
|
|
4316
|
+
});
|
|
4317
|
+
}
|
|
4318
|
+
return results;
|
|
4319
|
+
}
|
|
4320
|
+
async searchOrganizations(regex) {
|
|
4321
|
+
const organizationModel = new Organization(this.storage);
|
|
4322
|
+
const results = [];
|
|
4323
|
+
const organizations = await organizationModel.getMany({
|
|
4324
|
+
deleted: false,
|
|
4325
|
+
$or: [
|
|
4326
|
+
{ short_name: { $regex: regex } },
|
|
4327
|
+
{ "details.inn": { $regex: regex } },
|
|
4328
|
+
{ "details.ogrn": { $regex: regex } }
|
|
4329
|
+
]
|
|
4330
|
+
});
|
|
4331
|
+
for (const organization of organizations.results) {
|
|
4332
|
+
const highlightedFields = [];
|
|
4333
|
+
if (regex.test(organization.short_name))
|
|
4334
|
+
highlightedFields.push("short_name");
|
|
4335
|
+
if (organization.details?.inn && regex.test(organization.details.inn))
|
|
4336
|
+
highlightedFields.push("details.inn");
|
|
4337
|
+
if (organization.details?.ogrn && regex.test(organization.details.ogrn))
|
|
4338
|
+
highlightedFields.push("details.ogrn");
|
|
4339
|
+
results.push({
|
|
4340
|
+
type: "organization",
|
|
4341
|
+
data: organization,
|
|
4342
|
+
highlightedFields
|
|
4343
|
+
});
|
|
4344
|
+
}
|
|
4345
|
+
return results;
|
|
4346
|
+
}
|
|
4347
|
+
matchesFullName(fullName, queryWords) {
|
|
4348
|
+
const fullNameLower = fullName.toLowerCase();
|
|
4349
|
+
return queryWords.every((word) => fullNameLower.includes(word.toLowerCase()));
|
|
4350
|
+
}
|
|
4351
|
+
}
|
|
4352
|
+
|
|
4164
4353
|
var __defProp = Object.defineProperty;
|
|
4165
4354
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4166
4355
|
var __publicField = (obj, key, value) => {
|
|
@@ -4173,10 +4362,13 @@ class Generator {
|
|
|
4173
4362
|
__publicField(this, "factories");
|
|
4174
4363
|
// Определение хранилища
|
|
4175
4364
|
__publicField(this, "storage");
|
|
4365
|
+
// Сервис поиска
|
|
4366
|
+
__publicField(this, "searchService");
|
|
4176
4367
|
}
|
|
4177
4368
|
// Метод подключения к хранилищу
|
|
4178
4369
|
async connect(mongoUri) {
|
|
4179
4370
|
this.storage = new MongoDBConnector(mongoUri);
|
|
4371
|
+
this.searchService = new SearchService(this.storage);
|
|
4180
4372
|
this.factories = {
|
|
4181
4373
|
[registry_id$q]: new Factory$q(this.storage),
|
|
4182
4374
|
// 1
|
|
@@ -4295,6 +4487,10 @@ class Generator {
|
|
|
4295
4487
|
async constructCooperative(username, block_num) {
|
|
4296
4488
|
return new Cooperative(this.storage).getOne(username, block_num);
|
|
4297
4489
|
}
|
|
4490
|
+
// Новый метод поиска
|
|
4491
|
+
async search(query) {
|
|
4492
|
+
return this.searchService.search(query);
|
|
4493
|
+
}
|
|
4298
4494
|
}
|
|
4299
4495
|
|
|
4300
4496
|
exports.AgendaMeetSchema = AgendaMeetSchema;
|
package/dist/index.d.cts
CHANGED
|
@@ -457,6 +457,10 @@ type internalFilterTypes = InternalIndividualData | InternalEntrepreneurData | I
|
|
|
457
457
|
type externalDataTypes = ExternalIndividualData | ExternalEntrepreneurData | ExternalOrganizationData | PaymentData | IVars | ExternalProjectData;
|
|
458
458
|
type externalDataTypesArrays = ExternalIndividualData[] | ExternalEntrepreneurData[] | ExternalOrganizationData[] | PaymentData[] | IVars[] | ExternalProjectData[];
|
|
459
459
|
|
|
460
|
+
interface IDocument {
|
|
461
|
+
[key: string]: any;
|
|
462
|
+
}
|
|
463
|
+
|
|
460
464
|
declare class MongoDBConnector {
|
|
461
465
|
client: MongoClient;
|
|
462
466
|
db: Db;
|
|
@@ -470,8 +474,11 @@ declare class MongoDBConnector {
|
|
|
470
474
|
saveDraft(document: IGeneratedDocument): Promise<void>;
|
|
471
475
|
}
|
|
472
476
|
|
|
473
|
-
interface
|
|
474
|
-
|
|
477
|
+
interface ISearchResult {
|
|
478
|
+
type: 'individual' | 'entrepreneur' | 'organization';
|
|
479
|
+
data: ExternalIndividualData | ExternalEntrepreneurData | ExternalOrganizationData;
|
|
480
|
+
score?: number;
|
|
481
|
+
highlightedFields?: string[];
|
|
475
482
|
}
|
|
476
483
|
|
|
477
484
|
type CooperativeData = Cooperative.Model.ICooperativeData;
|
|
@@ -612,12 +619,14 @@ interface IGenerator {
|
|
|
612
619
|
del: (type: dataTypes, filter: Filter<internalFilterTypes>) => Promise<UpdateResult>;
|
|
613
620
|
list: (type: dataTypes, filter: Filter<internalFilterTypes>) => Promise<Cooperative.Document.IGetResponse<internalFilterTypes>>;
|
|
614
621
|
getHistory: (type: dataTypes, filter: Filter<internalFilterTypes>) => Promise<externalDataTypesArrays>;
|
|
622
|
+
search: (query: string) => Promise<ISearchResult[]>;
|
|
615
623
|
}
|
|
616
624
|
declare class Generator implements IGenerator {
|
|
617
625
|
factories: {
|
|
618
626
|
[K in Numbers]: DocFactory<IGenerate>;
|
|
619
627
|
};
|
|
620
628
|
storage: MongoDBConnector;
|
|
629
|
+
private searchService;
|
|
621
630
|
connect(mongoUri: string): Promise<void>;
|
|
622
631
|
disconnect(): Promise<void>;
|
|
623
632
|
generate(data: IGenerate, options?: IGenerationOptions): Promise<IGeneratedDocument>;
|
|
@@ -634,6 +643,7 @@ declare class Generator implements IGenerator {
|
|
|
634
643
|
getHistory(type: 'individual' | 'entrepreneur' | 'organization' | 'paymentMethod' | 'vars' | 'project', filter: Filter<internalFilterTypes>): Promise<externalDataTypesArrays>;
|
|
635
644
|
getModel(type: dataTypes, data?: externalDataTypes): Individual | Entrepreneur | Organization | PaymentMethod | Vars | Project;
|
|
636
645
|
constructCooperative(username: string, block_num?: number): Promise<CooperativeData | null>;
|
|
646
|
+
search(query: string): Promise<ISearchResult[]>;
|
|
637
647
|
}
|
|
638
648
|
|
|
639
|
-
export { AgendaMeetSchema, AgendaQuestionSchema, AnnualGeneralMeetingAgenda, AnnualGeneralMeetingDecision, AnnualGeneralMeetingNotification, AnnualGeneralMeetingSovietDecision, AnnualGeneralMeetingVotingBallot, AssetContributionAct, AssetContributionDecision, AssetContributionStatement, BankAccountSchema, CommonUserSchema, CoopenomicsAgreement, CooperativeSchema, type Currency, DecisionOfParticipantApplication, FreeDecision, Generator, type IBCState, type IBankAccount, type ICombinedData, type CooperativeData as ICooperativeData, type ExternalEntrepreneurData as IEntrepreneurData, type ExternalProjectData as IExternalProjectData, type IFilterActions, type IFilterDeltas, type IFilterDocuments, type IGenerate, type IGeneratedDocument, type IGenerationOptions, type IGenerator, type ExternalIndividualData as IIndividualData, type IMetaDocument, type IMetaDocumentPartial, type ExternalOrganizationData as IOrganizationData, type IPaymentData, type ITemplate, type ITranslations, InvestByMoneyStatement, InvestByResultAct, InvestByResultStatement, InvestMembershipConvertation, InvestmentAgreement, type LangType, MeetPointSchema, MeetSchema, type NestedRecord, type Numbers, ParticipantApplication, PrivacyPolicy, ProjectFreeDecision, QuestionExtendedSchema, QuestionSchema, Registry, RegulationElectronicSignaturet as RegulationElectronicSignature, ReturnByAssetAct, ReturnByAssetDecision, ReturnByAssetStatement, SelectBranchStatement, SosediAgreement, UserAgreement, VarsSchema, WalletAgreement, type dataTypes, decisionSchema, entrepreneurSchema, type externalDataTypes, type externalDataTypesArrays, individualSchema, type internalFilterTypes, organizationSchema, paymentMethodSchema };
|
|
649
|
+
export { AgendaMeetSchema, AgendaQuestionSchema, AnnualGeneralMeetingAgenda, AnnualGeneralMeetingDecision, AnnualGeneralMeetingNotification, AnnualGeneralMeetingSovietDecision, AnnualGeneralMeetingVotingBallot, AssetContributionAct, AssetContributionDecision, AssetContributionStatement, BankAccountSchema, CommonUserSchema, CoopenomicsAgreement, CooperativeSchema, type Currency, DecisionOfParticipantApplication, FreeDecision, Generator, type IBCState, type IBankAccount, type ICombinedData, type CooperativeData as ICooperativeData, type ExternalEntrepreneurData as IEntrepreneurData, type ExternalProjectData as IExternalProjectData, type IFilterActions, type IFilterDeltas, type IFilterDocuments, type IGenerate, type IGeneratedDocument, type IGenerationOptions, type IGenerator, type ExternalIndividualData as IIndividualData, type IMetaDocument, type IMetaDocumentPartial, type ExternalOrganizationData as IOrganizationData, type IPaymentData, type ISearchResult, type ITemplate, type ITranslations, InvestByMoneyStatement, InvestByResultAct, InvestByResultStatement, InvestMembershipConvertation, InvestmentAgreement, type LangType, MeetPointSchema, MeetSchema, type NestedRecord, type Numbers, ParticipantApplication, PrivacyPolicy, ProjectFreeDecision, QuestionExtendedSchema, QuestionSchema, Registry, RegulationElectronicSignaturet as RegulationElectronicSignature, ReturnByAssetAct, ReturnByAssetDecision, ReturnByAssetStatement, SelectBranchStatement, SosediAgreement, UserAgreement, VarsSchema, WalletAgreement, type dataTypes, decisionSchema, entrepreneurSchema, type externalDataTypes, type externalDataTypesArrays, individualSchema, type internalFilterTypes, organizationSchema, paymentMethodSchema };
|