@coopenomics/docs-factory 1.3.0 → 1.5.0

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.
Files changed (3) hide show
  1. package/dist/index.cjs +252 -10
  2. package/dist/index.mjs +252 -10
  3. package/package.json +2 -2
package/dist/index.cjs CHANGED
@@ -2631,9 +2631,25 @@ const registry_id$M = docsTemplates.Registry.CapitalizationPropertyInvestStateme
2631
2631
  const Schema$M = {
2632
2632
  type: "object",
2633
2633
  properties: {
2634
- meta: IMetaJSONSchema
2635
- },
2636
- required: ["meta"],
2634
+ meta: IMetaJSONSchema,
2635
+ coop: CooperativeSchema,
2636
+ vars: VarsSchema,
2637
+ common_user: CommonUserSchema,
2638
+ contributor_contract_number: { type: "string" },
2639
+ contributor_contract_created_at: { type: "string" },
2640
+ blagorost_agreement_number: { type: "string" },
2641
+ blagorost_agreement_created_at: { type: "string" },
2642
+ property_hash: { type: "string" },
2643
+ property_short_hash: { type: "string" },
2644
+ property_name: { type: "string" },
2645
+ property_description: { type: "string" },
2646
+ property_quantity: { type: "string" },
2647
+ property_unit: { type: "string" },
2648
+ property_amount: { type: "string" },
2649
+ property_form: { type: "string", nullable: true },
2650
+ property_form_label: { type: "string", nullable: true }
2651
+ },
2652
+ required: ["meta", "coop", "vars", "common_user", "contributor_contract_number", "contributor_contract_created_at", "blagorost_agreement_number", "blagorost_agreement_created_at", "property_hash", "property_short_hash", "property_name", "property_description", "property_quantity", "property_unit", "property_amount"],
2637
2653
  additionalProperties: true
2638
2654
  };
2639
2655
  const Template$M = {
@@ -2655,9 +2671,26 @@ const registry_id$L = docsTemplates.Registry.CapitalizationPropertyInvestDecisio
2655
2671
  const Schema$L = {
2656
2672
  type: "object",
2657
2673
  properties: {
2658
- meta: IMetaJSONSchema
2659
- },
2660
- required: ["meta"],
2674
+ meta: IMetaJSONSchema,
2675
+ coop: CooperativeSchema,
2676
+ vars: VarsSchema,
2677
+ decision: decisionSchema,
2678
+ common_user: CommonUserSchema,
2679
+ contributor_contract_number: { type: "string" },
2680
+ contributor_contract_created_at: { type: "string" },
2681
+ blagorost_agreement_number: { type: "string" },
2682
+ blagorost_agreement_created_at: { type: "string" },
2683
+ property_hash: { type: "string" },
2684
+ property_short_hash: { type: "string" },
2685
+ property_name: { type: "string" },
2686
+ property_description: { type: "string" },
2687
+ property_quantity: { type: "string" },
2688
+ property_unit: { type: "string" },
2689
+ property_amount: { type: "string" },
2690
+ property_form: { type: "string", nullable: true },
2691
+ property_form_label: { type: "string", nullable: true }
2692
+ },
2693
+ required: ["meta", "coop", "vars", "decision", "common_user", "contributor_contract_number", "contributor_contract_created_at", "blagorost_agreement_number", "blagorost_agreement_created_at", "property_hash", "property_short_hash", "property_name", "property_description", "property_quantity", "property_unit", "property_amount"],
2661
2694
  additionalProperties: true
2662
2695
  };
2663
2696
  const Template$L = {
@@ -2679,9 +2712,26 @@ const registry_id$K = docsTemplates.Registry.CapitalizationPropertyInvestAct.reg
2679
2712
  const Schema$K = {
2680
2713
  type: "object",
2681
2714
  properties: {
2682
- meta: IMetaJSONSchema
2683
- },
2684
- required: ["meta"],
2715
+ meta: IMetaJSONSchema,
2716
+ coop: CooperativeSchema,
2717
+ vars: VarsSchema,
2718
+ decision: decisionSchema,
2719
+ common_user: CommonUserSchema,
2720
+ contributor_contract_number: { type: "string" },
2721
+ contributor_contract_created_at: { type: "string" },
2722
+ blagorost_agreement_number: { type: "string" },
2723
+ blagorost_agreement_created_at: { type: "string" },
2724
+ property_hash: { type: "string" },
2725
+ property_short_hash: { type: "string" },
2726
+ property_name: { type: "string" },
2727
+ property_description: { type: "string" },
2728
+ property_quantity: { type: "string" },
2729
+ property_unit: { type: "string" },
2730
+ property_amount: { type: "string" },
2731
+ property_form: { type: "string", nullable: true },
2732
+ property_form_label: { type: "string", nullable: true }
2733
+ },
2734
+ required: ["meta", "coop", "vars", "decision", "common_user", "contributor_contract_number", "contributor_contract_created_at", "blagorost_agreement_number", "blagorost_agreement_created_at", "property_hash", "property_short_hash", "property_name", "property_description", "property_quantity", "property_unit", "property_amount"],
2685
2735
  additionalProperties: true
2686
2736
  };
