@coopenomics/extension-sdk 2026.12.1 → 2026.12.3-dev.2

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 (113) hide show
  1. package/README.md +29 -0
  2. package/dist/app/app-error.d.ts +31 -0
  3. package/dist/app/app-error.js +49 -0
  4. package/dist/app/app-logger.d.ts +29 -0
  5. package/dist/app/app-logger.js +54 -0
  6. package/dist/app/app-messages.d.ts +11 -0
  7. package/dist/app/app-messages.js +16 -0
  8. package/dist/app/app-platform.module.d.ts +19 -0
  9. package/dist/app/app-platform.module.js +35 -0
  10. package/dist/app/app-rights.d.ts +73 -0
  11. package/dist/app/app-rights.js +116 -0
  12. package/dist/config/extension-config.d.ts +14 -0
  13. package/dist/config/extension-config.js +5 -0
  14. package/dist/database/app-database.module.d.ts +39 -0
  15. package/dist/database/app-database.module.js +101 -0
  16. package/dist/database/index.d.ts +2 -0
  17. package/dist/database/index.js +11 -0
  18. package/dist/database/legacy-import.d.ts +61 -0
  19. package/dist/database/legacy-import.js +153 -0
  20. package/dist/database/live-changes.plugin.d.ts +50 -0
  21. package/dist/database/live-changes.plugin.js +119 -0
  22. package/dist/graphql/account-type.enum.d.ts +18 -0
  23. package/dist/graphql/account-type.enum.js +24 -0
  24. package/dist/graphql/certificates.dto.d.ts +70 -0
  25. package/dist/graphql/certificates.dto.js +200 -0
  26. package/dist/graphql/document-aggregate.dto.d.ts +16 -0
  27. package/dist/graphql/document-aggregate.dto.js +54 -0
  28. package/dist/graphql/generate-document-input.dto.d.ts +16 -0
  29. package/dist/graphql/generate-document-input.dto.js +34 -0
  30. package/dist/graphql/generate-document-options-input.dto.d.ts +5 -0
  31. package/dist/graphql/generate-document-options-input.dto.js +30 -0
  32. package/dist/graphql/generate-meta-document-input.dto.d.ts +14 -0
  33. package/dist/graphql/generate-meta-document-input.dto.js +100 -0
  34. package/dist/graphql/generated-document.dto.d.ts +21 -0
  35. package/dist/graphql/generated-document.dto.js +64 -0
  36. package/dist/graphql/index.d.ts +39 -0
  37. package/dist/graphql/index.js +70 -0
  38. package/dist/graphql/lang-type.enum.d.ts +4 -0
  39. package/dist/graphql/lang-type.enum.js +13 -0
  40. package/dist/graphql/meta-document-input.dto.d.ts +15 -0
  41. package/dist/graphql/meta-document-input.dto.js +103 -0
  42. package/dist/graphql/pagination.dto.d.ts +41 -0
  43. package/dist/graphql/pagination.dto.js +110 -0
  44. package/dist/graphql/print-subgraph.d.ts +14 -0
  45. package/dist/graphql/print-subgraph.js +65 -0
  46. package/dist/graphql/signed-digital-document-input.dto.d.ts +31 -0
  47. package/dist/graphql/signed-digital-document-input.dto.js +133 -0
  48. package/dist/graphql/signed-digital-document.dto.d.ts +34 -0
  49. package/dist/graphql/signed-digital-document.dto.js +136 -0
  50. package/dist/graphql/signer-certificate.resolver.d.ts +23 -0
  51. package/dist/graphql/signer-certificate.resolver.js +70 -0
  52. package/dist/graphql/subgraph-sdl.d.ts +54 -0
  53. package/dist/graphql/subgraph-sdl.js +125 -0
  54. package/dist/graphql/transaction.dto.d.ts +12 -0
  55. package/dist/graphql/transaction.dto.js +70 -0
  56. package/dist/graphql/user-certificate.union.d.ts +8 -0
  57. package/dist/graphql/user-certificate.union.js +25 -0
  58. package/dist/graphql/validation-message.d.ts +12 -0
  59. package/dist/graphql/validation-message.js +12 -0
  60. package/dist/index.d.ts +11 -1
  61. package/dist/index.js +50 -1
  62. package/dist/ports/app-ports.client.d.ts +64 -0
  63. package/dist/ports/app-ports.client.js +104 -0
  64. package/dist/ports/app-ports.provider.d.ts +57 -0
  65. package/dist/ports/app-ports.provider.js +124 -0
  66. package/dist/ports/core-ports.client.js +13 -1
  67. package/dist/ports/extension-ports.module.d.ts +67 -0
  68. package/dist/ports/extension-ports.module.js +133 -4
  69. package/dist/ports/integration-settings.d.ts +17 -0
  70. package/dist/ports/integration-settings.js +6 -0
  71. package/dist/secrets/app-credentials.d.ts +6 -0
  72. package/dist/secrets/app-credentials.js +38 -0
  73. package/dist/secrets/app-secrets.d.ts +17 -0
  74. package/dist/secrets/app-secrets.js +74 -0
  75. package/dist/secrets/index.d.ts +7 -0
  76. package/dist/secrets/index.js +15 -0
  77. package/dist/subgraph-rules/index.d.ts +35 -0
  78. package/dist/subgraph-rules/index.js +211 -0
  79. package/dist/sync/abstract-blockchain-delta.mapper.d.ts +18 -0
  80. package/dist/sync/abstract-blockchain-delta.mapper.js +25 -0
  81. package/dist/sync/abstract-entity-sync.service.d.ts +79 -0
  82. package/dist/sync/abstract-entity-sync.service.js +219 -0
  83. package/dist/sync/audit-logger.d.ts +5 -0
  84. package/dist/sync/audit-logger.js +32 -0
  85. package/dist/sync/base-chain.repository.d.ts +46 -0
  86. package/dist/sync/base-chain.repository.js +127 -0
  87. package/dist/sync/base-database.interface.d.ts +17 -0
  88. package/dist/sync/base-database.interface.js +2 -0
  89. package/dist/sync/base-domain.entity.d.ts +27 -0
  90. package/dist/sync/base-domain.entity.js +52 -0
  91. package/dist/sync/base-output.dto.d.ts +10 -0
  92. package/dist/sync/base-output.dto.js +60 -0
  93. package/dist/sync/blockchain-sync.interface.d.ts +84 -0
  94. package/dist/sync/blockchain-sync.interface.js +2 -0
  95. package/dist/sync/chain-record.d.ts +15 -0
  96. package/dist/sync/chain-record.js +19 -0
  97. package/dist/sync/chain-versioning.service.d.ts +47 -0
  98. package/dist/sync/chain-versioning.service.js +169 -0
  99. package/dist/sync/delta.d.ts +22 -0
  100. package/dist/sync/delta.js +2 -0
  101. package/dist/sync/errors/audit-unknown-status.d.ts +11 -0
  102. package/dist/sync/errors/audit-unknown-status.js +26 -0
  103. package/dist/sync/errors/unsupported-contract-version.error.d.ts +23 -0
  104. package/dist/sync/errors/unsupported-contract-version.error.js +22 -0
  105. package/dist/sync/fork/fork-aware-syncer.interface.d.ts +44 -0
  106. package/dist/sync/fork/fork-aware-syncer.interface.js +22 -0
  107. package/dist/sync/index.d.ts +36 -0
  108. package/dist/sync/index.js +56 -0
  109. package/dist/sync/sync-logger.d.ts +21 -0
  110. package/dist/sync/sync-logger.js +2 -0
  111. package/dist/sync/sync-policy.d.ts +27 -0
  112. package/dist/sync/sync-policy.js +16 -0
  113. package/package.json +55 -3
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.printSubgraphSdl = exports.collectResolvers = exports.buildSubgraphSdl = exports.SignerCertificateResolver = exports.UserCertificateUnion = exports.OrganizationCertificateDTO = exports.EntrepreneurCertificateDTO = exports.IndividualCertificateDTO = exports.RepresentedByCertificateDTO = exports.SORT_ORDERS = exports.SORT_FIELD_PATTERN = exports.createPaginationResult = exports.PaginationResult = exports.PaginationInputDTO = exports.GenerateDocumentOptionsInputDTO = exports.GenerateDocumentInputDTO = exports.GenerateMetaDocumentInputDTO = exports.MetaDocumentInputDTO = exports.SignedDigitalDocumentInputDTO = exports.SignatureInfoInputDTO = exports.TransactionDTO = exports.DocumentAggregateDTO = exports.SignedDigitalDocumentDTO = exports.SignatureInfoDTO = exports.GeneratedDocumentDTO = exports.validationMessage = exports.AccountType = exports.LangType = void 0;
4
+ /**
5
+ * Общие типы схемы платформы: документ, подпись, сертификат подписанта,
6
+ * транзакция, пагинация и перечисления к ним.
7
+ *
8
+ * Оркестратор сводит подграф ядра и подграфы приложений в одну схему
9
+ * (федерация Apollo 2). Одноимённый выходной тип в двух подграфах федерация
10
+ * сводит, только если оба подграфа пометили его `@shareable` и поля совпадают
11
+ * по типам. Иначе подграф приложения исключается из схемы, и каждый его
12
+ * запрос получает ошибку (03.12.2026, первая установка «Кооперативного
13
+ * участка»). Поэтому эти типы объявлены один раз — здесь: ядро получает их
14
+ * через `@coopenomics/extension-kit`, приложение — из этого подпути, и схема у
15
+ * обоих совпадает по построению.
16
+ *
17
+ * Входные типы федерация сводит пересечением полей: одноимённый вход
18
+ * приложения с другим набором полей срезал бы поля у входа ядра. Общие входы
19
+ * поэтому тоже объявлены здесь.
20
+ *
21
+ * Подпуть требует `class-validator`, `class-transformer` и `graphql-type-json`
22
+ * одним экземпляром с приложением (peer-зависимости): две копии
23
+ * `graphql-type-json` дали бы два скаляра `JSON`, две копии `class-validator`
24
+ * — проверку входа, которую ValidationPipe не видит.
25
+ */
26
+ var lang_type_enum_1 = require("./lang-type.enum");
27
+ Object.defineProperty(exports, "LangType", { enumerable: true, get: function () { return lang_type_enum_1.LangType; } });
28
+ var account_type_enum_1 = require("./account-type.enum");
29
+ Object.defineProperty(exports, "AccountType", { enumerable: true, get: function () { return account_type_enum_1.AccountType; } });
30
+ var validation_message_1 = require("./validation-message");
31
+ Object.defineProperty(exports, "validationMessage", { enumerable: true, get: function () { return validation_message_1.validationMessage; } });
32
+ var generated_document_dto_1 = require("./generated-document.dto");
33
+ Object.defineProperty(exports, "GeneratedDocumentDTO", { enumerable: true, get: function () { return generated_document_dto_1.GeneratedDocumentDTO; } });
34
+ var signed_digital_document_dto_1 = require("./signed-digital-document.dto");
35
+ Object.defineProperty(exports, "SignatureInfoDTO", { enumerable: true, get: function () { return signed_digital_document_dto_1.SignatureInfoDTO; } });
36
+ Object.defineProperty(exports, "SignedDigitalDocumentDTO", { enumerable: true, get: function () { return signed_digital_document_dto_1.SignedDigitalDocumentDTO; } });
37
+ var document_aggregate_dto_1 = require("./document-aggregate.dto");
38
+ Object.defineProperty(exports, "DocumentAggregateDTO", { enumerable: true, get: function () { return document_aggregate_dto_1.DocumentAggregateDTO; } });
39
+ var transaction_dto_1 = require("./transaction.dto");
40
+ Object.defineProperty(exports, "TransactionDTO", { enumerable: true, get: function () { return transaction_dto_1.TransactionDTO; } });
41
+ var signed_digital_document_input_dto_1 = require("./signed-digital-document-input.dto");
42
+ Object.defineProperty(exports, "SignatureInfoInputDTO", { enumerable: true, get: function () { return signed_digital_document_input_dto_1.SignatureInfoInputDTO; } });
43
+ Object.defineProperty(exports, "SignedDigitalDocumentInputDTO", { enumerable: true, get: function () { return signed_digital_document_input_dto_1.SignedDigitalDocumentInputDTO; } });
44
+ var meta_document_input_dto_1 = require("./meta-document-input.dto");
45
+ Object.defineProperty(exports, "MetaDocumentInputDTO", { enumerable: true, get: function () { return meta_document_input_dto_1.MetaDocumentInputDTO; } });
46
+ var generate_meta_document_input_dto_1 = require("./generate-meta-document-input.dto");
47
+ Object.defineProperty(exports, "GenerateMetaDocumentInputDTO", { enumerable: true, get: function () { return generate_meta_document_input_dto_1.GenerateMetaDocumentInputDTO; } });
48
+ var generate_document_input_dto_1 = require("./generate-document-input.dto");
49
+ Object.defineProperty(exports, "GenerateDocumentInputDTO", { enumerable: true, get: function () { return generate_document_input_dto_1.GenerateDocumentInputDTO; } });
50
+ var generate_document_options_input_dto_1 = require("./generate-document-options-input.dto");
51
+ Object.defineProperty(exports, "GenerateDocumentOptionsInputDTO", { enumerable: true, get: function () { return generate_document_options_input_dto_1.GenerateDocumentOptionsInputDTO; } });
52
+ var pagination_dto_1 = require("./pagination.dto");
53
+ Object.defineProperty(exports, "PaginationInputDTO", { enumerable: true, get: function () { return pagination_dto_1.PaginationInputDTO; } });
54
+ Object.defineProperty(exports, "PaginationResult", { enumerable: true, get: function () { return pagination_dto_1.PaginationResult; } });
55
+ Object.defineProperty(exports, "createPaginationResult", { enumerable: true, get: function () { return pagination_dto_1.createPaginationResult; } });
56
+ Object.defineProperty(exports, "SORT_FIELD_PATTERN", { enumerable: true, get: function () { return pagination_dto_1.SORT_FIELD_PATTERN; } });
57
+ Object.defineProperty(exports, "SORT_ORDERS", { enumerable: true, get: function () { return pagination_dto_1.SORT_ORDERS; } });
58
+ var certificates_dto_1 = require("./certificates.dto");
59
+ Object.defineProperty(exports, "RepresentedByCertificateDTO", { enumerable: true, get: function () { return certificates_dto_1.RepresentedByCertificateDTO; } });
60
+ Object.defineProperty(exports, "IndividualCertificateDTO", { enumerable: true, get: function () { return certificates_dto_1.IndividualCertificateDTO; } });
61
+ Object.defineProperty(exports, "EntrepreneurCertificateDTO", { enumerable: true, get: function () { return certificates_dto_1.EntrepreneurCertificateDTO; } });
62
+ Object.defineProperty(exports, "OrganizationCertificateDTO", { enumerable: true, get: function () { return certificates_dto_1.OrganizationCertificateDTO; } });
63
+ var user_certificate_union_1 = require("./user-certificate.union");
64
+ Object.defineProperty(exports, "UserCertificateUnion", { enumerable: true, get: function () { return user_certificate_union_1.UserCertificateUnion; } });
65
+ var signer_certificate_resolver_1 = require("./signer-certificate.resolver");
66
+ Object.defineProperty(exports, "SignerCertificateResolver", { enumerable: true, get: function () { return signer_certificate_resolver_1.SignerCertificateResolver; } });
67
+ var subgraph_sdl_1 = require("./subgraph-sdl");
68
+ Object.defineProperty(exports, "buildSubgraphSdl", { enumerable: true, get: function () { return subgraph_sdl_1.buildSubgraphSdl; } });
69
+ Object.defineProperty(exports, "collectResolvers", { enumerable: true, get: function () { return subgraph_sdl_1.collectResolvers; } });
70
+ Object.defineProperty(exports, "printSubgraphSdl", { enumerable: true, get: function () { return subgraph_sdl_1.printSubgraphSdl; } });
@@ -0,0 +1,4 @@
1
+ /** Язык документа. Регистрация в схеме одна — в этом файле. */
2
+ export declare enum LangType {
3
+ ru = "ru"
4
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LangType = void 0;
4
+ const graphql_1 = require("@nestjs/graphql");
5
+ /** Язык документа. Регистрация в схеме одна — в этом файле. */
6
+ var LangType;
7
+ (function (LangType) {
8
+ LangType["ru"] = "ru";
9
+ })(LangType || (exports.LangType = LangType = {}));
10
+ (0, graphql_1.registerEnumType)(LangType, {
11
+ name: 'LangType',
12
+ description: 'Язык документа',
13
+ });
@@ -0,0 +1,15 @@
1
+ import { LangType } from './lang-type.enum';
2
+ export declare class MetaDocumentInputDTO {
3
+ title: string;
4
+ registry_id: number;
5
+ lang: LangType;
6
+ generator: string;
7
+ version: string;
8
+ coopname: string;
9
+ username: string;
10
+ created_at: string;
11
+ block_num: number;
12
+ timezone: string;
13
+ links: string[];
14
+ builder?: string;
15
+ }
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.MetaDocumentInputDTO = void 0;
13
+ /**
14
+ * Метаданные документа на вход: к какому реестру относится, кем и для кого
15
+ * сформирован. Совпадение с `IMetaDocument` пакета `@coopenomics/docs-templates`
16
+ * сверяет `extension-kit`: SDK от пакета шаблонов не зависит.
17
+ */
18
+ const class_validator_1 = require("class-validator");
19
+ const graphql_1 = require("@nestjs/graphql");
20
+ const lang_type_enum_1 = require("./lang-type.enum");
21
+ let MetaDocumentInputDTO = class MetaDocumentInputDTO {
22
+ title;
23
+ registry_id;
24
+ lang;
25
+ generator;
26
+ version;
27
+ coopname;
28
+ username;
29
+ created_at;
30
+ block_num;
31
+ timezone;
32
+ links;
33
+ builder;
34
+ };
35
+ exports.MetaDocumentInputDTO = MetaDocumentInputDTO;
36
+ __decorate([
37
+ (0, graphql_1.Field)(() => String, { description: 'Название документа' }),
38
+ (0, class_validator_1.IsString)(),
39
+ __metadata("design:type", String)
40
+ ], MetaDocumentInputDTO.prototype, "title", void 0);
41
+ __decorate([
42
+ (0, graphql_1.Field)(() => graphql_1.Int, { description: 'ID документа в реестре' }),
43
+ (0, class_validator_1.IsNumber)(),
44
+ __metadata("design:type", Number)
45
+ ], MetaDocumentInputDTO.prototype, "registry_id", void 0);
46
+ __decorate([
47
+ (0, graphql_1.Field)(() => String, { description: 'Язык документа' }),
48
+ (0, class_validator_1.IsEnum)(lang_type_enum_1.LangType),
49
+ __metadata("design:type", String)
50
+ ], MetaDocumentInputDTO.prototype, "lang", void 0);
51
+ __decorate([
52
+ (0, graphql_1.Field)(() => String, { description: 'Имя генератора, использованного для создания документа' }),
53
+ (0, class_validator_1.IsString)(),
54
+ __metadata("design:type", String)
55
+ ], MetaDocumentInputDTO.prototype, "generator", void 0);
56
+ __decorate([
57
+ (0, graphql_1.Field)(() => String, { description: 'Версия генератора, использованного для создания документа' }),
58
+ (0, class_validator_1.IsString)(),
59
+ __metadata("design:type", String)
60
+ ], MetaDocumentInputDTO.prototype, "version", void 0);
61
+ __decorate([
62
+ (0, graphql_1.Field)(() => String, { description: 'Название кооператива, связанное с документом' }),
63
+ (0, class_validator_1.IsString)(),
64
+ __metadata("design:type", String)
65
+ ], MetaDocumentInputDTO.prototype, "coopname", void 0);
66
+ __decorate([
67
+ (0, graphql_1.Field)(() => String, { description: 'Имя пользователя, создавшего документ' }),
68
+ (0, class_validator_1.IsString)(),
69
+ __metadata("design:type", String)
70
+ ], MetaDocumentInputDTO.prototype, "username", void 0);
71
+ __decorate([
72
+ (0, graphql_1.Field)(() => String, { description: 'Дата и время создания документа' }),
73
+ (0, class_validator_1.IsString)(),
74
+ __metadata("design:type", String)
75
+ ], MetaDocumentInputDTO.prototype, "created_at", void 0);
76
+ __decorate([
77
+ (0, graphql_1.Field)(() => graphql_1.Int, { description: 'Номер блока, на котором был создан документ' }),
78
+ (0, class_validator_1.IsInt)(),
79
+ __metadata("design:type", Number)
80
+ ], MetaDocumentInputDTO.prototype, "block_num", void 0);
81
+ __decorate([
82
+ (0, graphql_1.Field)(() => String, { description: 'Часовой пояс, в котором был создан документ' }),
83
+ (0, class_validator_1.IsString)(),
84
+ __metadata("design:type", String)
85
+ ], MetaDocumentInputDTO.prototype, "timezone", void 0);
86
+ __decorate([
87
+ (0, graphql_1.Field)(() => [String], { description: 'Ссылки, связанные с документом' }),
88
+ (0, class_validator_1.IsArray)(),
89
+ (0, class_validator_1.IsString)({ each: true }),
90
+ __metadata("design:type", Array)
91
+ ], MetaDocumentInputDTO.prototype, "links", void 0);
92
+ __decorate([
93
+ (0, graphql_1.Field)(() => String, {
94
+ nullable: true,
95
+ description: 'Версия сборщика документа (major.minor); у документов, собранных до её появления, не задана',
96
+ }),
97
+ (0, class_validator_1.IsOptional)(),
98
+ (0, class_validator_1.IsString)(),
99
+ __metadata("design:type", String)
100
+ ], MetaDocumentInputDTO.prototype, "builder", void 0);
101
+ exports.MetaDocumentInputDTO = MetaDocumentInputDTO = __decorate([
102
+ (0, graphql_1.InputType)('MetaDocumentInput')
103
+ ], MetaDocumentInputDTO);
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Допустимое поле сортировки: имя из латиницы, цифр и подчёркивания и, по
3
+ * желанию, направление через двоеточие (`created_at:desc`). Поле попадает в
4
+ * `ORDER BY` строкой, и любой другой символ открывал бы подстановку SQL.
5
+ * Какая колонка разрешена, решает репозиторий по своему списку; здесь
6
+ * отсекается всё, что именем колонки быть не может. Пустая строка — «без
7
+ * сортировки»: репозиторий берёт порядок по умолчанию.
8
+ */
9
+ /** Направления сортировки списка. */
10
+ export declare const SORT_ORDERS: readonly ["ASC", "DESC"];
11
+ export declare const SORT_FIELD_PATTERN: RegExp;
12
+ /** Входные параметры для пагинации и сортировки. */
13
+ export declare class PaginationInputDTO {
14
+ page: number;
15
+ limit: number;
16
+ sortBy?: string;
17
+ sortOrder: (typeof SORT_ORDERS)[number];
18
+ }
19
+ /** Результат пагинации (универсальный для TypeScript). */
20
+ export declare class PaginationResult<T> {
21
+ items: T[];
22
+ totalCount: number;
23
+ totalPages: number;
24
+ currentPage: number;
25
+ }
26
+ /**
27
+ * Тип GraphQL результата пагинации `<name>PaginationResult`.
28
+ *
29
+ * Имя типа задаёт владелец списка. У приложения имя начинается с его
30
+ * приставки (`PaginatedKuDecisions`): типы списков приложения принадлежат ему
31
+ * одному и с ядром совпадать не должны.
32
+ *
33
+ * @param ItemType - класс элемента списка
34
+ * @param name - имя объекта GraphQL без суффикса `PaginationResult`
35
+ */
36
+ export declare function createPaginationResult<T>(ItemType: new (...args: any[]) => T, name: string): abstract new () => {
37
+ items: T[];
38
+ totalCount: number;
39
+ totalPages: number;
40
+ currentPage: number;
41
+ };
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PaginationResult = exports.PaginationInputDTO = exports.SORT_FIELD_PATTERN = exports.SORT_ORDERS = void 0;
13
+ exports.createPaginationResult = createPaginationResult;
14
+ const graphql_1 = require("@nestjs/graphql");
15
+ const class_validator_1 = require("class-validator");
16
+ const validation_message_1 = require("./validation-message");
17
+ /**
18
+ * Допустимое поле сортировки: имя из латиницы, цифр и подчёркивания и, по
19
+ * желанию, направление через двоеточие (`created_at:desc`). Поле попадает в
20
+ * `ORDER BY` строкой, и любой другой символ открывал бы подстановку SQL.
21
+ * Какая колонка разрешена, решает репозиторий по своему списку; здесь
22
+ * отсекается всё, что именем колонки быть не может. Пустая строка — «без
23
+ * сортировки»: репозиторий берёт порядок по умолчанию.
24
+ */
25
+ /** Направления сортировки списка. */
26
+ exports.SORT_ORDERS = ['ASC', 'DESC'];
27
+ exports.SORT_FIELD_PATTERN = /^([A-Za-z_][A-Za-z0-9_]*(:(asc|desc))?)?$/i;
28
+ /** Входные параметры для пагинации и сортировки. */
29
+ let PaginationInputDTO = class PaginationInputDTO {
30
+ page;
31
+ limit;
32
+ sortBy;
33
+ sortOrder;
34
+ };
35
+ exports.PaginationInputDTO = PaginationInputDTO;
36
+ __decorate([
37
+ (0, graphql_1.Field)(() => graphql_1.Int, { description: 'Номер страницы', defaultValue: 1 }),
38
+ __metadata("design:type", Number)
39
+ ], PaginationInputDTO.prototype, "page", void 0);
40
+ __decorate([
41
+ (0, graphql_1.Field)(() => graphql_1.Int, { description: 'Количество элементов на странице', defaultValue: 10 }),
42
+ __metadata("design:type", Number)
43
+ ], PaginationInputDTO.prototype, "limit", void 0);
44
+ __decorate([
45
+ (0, graphql_1.Field)(() => String, { nullable: true, description: 'Ключ сортировки (например, "name")' }),
46
+ (0, class_validator_1.IsOptional)(),
47
+ (0, class_validator_1.Matches)(exports.SORT_FIELD_PATTERN, { message: (0, validation_message_1.validationMessage)('kit.pagination.invalidSortField') }),
48
+ __metadata("design:type", String)
49
+ ], PaginationInputDTO.prototype, "sortBy", void 0);
50
+ __decorate([
51
+ (0, graphql_1.Field)(() => String, {
52
+ description: 'Направление сортировки ("ASC" или "DESC")',
53
+ defaultValue: 'ASC',
54
+ })
55
+ // Иное направление отклоняется на входе: до 25.09.2026 оно доходило до
56
+ // ORDER BY в списках Стола заказов и роняло их ошибкой 500 (C28-80).
57
+ ,
58
+ (0, class_validator_1.IsOptional)(),
59
+ (0, class_validator_1.IsIn)([...exports.SORT_ORDERS], { message: (0, validation_message_1.validationMessage)('kit.pagination.invalidSortOrder') }),
60
+ __metadata("design:type", Object)
61
+ ], PaginationInputDTO.prototype, "sortOrder", void 0);
62
+ exports.PaginationInputDTO = PaginationInputDTO = __decorate([
63
+ (0, graphql_1.InputType)('PaginationInput')
64
+ ], PaginationInputDTO);
65
+ /** Результат пагинации (универсальный для TypeScript). */
66
+ class PaginationResult {
67
+ items;
68
+ totalCount;
69
+ totalPages;
70
+ currentPage;
71
+ }
72
+ exports.PaginationResult = PaginationResult;
73
+ /**
74
+ * Тип GraphQL результата пагинации `<name>PaginationResult`.
75
+ *
76
+ * Имя типа задаёт владелец списка. У приложения имя начинается с его
77
+ * приставки (`PaginatedKuDecisions`): типы списков приложения принадлежат ему
78
+ * одному и с ядром совпадать не должны.
79
+ *
80
+ * @param ItemType - класс элемента списка
81
+ * @param name - имя объекта GraphQL без суффикса `PaginationResult`
82
+ */
83
+ function createPaginationResult(ItemType, name) {
84
+ let PaginationResult = class PaginationResult {
85
+ items;
86
+ totalCount;
87
+ totalPages;
88
+ currentPage;
89
+ };
90
+ __decorate([
91
+ (0, graphql_1.Field)(() => [ItemType], { description: 'Элементы текущей страницы' }),
92
+ __metadata("design:type", Array)
93
+ ], PaginationResult.prototype, "items", void 0);
94
+ __decorate([
95
+ (0, graphql_1.Field)(() => graphql_1.Int, { description: 'Общее количество элементов' }),
96
+ __metadata("design:type", Number)
97
+ ], PaginationResult.prototype, "totalCount", void 0);
98
+ __decorate([
99
+ (0, graphql_1.Field)(() => graphql_1.Int, { description: 'Общее количество страниц' }),
100
+ __metadata("design:type", Number)
101
+ ], PaginationResult.prototype, "totalPages", void 0);
102
+ __decorate([
103
+ (0, graphql_1.Field)(() => graphql_1.Int, { description: 'Текущая страница' }),
104
+ __metadata("design:type", Number)
105
+ ], PaginationResult.prototype, "currentPage", void 0);
106
+ PaginationResult = __decorate([
107
+ (0, graphql_1.ObjectType)(`${name}PaginationResult`, { isAbstract: true })
108
+ ], PaginationResult);
109
+ return PaginationResult;
110
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Схема подграфа приложения в стандартный вывод — для проверки выпуска.
3
+ *
4
+ * node node_modules/@coopenomics/extension-sdk/dist/graphql/print-subgraph.js \
5
+ * dist/app.module.js [AppModule]
6
+ *
7
+ * Сценарий выпуска `app-kit` запускает его внутри собранного образа бэкенда:
8
+ * в образе те же зависимости, что на узле. Схема выводится между строками
9
+ * `SUBGRAPH_SDL_BEGIN` и `SUBGRAPH_SDL_END`: модули приложения при загрузке
10
+ * могут писать в консоль, и граница отделяет схему от их вывода.
11
+ */
12
+ import 'reflect-metadata';
13
+ export declare const SUBGRAPH_SDL_BEGIN = "-----SUBGRAPH_SDL_BEGIN-----";
14
+ export declare const SUBGRAPH_SDL_END = "-----SUBGRAPH_SDL_END-----";
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SUBGRAPH_SDL_END = exports.SUBGRAPH_SDL_BEGIN = void 0;
4
+ /**
5
+ * Схема подграфа приложения в стандартный вывод — для проверки выпуска.
6
+ *
7
+ * node node_modules/@coopenomics/extension-sdk/dist/graphql/print-subgraph.js \
8
+ * dist/app.module.js [AppModule]
9
+ *
10
+ * Сценарий выпуска `app-kit` запускает его внутри собранного образа бэкенда:
11
+ * в образе те же зависимости, что на узле. Схема выводится между строками
12
+ * `SUBGRAPH_SDL_BEGIN` и `SUBGRAPH_SDL_END`: модули приложения при загрузке
13
+ * могут писать в консоль, и граница отделяет схему от их вывода.
14
+ */
15
+ require("reflect-metadata");
16
+ const node_path_1 = require("node:path");
17
+ const subgraph_sdl_1 = require("./subgraph-sdl");
18
+ exports.SUBGRAPH_SDL_BEGIN = '-----SUBGRAPH_SDL_BEGIN-----';
19
+ exports.SUBGRAPH_SDL_END = '-----SUBGRAPH_SDL_END-----';
20
+ /** Заглушки окружения узла на время печати схемы. */
21
+ const PRINT_ENV = {
22
+ SUBGRAPH_PORT: '4000',
23
+ COOPNAME: 'schemaprint',
24
+ CORE_PORTS_URL: 'http://core-ports.invalid',
25
+ CORE_PORTS_TOKEN: 'schema-print',
26
+ APP_PORTS_URL: 'http://core-ports.invalid',
27
+ APP_PORTS_TOKEN: 'schema-print',
28
+ APP_PORTS_INBOUND_TOKEN: 'schema-print',
29
+ DATABASE_URL: 'postgres://schema-print.invalid/schema',
30
+ JWT_SECRET: 'schema-print',
31
+ };
32
+ async function main() {
33
+ const [file, exportName = 'AppModule'] = process.argv.slice(2);
34
+ if (!file)
35
+ throw new Error('не задан файл корневого модуля приложения (dist/app.module.js)');
36
+ // Модуль приложения при загрузке проверяет окружение, которое оркестратор
37
+ // выдаёт на узле (`loadExtensionConfig` SDK и проверки самого приложения:
38
+ // порт, кооператив, адреса портов ядра). Схема от этих значений не зависит:
39
+ // службы не создаются, соединений нет. Вне узла подставляются заглушки,
40
+ // заданные значения не трогаются.
41
+ for (const [name, value] of Object.entries(PRINT_ENV))
42
+ process.env[name] ||= value;
43
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
44
+ const loaded = require((0, node_path_1.resolve)(file));
45
+ const root = loaded[exportName];
46
+ if (!root)
47
+ throw new Error(`в ${file} нет экспорта ${exportName}`);
48
+ const resolvers = await (0, subgraph_sdl_1.collectResolvers)(root);
49
+ if (resolvers.length === 0)
50
+ throw new Error(`в модулях ${exportName} нет резолверов GraphQL`);
51
+ const sdl = await (0, subgraph_sdl_1.buildSubgraphSdl)(resolvers, { requireFrom: (0, node_path_1.resolve)(file) });
52
+ // Запись в канал асинхронна: `process.exit` до её конца обрезал вывод на
53
+ // 64 КБ (схема «Кооперативного участка», 03.12.2026). Выход — после записи.
54
+ await new Promise((done, fail) => process.stdout.write(`${exports.SUBGRAPH_SDL_BEGIN}\n${sdl}${exports.SUBGRAPH_SDL_END}\n`, (err) => (err ? fail(err) : done())));
55
+ }
56
+ if (require.main === module) {
57
+ main()
58
+ // Модули приложения при загрузке могут открыть соединения; схема уже
59
+ // выведена, ждать их закрытия незачем.
60
+ .then(() => process.exit(0))
61
+ .catch((err) => {
62
+ process.stderr.write(`print-subgraph: ${err instanceof Error ? err.message : String(err)}\n`);
63
+ process.exit(1);
64
+ });
65
+ }
@@ -0,0 +1,31 @@
1
+ /** Одна подпись под документом. */
2
+ export declare class SignatureInfoInputDTO {
3
+ readonly id: number;
4
+ readonly signer: string;
5
+ readonly public_key: string;
6
+ readonly signature: string;
7
+ readonly signed_at: string;
8
+ readonly signed_hash: string;
9
+ readonly meta: string;
10
+ }
11
+ /** Документ в цепи: метаданные строкой JSON, подписи как есть. */
12
+ export interface ChainDocumentFields {
13
+ version: string;
14
+ hash: string;
15
+ doc_hash: string;
16
+ meta_hash: string;
17
+ meta: string;
18
+ signatures: SignatureInfoInputDTO[];
19
+ }
20
+ /** Подписанный документ: хэши, метаданные и подписи. */
21
+ export declare class SignedDigitalDocumentInputDTO {
22
+ readonly version: string;
23
+ readonly hash: string;
24
+ readonly doc_hash: string;
25
+ readonly meta_hash: string;
26
+ readonly meta: any;
27
+ readonly signatures: SignatureInfoInputDTO[];
28
+ constructor(data: SignedDigitalDocumentInputDTO);
29
+ /** Документ в форме цепи: метаданные — строкой JSON. */
30
+ toDocument(): ChainDocumentFields;
31
+ }
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SignedDigitalDocumentInputDTO = exports.SignatureInfoInputDTO = void 0;
13
+ /**
14
+ * Входные типы подписанного документа: подпись, которую пайщик передаёт с
15
+ * интерфейса.
16
+ *
17
+ * Номинальной связи с контрактами ядра (`ISignedDocument` из
18
+ * `@coopenomics/innercoop`, `IChainDocument2` из `cooptypes`) нет: SDK от них
19
+ * не зависит. Совместимость структурная, её сверяет `extension-kit`.
20
+ */
21
+ const graphql_1 = require("@nestjs/graphql");
22
+ const class_validator_1 = require("class-validator");
23
+ const class_transformer_1 = require("class-transformer");
24
+ const graphql_type_json_1 = require("graphql-type-json");
25
+ /** Одна подпись под документом. */
26
+ let SignatureInfoInputDTO = class SignatureInfoInputDTO {
27
+ id;
28
+ signer;
29
+ public_key;
30
+ signature;
31
+ signed_at;
32
+ signed_hash;
33
+ meta;
34
+ };
35
+ exports.SignatureInfoInputDTO = SignatureInfoInputDTO;
36
+ __decorate([
37
+ (0, graphql_1.Field)(() => Number, { description: 'Идентификатор номера подписи' }),
38
+ (0, class_validator_1.IsNumber)(),
39
+ __metadata("design:type", Number)
40
+ ], SignatureInfoInputDTO.prototype, "id", void 0);
41
+ __decorate([
42
+ (0, graphql_1.Field)(() => String, { description: 'Аккаунт подписавшего' }),
43
+ (0, class_validator_1.IsString)(),
44
+ __metadata("design:type", String)
45
+ ], SignatureInfoInputDTO.prototype, "signer", void 0);
46
+ __decorate([
47
+ (0, graphql_1.Field)(() => String, { description: 'Публичный ключ' }),
48
+ (0, class_validator_1.IsString)(),
49
+ __metadata("design:type", String)
50
+ ], SignatureInfoInputDTO.prototype, "public_key", void 0);
51
+ __decorate([
52
+ (0, graphql_1.Field)(() => String, { description: 'Подпись хэша' }),
53
+ (0, class_validator_1.IsString)(),
54
+ __metadata("design:type", String)
55
+ ], SignatureInfoInputDTO.prototype, "signature", void 0);
56
+ __decorate([
57
+ (0, graphql_1.Field)(() => String, { description: 'Время подписания' }),
58
+ (0, class_validator_1.IsString)(),
59
+ __metadata("design:type", String)
60
+ ], SignatureInfoInputDTO.prototype, "signed_at", void 0);
61
+ __decorate([
62
+ (0, graphql_1.Field)(() => String, { description: 'Подписанный хэш' }),
63
+ (0, class_validator_1.IsString)(),
64
+ __metadata("design:type", String)
65
+ ], SignatureInfoInputDTO.prototype, "signed_hash", void 0);
66
+ __decorate([
67
+ (0, graphql_1.Field)(() => String, { description: 'Мета-данные подписи' }),
68
+ (0, class_validator_1.IsString)(),
69
+ __metadata("design:type", String)
70
+ ], SignatureInfoInputDTO.prototype, "meta", void 0);
71
+ exports.SignatureInfoInputDTO = SignatureInfoInputDTO = __decorate([
72
+ (0, graphql_1.InputType)('SignatureInfoInput')
73
+ ], SignatureInfoInputDTO);
74
+ /** Подписанный документ: хэши, метаданные и подписи. */
75
+ let SignedDigitalDocumentInputDTO = class SignedDigitalDocumentInputDTO {
76
+ version;
77
+ hash;
78
+ doc_hash;
79
+ meta_hash;
80
+ meta;
81
+ signatures;
82
+ constructor(data) {
83
+ Object.assign(this, data);
84
+ }
85
+ /** Документ в форме цепи: метаданные — строкой JSON. */
86
+ toDocument() {
87
+ return {
88
+ version: this.version,
89
+ hash: this.hash,
90
+ doc_hash: this.doc_hash,
91
+ meta_hash: this.meta_hash,
92
+ meta: JSON.stringify(this.meta),
93
+ signatures: this.signatures,
94
+ };
95
+ }
96
+ };
97
+ exports.SignedDigitalDocumentInputDTO = SignedDigitalDocumentInputDTO;
98
+ __decorate([
99
+ (0, graphql_1.Field)(() => String, { description: 'Версия стандарта документа' }),
100
+ (0, class_validator_1.IsString)(),
101
+ __metadata("design:type", String)
102
+ ], SignedDigitalDocumentInputDTO.prototype, "version", void 0);
103
+ __decorate([
104
+ (0, graphql_1.Field)(() => String, { description: 'Общий хэш (doc_hash + meta_hash)' }),
105
+ (0, class_validator_1.IsString)(),
106
+ __metadata("design:type", String)
107
+ ], SignedDigitalDocumentInputDTO.prototype, "hash", void 0);
108
+ __decorate([
109
+ (0, graphql_1.Field)(() => String, { description: 'Хэш содержимого документа' }),
110
+ (0, class_validator_1.IsString)(),
111
+ __metadata("design:type", String)
112
+ ], SignedDigitalDocumentInputDTO.prototype, "doc_hash", void 0);
113
+ __decorate([
114
+ (0, graphql_1.Field)(() => String, { description: 'Хэш мета-данных' }),
115
+ (0, class_validator_1.IsString)(),
116
+ __metadata("design:type", String)
117
+ ], SignedDigitalDocumentInputDTO.prototype, "meta_hash", void 0);
118
+ __decorate([
119
+ (0, graphql_1.Field)(() => graphql_type_json_1.GraphQLJSON, { description: 'Метаинформация документа' }),
120
+ __metadata("design:type", Object)
121
+ ], SignedDigitalDocumentInputDTO.prototype, "meta", void 0);
122
+ __decorate([
123
+ (0, graphql_1.Field)(() => [SignatureInfoInputDTO], { description: 'Вектор подписей' }),
124
+ (0, class_validator_1.IsArray)(),
125
+ (0, class_validator_1.ArrayMinSize)(1),
126
+ (0, class_validator_1.ValidateNested)({ each: true }),
127
+ (0, class_transformer_1.Type)(() => SignatureInfoInputDTO),
128
+ __metadata("design:type", Array)
129
+ ], SignedDigitalDocumentInputDTO.prototype, "signatures", void 0);
130
+ exports.SignedDigitalDocumentInputDTO = SignedDigitalDocumentInputDTO = __decorate([
131
+ (0, graphql_1.InputType)('SignedDigitalDocumentInput'),
132
+ __metadata("design:paramtypes", [SignedDigitalDocumentInputDTO])
133
+ ], SignedDigitalDocumentInputDTO);
@@ -0,0 +1,34 @@
1
+ /** Реквизиты одной подписи под документом. */
2
+ export declare class SignatureInfoDTO {
3
+ readonly id: number;
4
+ readonly signer: string;
5
+ readonly public_key: string;
6
+ readonly signature: string;
7
+ readonly signed_at: string;
8
+ readonly signed_hash: string;
9
+ readonly meta: any;
10
+ readonly is_valid?: boolean;
11
+ }
12
+ /**
13
+ * Подписанный документ целиком.
14
+ *
15
+ * Конструктор переносит подписи как есть: поля совпадают по именам, а всё,
16
+ * что ядро добавило сверх контракта (сертификат подписанта), резолвер
17
+ * сертификата получает нетронутым.
18
+ */
19
+ export declare class SignedDigitalDocumentDTO {
20
+ readonly version: string;
21
+ readonly hash: string;
22
+ readonly doc_hash: string;
23
+ readonly meta_hash: string;
24
+ readonly meta: any;
25
+ readonly signatures: SignatureInfoDTO[];
26
+ constructor(data: {
27
+ version: string;
28
+ hash: string;
29
+ doc_hash: string;
30
+ meta_hash: string;
31
+ meta: any;
32
+ signatures: readonly any[];
33
+ });
34
+ }