2687
2737
  const Template$K = {
@@ -5046,7 +5096,7 @@ function latestMinorOf(versions, major) {
5046
5096
 
5047
5097
  const name = "@coopenomics/docs-factory";
5048
5098
  const type = "module";
5049
- const version = "1.3.0";
5099
+ const version = "1.5.0";
5050
5100
  const description = "Фабрика документов цифрового кооператива: сборка документов по шаблонам, сборщики всех видов документов, версии сборщиков";
5051
5101
  const author = "Alex Ant <chairman.voskhod@gmail.com>";
5052
5102
  const license = "MIT";
@@ -8227,16 +8277,106 @@ const _1062_GenerationPropertyInvestAct = {
8227
8277
  Template: GenerationPropertyInvestAct
8228
8278
  };
8229
8279
 
8280
+ async function getBlagorostContractRef(sources, data) {
8281
+ const read = (key) => sources.udata({ coopname: data.coopname, username: data.username, key, block_num: data.block_num });
8282
+ const [contractNumber, contractCreatedAt, agreementNumber, agreementCreatedAt] = await Promise.all([
8283
+ read(docsTemplates.UdataKey.BLAGOROST_CONTRIBUTOR_CONTRACT_NUMBER),
8284
+ read(docsTemplates.UdataKey.BLAGOROST_CONTRIBUTOR_CONTRACT_CREATED_AT),
8285
+ read(docsTemplates.UdataKey.BLAGOROST_AGREEMENT_NUMBER),
8286
+ read(docsTemplates.UdataKey.BLAGOROST_AGREEMENT_CREATED_AT)
8287
+ ]);
8288
+ if (!contractNumber?.value)
8289
+ throw new Error("\u0414\u0430\u043D\u043D\u044B\u0435 \u0434\u043E\u0433\u043E\u0432\u043E\u0440\u0430 \u0423\u0425\u0414 \u0443\u0447\u0430\u0441\u0442\u043D\u0438\u043A\u0430 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u044B \u0432 Udata");
8290
+ if (!contractCreatedAt?.value)
8291
+ throw new Error("\u0414\u0430\u0442\u0430 \u0441\u043E\u0437\u0434\u0430\u043D\u0438\u044F \u0434\u043E\u0433\u043E\u0432\u043E\u0440\u0430 \u0423\u0425\u0414 \u0443\u0447\u0430\u0441\u0442\u043D\u0438\u043A\u0430 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u0430 \u0432 Udata");
8292
+ if (!agreementNumber?.value)
8293
+ throw new Error("\u0414\u0430\u043D\u043D\u044B\u0435 \u0441\u043E\u0433\u043B\u0430\u0448\u0435\u043D\u0438\u044F \u0431\u043B\u0430\u0433\u043E\u0440\u043E\u0441\u0442\u0430 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u044B \u0432 Udata");
8294
+ if (!agreementCreatedAt?.value)
8295
+ throw new Error("\u0414\u0430\u0442\u0430 \u0441\u043E\u0437\u0434\u0430\u043D\u0438\u044F \u0441\u043E\u0433\u043B\u0430\u0448\u0435\u043D\u0438\u044F \u0431\u043B\u0430\u0433\u043E\u0440\u043E\u0441\u0442\u0430 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u0430 \u0432 Udata");
8296
+ return {
8297
+ contributor_contract_number: String(contractNumber.value),
8298
+ contributor_contract_created_at: String(contractCreatedAt.value),
8299
+ blagorost_agreement_number: String(agreementNumber.value),
8300
+ blagorost_agreement_created_at: String(agreementCreatedAt.value)
8301
+ };
8302
+ }
8303
+ function propertyPositionFields(data) {
8304
+ return {
8305
+ property_hash: data.property_hash,
8306
+ property_short_hash: shortHash(data.property_hash),
8307
+ property_name: data.property_name,
8308
+ property_description: data.property_description,
8309
+ property_quantity: data.property_quantity,
8310
+ property_unit: data.property_unit,
8311
+ property_amount: formatAsset(data.property_amount)
8312
+ };
8313
+ }
8314
+ const PROPERTY_FORM_LABELS = {
8315
+ thing: "\u0412\u0435\u0449\u044C (\u0438\u043C\u0443\u0449\u0435\u0441\u0442\u0432\u043E \u0432 \u043D\u0430\u0442\u0443\u0440\u0430\u043B\u044C\u043D\u043E\u0439 \u0444\u043E\u0440\u043C\u0435)",
8316
+ intangible: "\u041D\u0435\u043C\u0430\u0442\u0435\u0440\u0438\u0430\u043B\u044C\u043D\u043E\u0435 \u0438\u043C\u0443\u0449\u0435\u0441\u0442\u0432\u043E \u0432 \u043E\u0431\u044A\u0435\u043A\u0442\u0438\u0432\u043D\u043E\u0439 \u0444\u043E\u0440\u043C\u0435 (\u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442, \u043C\u0435\u0442\u043E\u0434\u0438\u043A\u0430, \u0444\u0430\u0439\u043B)"
8317
+ };
8318
+ function propertyFormFields(data) {
8319
+ const form = data.property_form ?? "";
8320
+ return {
8321
+ property_form: form,
8322
+ property_form_label: PROPERTY_FORM_LABELS[form] ?? ""
8323
+ };
8324
+ }
8325
+
8230
8326
  const Factory$O = defineBuilder()({
8231
8327
  registry_id: registry_id$M,
8232
8328
  version: "1.0",
8233
8329
  reads: () => ({}),
8330
+ // Заглушка 1.0 собирала только мету и документов в цепях не дала; модель шаблона
8331
+ // с версии 1.1 шире (позиция имущества, реквизиты договоров). Код версии заморожен.
8332
+ // @ts-expect-error модель 1.1 требует полей, которых у заглушки нет
8234
8333
  assemble: ({ meta }) => ({ meta })
8235
8334
  });
8335
+ const Factory_1_1$2 = defineBuilder()({
8336
+ registry_id: registry_id$M,
8337
+ version: "1.1",
8338
+ reads: ({ data, f, s }) => ({
8339
+ coop: () => f.getCooperative(data.coopname, data.block_num),
8340
+ vars: () => f.getVars(data.coopname, data.block_num),
8341
+ userData: () => f.getUser(data.username, data.block_num),
8342
+ contract: () => getBlagorostContractRef(s, data)
8343
+ }),
8344
+ assemble: ({ data, meta, reads: { coop, vars, userData, contract } }) => ({
8345
+ meta,
8346
+ coop,
8347
+ vars,
8348
+ common_user: commonUser(userData),
8349
+ ...contract,
8350
+ ...propertyPositionFields(data)
8351
+ }),
8352
+ signer: ({ reads: { userData } }) => commonUser(userData).full_name_or_short_name
8353
+ });
8354
+ const Factory_1_2$2 = defineBuilder()({
8355
+ registry_id: registry_id$M,
8356
+ version: "1.2",
8357
+ reads: ({ data, f, s }) => ({
8358
+ coop: () => f.getCooperative(data.coopname, data.block_num),
8359
+ vars: () => f.getVars(data.coopname, data.block_num),
8360
+ userData: () => f.getUser(data.username, data.block_num),
8361
+ contract: () => getBlagorostContractRef(s, data)
8362
+ }),
8363
+ assemble: ({ data, meta, reads: { coop, vars, userData, contract } }) => ({
8364
+ meta,
8365
+ coop,
8366
+ vars,
8367
+ common_user: commonUser(userData),
8368
+ ...contract,
8369
+ ...propertyPositionFields(data),
8370
+ ...propertyFormFields(data)
8371
+ }),
8372
+ signer: ({ reads: { userData } }) => commonUser(userData).full_name_or_short_name
8373
+ });
8236
8374
 
8237
8375
  const _1070_CapitalizationPropertyInvestStatement = {
8238
8376
  __proto__: null,
8239
8377
  Factory: Factory$O,
8378
+ Factory_1_1: Factory_1_1$2,
8379
+ Factory_1_2: Factory_1_2$2,
8240
8380
  Template: CapitalizationPropertyInvestStatement
8241
8381
  };
8242
8382
 
@@ -8244,12 +8384,62 @@ const Factory$N = defineBuilder()({
8244
8384
  registry_id: registry_id$L,
8245
8385
  version: "1.0",
8246
8386
  reads: () => ({}),
8387
+ // Заглушка 1.0 собирала только мету и документов в цепях не дала; модель шаблона
8388
+ // с версии 1.1 шире (позиция имущества, реквизиты договоров). Код версии заморожен.
8389
+ // @ts-expect-error модель 1.1 требует полей, которых у заглушки нет
8247
8390
  assemble: ({ meta }) => ({ meta })
8248
8391
  });
8392
+ const Factory_1_1$1 = defineBuilder()({
8393
+ registry_id: registry_id$L,
8394
+ version: "1.1",
8395
+ reads: ({ data, f, s }) => ({
8396
+ coop: () => f.getCooperative(data.coopname, data.block_num),
8397
+ vars: () => f.getVars(data.coopname, data.block_num),
8398
+ userData: () => f.getUser(data.username, data.block_num),
8399
+ contract: () => getBlagorostContractRef(s, data)
8400
+ }),
8401
+ derive: ({ data, f, meta, reads: { coop } }) => ({
8402
+ decision: () => f.getDecision(coop, data.coopname, data.decision_id, meta.created_at, meta.timezone)
8403
+ }),
8404
+ assemble: ({ data, meta, reads: { coop, vars, userData, contract }, derived: { decision } }) => ({
8405
+ meta,
8406
+ coop,
8407
+ vars,
8408
+ decision,
8409
+ common_user: commonUser(userData),
8410
+ ...contract,
8411
+ ...propertyPositionFields(data)
8412
+ })
8413
+ });
8414
+ const Factory_1_2$1 = defineBuilder()({
8415
+ registry_id: registry_id$L,
8416
+ version: "1.2",
8417
+ reads: ({ data, f, s }) => ({
8418
+ coop: () => f.getCooperative(data.coopname, data.block_num),
8419
+ vars: () => f.getVars(data.coopname, data.block_num),
8420
+ userData: () => f.getUser(data.username, data.block_num),
8421
+ contract: () => getBlagorostContractRef(s, data)
8422
+ }),
8423
+ derive: ({ data, f, meta, reads: { coop } }) => ({
8424
+ decision: () => f.getDecision(coop, data.coopname, data.decision_id, meta.created_at, meta.timezone)
8425
+ }),
8426
+ assemble: ({ data, meta, reads: { coop, vars, userData, contract }, derived: { decision } }) => ({
8427
+ meta,
8428
+ coop,
8429
+ vars,
8430
+ decision,
8431
+ common_user: commonUser(userData),
8432
+ ...contract,
8433
+ ...propertyPositionFields(data),
8434
+ ...propertyFormFields(data)
8435
+ })
8436
+ });
8249
8437
 
8250
8438
  const _1071_CapitalizationPropertyInvestDecision = {
8251
8439
  __proto__: null,
8252
8440
  Factory: Factory$N,
8441
+ Factory_1_1: Factory_1_1$1,
8442
+ Factory_1_2: Factory_1_2$1,
8253
8443
  Template: CapitalizationPropertyInvestDecision
8254
8444
  };
8255
8445
 
@@ -8257,12 +8447,64 @@ const Factory$M = defineBuilder()({
8257
8447
  registry_id: registry_id$K,
8258
8448
  version: "1.0",
8259
8449
  reads: () => ({}),
8450
+ // Заглушка 1.0 собирала только мету и документов в цепях не дала; модель шаблона
8451
+ // с версии 1.1 шире (позиция имущества, реквизиты договоров). Код версии заморожен.
8452
+ // @ts-expect-error модель 1.1 требует полей, которых у заглушки нет
8260
8453
  assemble: ({ meta }) => ({ meta })
8261
8454
  });
8455
+ const Factory_1_1 = defineBuilder()({
8456
+ registry_id: registry_id$K,
8457
+ version: "1.1",
8458
+ reads: ({ data, f, s }) => ({
8459
+ coop: () => f.getCooperative(data.coopname, data.block_num),
8460
+ vars: () => f.getVars(data.coopname, data.block_num),
8461
+ userData: () => f.getUser(data.username, data.block_num),
8462
+ contract: () => getBlagorostContractRef(s, data)
8463
+ }),
8464
+ derive: ({ data, f, reads: { coop } }) => ({
8465
+ decision: () => f.getApprovedDecision(coop, data.coopname, data.decision_id)
8466
+ }),
8467
+ assemble: ({ data, meta, reads: { coop, vars, userData, contract }, derived: { decision } }) => ({
8468
+ meta,
8469
+ coop,
8470
+ vars,
8471
+ decision,
8472
+ common_user: commonUser(userData),
8473
+ ...contract,
8474
+ ...propertyPositionFields(data)
8475
+ }),
8476
+ signer: ({ reads: { userData } }) => commonUser(userData).full_name_or_short_name
8477
+ });
8478
+ const Factory_1_2 = defineBuilder()({
8479
+ registry_id: registry_id$K,
8480
+ version: "1.2",
8481
+ reads: ({ data, f, s }) => ({
8482
+ coop: () => f.getCooperative(data.coopname, data.block_num),
8483
+ vars: () => f.getVars(data.coopname, data.block_num),
8484
+ userData: () => f.getUser(data.username, data.block_num),
8485
+ contract: () => getBlagorostContractRef(s, data)
8486
+ }),
8487
+ derive: ({ data, f, reads: { coop } }) => ({
8488
+ decision: () => f.getApprovedDecision(coop, data.coopname, data.decision_id)
8489
+ }),
8490
+ assemble: ({ data, meta, reads: { coop, vars, userData, contract }, derived: { decision } }) => ({
8491
+ meta,
8492
+ coop,
8493
+ vars,
8494
+ decision,
8495
+ common_user: commonUser(userData),
8496
+ ...contract,
8497
+ ...propertyPositionFields(data),
8498
+ ...propertyFormFields(data)
8499
+ }),
8500
+ signer: ({ reads: { userData } }) => commonUser(userData).full_name_or_short_name
8501
+ });
8262
8502
 
8263
8503
  const _1072_CapitalizationPropertyInvestAct = {
8264
8504
  __proto__: null,
8265
8505
  Factory: Factory$M,
8506
+ Factory_1_1: Factory_1_1,
8507
+ Factory_1_2: Factory_1_2,
8266
8508
  Template: CapitalizationPropertyInvestAct
8267
8509
  };
8268
8510
 
package/dist/index.mjs CHANGED
@@ -2616,9 +2616,25 @@ const registry_id$M = Registry$1.CapitalizationPropertyInvestStatement.registry_
2616
2616
  const Schema$M = {
2617
2617
  type: "object",
2618
2618
  properties: {
2619
- meta: IMetaJSONSchema
2620
- },
2621
- required: ["meta"],
2619
+ meta: IMetaJSONSchema,
2620
+ coop: CooperativeSchema,
2621
+ vars: VarsSchema,
2622
+ common_user: CommonUserSchema,
2623
+ contributor_contract_number: { type: "string" },
2624
+ contributor_contract_created_at: { type: "string" },
2625
+ blagorost_agreement_number: { type: "string" },
2626
+ blagorost_agreement_created_at: { type: "string" },
2627
+ property_hash: { type: "string" },
2628
+ property_short_hash: { type: "string" },
2629
+ property_name: { type: "string" },
2630
+ property_description: { type: "string" },
2631
+ property_quantity: { type: "string" },
2632
+ property_unit: { type: "string" },
2633
+ property_amount: { type: "string" },
2634
+ property_form: { type: "string", nullable: true },
2635
+ property_form_label: { type: "string", nullable: true }
2636
+ },
2637
+ required: ["meta", "coop", "vars", "common_user", "contributor_contract_number", "contributor_contract_created_at", "blagorost_agreement_number", "blagorost_agreement_created_at", "property_hash", "property_short_hash", "property_name", "property_description", "property_quantity", "property_unit", "property_amount"],
2622
2638
  additionalProperties: true
2623
2639
  };
2624
2640
  const Template$M = {
@@ -2640,9 +2656,26 @@ const registry_id$L = Registry$1.CapitalizationPropertyInvestDecision.registry_i
2640
2656
  const Schema$L = {
2641
2657
  type: "object",
2642
2658
  properties: {
2643
- meta: IMetaJSONSchema
2644
- },
2645
- required: ["meta"],
2659
+ meta: IMetaJSONSchema,
2660
+ coop: CooperativeSchema,
2661
+ vars: VarsSchema,
2662
+ decision: decisionSchema,
2663
+ common_user: CommonUserSchema,
2664
+ contributor_contract_number: { type: "string" },
2665
+ contributor_contract_created_at: { type: "string" },
2666
+ blagorost_agreement_number: { type: "string" },
2667
+ blagorost_agreement_created_at: { type: "string" },
2668
+ property_hash: { type: "string" },
2669
+ property_short_hash: { type: "string" },
2670
+ property_name: { type: "string" },
2671
+ property_description: { type: "string" },
2672
+ property_quantity: { type: "string" },
2673
+ property_unit: { type: "string" },
2674
+ property_amount: { type: "string" },
2675
+ property_form: { type: "string", nullable: true },
2676
+ property_form_label: { type: "string", nullable: true }
2677
+ },
2678
+ required: ["meta", "coop", "vars", "decision", "common_user", "contributor_contract_number", "contributor_contract_created_at", "blagorost_agreement_number", "blagorost_agreement_created_at", "property_hash", "property_short_hash", "property_name", "property_description", "property_quantity", "property_unit", "property_amount"],
2646
2679
  additionalProperties: true
2647
2680
  };
2648
2681
  const Template$L = {
@@ -2664,9 +2697,26 @@ const registry_id$K = Registry$1.CapitalizationPropertyInvestAct.registry_id;
2664
2697
  const Schema$K = {
2665
2698
  type: "object",
2666
2699
  properties: {
2667
- meta: IMetaJSONSchema
2668
- },
2669
- required: ["meta"],
2700
+ meta: IMetaJSONSchema,
2701
+ coop: CooperativeSchema,
2702
+ vars: VarsSchema,
2703
+ decision: decisionSchema,
2704
+ common_user: CommonUserSchema,
2705
+ contributor_contract_number: { type: "string" },
2706
+ contributor_contract_created_at: { type: "string" },
2707
+ blagorost_agreement_number: { type: "string" },
2708
+ blagorost_agreement_created_at: { type: "string" },
2709
+ property_hash: { type: "string" },
2710
+ property_short_hash: { type: "string" },
2711
+ property_name: { type: "string" },
2712
+ property_description: { type: "string" },
2713
+ property_quantity: { type: "string" },
2714
+ property_unit: { type: "string" },
2715
+ property_amount: { type: "string" },
2716
+ property_form: { type: "string", nullable: true },
2717
+ property_form_label: { type: "string", nullable: true }
2718
+ },
2719
+ required: ["meta", "coop", "vars", "decision", "common_user", "contributor_contract_number", "contributor_contract_created_at", "blagorost_agreement_number", "blagorost_agreement_created_at", "property_hash", "property_short_hash", "property_name", "property_description", "property_quantity", "property_unit", "property_amount"],
2670
2720
  additionalProperties: true
2671
2721
  };
2672
2722
  const Template$K = {
@@ -5031,7 +5081,7 @@ function latestMinorOf(versions, major) {
5031
5081
 
5032
5082
  const name = "@coopenomics/docs-factory";
5033
5083
  const type = "module";
5034
- const version = "1.3.0";
5084
+ const version = "1.5.0";
5035
5085
  const description = "Фабрика документов цифрового кооператива: сборка документов по шаблонам, сборщики всех видов документов, версии сборщиков";
5036
5086
  const author = "Alex Ant <chairman.voskhod@gmail.com>";
5037
5087
  const license = "MIT";
@@ -8212,16 +8262,106 @@ const _1062_GenerationPropertyInvestAct = {
8212
8262
  Template: GenerationPropertyInvestAct
8213
8263
  };
8214
8264
 
8265
+ async function getBlagorostContractRef(sources, data) {
8266
+ const read = (key) => sources.udata({ coopname: data.coopname, username: data.username, key, block_num: data.block_num });
8267
+ const [contractNumber, contractCreatedAt, agreementNumber, agreementCreatedAt] = await Promise.all([
8268
+ read(UdataKey.BLAGOROST_CONTRIBUTOR_CONTRACT_NUMBER),
8269
+ read(UdataKey.BLAGOROST_CONTRIBUTOR_CONTRACT_CREATED_AT),
8270
+ read(UdataKey.BLAGOROST_AGREEMENT_NUMBER),
8271
+ read(UdataKey.BLAGOROST_AGREEMENT_CREATED_AT)
8272
+ ]);
8273
+ if (!contractNumber?.value)
8274
+ throw new Error("\u0414\u0430\u043D\u043D\u044B\u0435 \u0434\u043E\u0433\u043E\u0432\u043E\u0440\u0430 \u0423\u0425\u0414 \u0443\u0447\u0430\u0441\u0442\u043D\u0438\u043A\u0430 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u044B \u0432 Udata");
8275
+ if (!contractCreatedAt?.value)
8276
+ throw new Error("\u0414\u0430\u0442\u0430 \u0441\u043E\u0437\u0434\u0430\u043D\u0438\u044F \u0434\u043E\u0433\u043E\u0432\u043E\u0440\u0430 \u0423\u0425\u0414 \u0443\u0447\u0430\u0441\u0442\u043D\u0438\u043A\u0430 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u0430 \u0432 Udata");
8277
+ if (!agreementNumber?.value)
8278
+ throw new Error("\u0414\u0430\u043D\u043D\u044B\u0435 \u0441\u043E\u0433\u043B\u0430\u0448\u0435\u043D\u0438\u044F \u0431\u043B\u0430\u0433\u043E\u0440\u043E\u0441\u0442\u0430 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u044B \u0432 Udata");
8279
+ if (!agreementCreatedAt?.value)
8280
+ throw new Error("\u0414\u0430\u0442\u0430 \u0441\u043E\u0437\u0434\u0430\u043D\u0438\u044F \u0441\u043E\u0433\u043B\u0430\u0448\u0435\u043D\u0438\u044F \u0431\u043B\u0430\u0433\u043E\u0440\u043E\u0441\u0442\u0430 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u0430 \u0432 Udata");
8281
+ return {
8282
+ contributor_contract_number: String(contractNumber.value),
8283
+ contributor_contract_created_at: String(contractCreatedAt.value),
8284
+ blagorost_agreement_number: String(agreementNumber.value),
8285
+ blagorost_agreement_created_at: String(agreementCreatedAt.value)
8286
+ };
8287
+ }
8288
+ function propertyPositionFields(data) {
8289
+ return {
8290
+ property_hash: data.property_hash,
8291
+ property_short_hash: shortHash(data.property_hash),
8292
+ property_name: data.property_name,
8293
+ property_description: data.property_description,
8294
+ property_quantity: data.property_quantity,
8295
+ property_unit: data.property_unit,
8296
+ property_amount: formatAsset(data.property_amount)
8297
+ };
8298
+ }
8299
+ const PROPERTY_FORM_LABELS = {
8300
+ thing: "\u0412\u0435\u0449\u044C (\u0438\u043C\u0443\u0449\u0435\u0441\u0442\u0432\u043E \u0432 \u043D\u0430\u0442\u0443\u0440\u0430\u043B\u044C\u043D\u043E\u0439 \u0444\u043E\u0440\u043C\u0435)",
8301
+ intangible: "\u041D\u0435\u043C\u0430\u0442\u0435\u0440\u0438\u0430\u043B\u044C\u043D\u043E\u0435 \u0438\u043C\u0443\u0449\u0435\u0441\u0442\u0432\u043E \u0432 \u043E\u0431\u044A\u0435\u043A\u0442\u0438\u0432\u043D\u043E\u0439 \u0444\u043E\u0440\u043C\u0435 (\u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442, \u043C\u0435\u0442\u043E\u0434\u0438\u043A\u0430, \u0444\u0430\u0439\u043B)"
8302
+ };
8303
+ function propertyFormFields(data) {
8304
+ const form = data.property_form ?? "";
8305
+ return {
8306
+ property_form: form,
8307
+ property_form_label: PROPERTY_FORM_LABELS[form] ?? ""
8308
+ };
8309
+ }
8310
+
8215
8311
  const Factory$O = defineBuilder()({
8216
8312
  registry_id: registry_id$M,
8217
8313
  version: "1.0",
8218
8314
  reads: () => ({}),
8315
+ // Заглушка 1.0 собирала только мету и документов в цепях не дала; модель шаблона
8316
+ // с версии 1.1 шире (позиция имущества, реквизиты договоров). Код версии заморожен.
8317
+ // @ts-expect-error модель 1.1 требует полей, которых у заглушки нет
8219
8318
  assemble: ({ meta }) => ({ meta })
8220
8319
  });
8320
+ const Factory_1_1$2 = defineBuilder()({
8321
+ registry_id: registry_id$M,
8322
+ version: "1.1",
8323
+ reads: ({ data, f, s }) => ({
8324
+ coop: () => f.getCooperative(data.coopname, data.block_num),
8325
+ vars: () => f.getVars(data.coopname, data.block_num),
8326
+ userData: () => f.getUser(data.username, data.block_num),
8327
+ contract: () => getBlagorostContractRef(s, data)
8328
+ }),
8329
+ assemble: ({ data, meta, reads: { coop, vars, userData, contract } }) => ({
8330
+ meta,
8331
+ coop,
8332
+ vars,
8333
+ common_user: commonUser(userData),
8334
+ ...contract,
8335
+ ...propertyPositionFields(data)
8336
+ }),
8337
+ signer: ({ reads: { userData } }) => commonUser(userData).full_name_or_short_name
8338
+ });
8339
+ const Factory_1_2$2 = defineBuilder()({
8340
+ registry_id: registry_id$M,
8341
+ version: "1.2",
8342
+ reads: ({ data, f, s }) => ({
8343
+ coop: () => f.getCooperative(data.coopname, data.block_num),
8344
+ vars: () => f.getVars(data.coopname, data.block_num),
8345
+ userData: () => f.getUser(data.username, data.block_num),
8346
+ contract: () => getBlagorostContractRef(s, data)
8347
+ }),
8348
+ assemble: ({ data, meta, reads: { coop, vars, userData, contract } }) => ({
8349
+ meta,
8350
+ coop,
8351
+ vars,
8352
+ common_user: commonUser(userData),
8353
+ ...contract,
8354
+ ...propertyPositionFields(data),
8355
+ ...propertyFormFields(data)
8356
+ }),
8357
+ signer: ({ reads: { userData } }) => commonUser(userData).full_name_or_short_name
8358
+ });
8221
8359
 
8222
8360
  const _1070_CapitalizationPropertyInvestStatement = {
8223
8361
  __proto__: null,
8224
8362
  Factory: Factory$O,
8363
+ Factory_1_1: Factory_1_1$2,
8364
+ Factory_1_2: Factory_1_2$2,
8225
8365
  Template: CapitalizationPropertyInvestStatement
8226
8366
  };
8227
8367
 
@@ -8229,12 +8369,62 @@ const Factory$N = defineBuilder()({
8229
8369
  registry_id: registry_id$L,
8230
8370
  version: "1.0",
8231
8371
  reads: () => ({}),
8372
+ // Заглушка 1.0 собирала только мету и документов в цепях не дала; модель шаблона
8373
+ // с версии 1.1 шире (позиция имущества, реквизиты договоров). Код версии заморожен.
8374
+ // @ts-expect-error модель 1.1 требует полей, которых у заглушки нет
8232
8375
  assemble: ({ meta }) => ({ meta })
8233
8376
  });
8377
+ const Factory_1_1$1 = defineBuilder()({
8378
+ registry_id: registry_id$L,
8379
+ version: "1.1",
8380
+ reads: ({ data, f, s }) => ({
8381
+ coop: () => f.getCooperative(data.coopname, data.block_num),
8382
+ vars: () => f.getVars(data.coopname, data.block_num),
8383
+ userData: () => f.getUser(data.username, data.block_num),
8384
+ contract: () => getBlagorostContractRef(s, data)
8385
+ }),
8386
+ derive: ({ data, f, meta, reads: { coop } }) => ({
8387
+ decision: () => f.getDecision(coop, data.coopname, data.decision_id, meta.created_at, meta.timezone)
8388
+ }),
8389
+ assemble: ({ data, meta, reads: { coop, vars, userData, contract }, derived: { decision } }) => ({
8390
+ meta,
8391
+ coop,
8392
+ vars,
8393
+ decision,
8394
+ common_user: commonUser(userData),
8395
+ ...contract,
8396
+ ...propertyPositionFields(data)
8397
+ })
8398
+ });
8399
+ const Factory_1_2$1 = defineBuilder()({
8400
+ registry_id: registry_id$L,
8401
+ version: "1.2",
8402
+ reads: ({ data, f, s }) => ({
8403
+ coop: () => f.getCooperative(data.coopname, data.block_num),
8404
+ vars: () => f.getVars(data.coopname, data.block_num),
8405
+ userData: () => f.getUser(data.username, data.block_num),
8406
+ contract: () => getBlagorostContractRef(s, data)
8407
+ }),
8408
+ derive: ({ data, f, meta, reads: { coop } }) => ({
8409
+ decision: () => f.getDecision(coop, data.coopname, data.decision_id, meta.created_at, meta.timezone)
8410
+ }),
8411
+ assemble: ({ data, meta, reads: { coop, vars, userData, contract }, derived: { decision } }) => ({
8412
+ meta,
8413
+ coop,
8414
+ vars,
8415
+ decision,
8416
+ common_user: commonUser(userData),
8417
+ ...contract,
8418
+ ...propertyPositionFields(data),
8419
+ ...propertyFormFields(data)
8420
+ })
8421
+ });
8234
8422
 
8235
8423
  const _1071_CapitalizationPropertyInvestDecision = {
8236
8424
  __proto__: null,
8237
8425
  Factory: Factory$N,
8426
+ Factory_1_1: Factory_1_1$1,
8427
+ Factory_1_2: Factory_1_2$1,
8238
8428
  Template: CapitalizationPropertyInvestDecision
8239
8429
  };
8240
8430
 
@@ -8242,12 +8432,64 @@ const Factory$M = defineBuilder()({
8242
8432
  registry_id: registry_id$K,
8243
8433
  version: "1.0",
8244
8434
  reads: () => ({}),
8435
+ // Заглушка 1.0 собирала только мету и документов в цепях не дала; модель шаблона
8436
+ // с версии 1.1 шире (позиция имущества, реквизиты договоров). Код версии заморожен.
8437
+ // @ts-expect-error модель 1.1 требует полей, которых у заглушки нет
8245
8438
  assemble: ({ meta }) => ({ meta })
8246
8439
  });
8440
+ const Factory_1_1 = defineBuilder()({
8441
+ registry_id: registry_id$K,
8442
+ version: "1.1",
8443
+ reads: ({ data, f, s }) => ({
8444
+ coop: () => f.getCooperative(data.coopname, data.block_num),
8445
+ vars: () => f.getVars(data.coopname, data.block_num),
8446
+ userData: () => f.getUser(data.username, data.block_num),
8447
+ contract: () => getBlagorostContractRef(s, data)
8448
+ }),
8449
+ derive: ({ data, f, reads: { coop } }) => ({
8450
+ decision: () => f.getApprovedDecision(coop, data.coopname, data.decision_id)
8451
+ }),
8452
+ assemble: ({ data, meta, reads: { coop, vars, userData, contract }, derived: { decision } }) => ({
8453
+ meta,
8454
+ coop,
8455
+ vars,
8456
+ decision,
8457
+ common_user: commonUser(userData),
8458
+ ...contract,
8459
+ ...propertyPositionFields(data)
8460
+ }),
8461
+ signer: ({ reads: { userData } }) => commonUser(userData).full_name_or_short_name
8462
+ });
8463
+ const Factory_1_2 = defineBuilder()({
8464
+ registry_id: registry_id$K,
8465
+ version: "1.2",
8466
+ reads: ({ data, f, s }) => ({
8467
+ coop: () => f.getCooperative(data.coopname, data.block_num),
8468
+ vars: () => f.getVars(data.coopname, data.block_num),
8469
+ userData: () => f.getUser(data.username, data.block_num),
8470
+ contract: () => getBlagorostContractRef(s, data)
8471
+ }),
8472
+ derive: ({ data, f, reads: { coop } }) => ({
8473
+ decision: () => f.getApprovedDecision(coop, data.coopname, data.decision_id)
8474
+ }),
8475
+ assemble: ({ data, meta, reads: { coop, vars, userData, contract }, derived: { decision } }) => ({
8476
+ meta,
8477
+ coop,
8478
+ vars,
8479
+ decision,
8480
+ common_user: commonUser(userData),
8481
+ ...contract,
8482
+ ...propertyPositionFields(data),
8483
+ ...propertyFormFields(data)
8484
+ }),
8485
+ signer: ({ reads: { userData } }) => commonUser(userData).full_name_or_short_name
8486
+ });
8247
8487
 
8248
8488
  const _1072_CapitalizationPropertyInvestAct = {
8249
8489
  __proto__: null,
8250
8490
  Factory: Factory$M,
8491
+ Factory_1_1: Factory_1_1,
8492
+ Factory_1_2: Factory_1_2,
8251
8493
  Template: CapitalizationPropertyInvestAct
8252
8494
  };
8253
8495
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coopenomics/docs-factory",
3
3
  "type": "module",
4
- "version": "1.3.0",
4
+ "version": "1.5.0",
5
5
  "description": "Фабрика документов цифрового кооператива: сборка документов по шаблонам, сборщики всех видов документов, версии сборщиков",
6
6
  "author": "Alex Ant <chairman.voskhod@gmail.com>",
7
7
  "license": "MIT",
@@ -50,7 +50,7 @@
50
50
  "pdf-lib": "^1.17.1",
51
51
  "pg": "^8.16.3",
52
52
  "uuid": "^11.0.0",
53
- "@coopenomics/docs-templates": "1.3.0"
53
+ "@coopenomics/docs-templates": "1.5.0"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@antfu/eslint-config": "^2.17.0",