@coopenomics/app-kit 2026.12.2 → 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.
- package/README.md +60 -7
- package/bin/app-kit.mjs +294 -48
- package/core/core.subgraph.graphql +16941 -0
- package/package.json +8 -2
- package/scripts/catalog-release.sh +112 -8
- package/scripts/check-app-source.mjs +135 -0
- package/scripts/check-subgraph.mjs +64 -0
- package/template/backend/Dockerfile +0 -4
- package/template/backend/src/app.module.ts +6 -4
- package/template/backend/src/core/core-demo.resolver.ts +22 -20
- package/template/backend/src/core/core-demo.types.ts +6 -6
- package/template/backend/src/i18n/index.ts +8 -0
- package/template/backend/src/i18n/ru.json +5 -0
- package/template/backend/src/notes/note.entity.ts +1 -1
- package/template/backend/src/notes/notes.module.ts +1 -1
- package/template/backend/src/notes/notes.resolver.ts +6 -6
- package/template/backend/src/rights.ts +13 -0
- package/template/backend/tsconfig.json +1 -0
- package/template/frontend/frame.html +6 -6
- package/template/backend/src/core/current-identity.decorator.ts +0 -12
- package/template/backend/vendor/README.md +0 -3
|
@@ -8,20 +8,20 @@ import {
|
|
|
8
8
|
Resolver,
|
|
9
9
|
} from '@nestjs/graphql';
|
|
10
10
|
import {
|
|
11
|
+
CurrentUser,
|
|
11
12
|
ExtensionAccessGuard,
|
|
12
13
|
type ExtensionIdentity,
|
|
13
14
|
} from '@coopenomics/extension-sdk';
|
|
14
|
-
import { CurrentIdentity } from '../core/current-identity.decorator';
|
|
15
15
|
import { Note } from './note.entity';
|
|
16
16
|
import { NotesService } from './notes.service';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Локальные Query / Mutation расширения.
|
|
20
20
|
*
|
|
21
|
-
* - `
|
|
21
|
+
* - `exampleappNotes` — публичная выдача последних заметок;
|
|
22
22
|
* в реальном пакете её можно тоже закрыть guard'ом — здесь оставлено
|
|
23
23
|
* открытой, чтобы показать оба варианта (open и protected).
|
|
24
|
-
* - `
|
|
24
|
+
* - `exampleappAddNote` — защищена `ExtensionJwtAuthGuard`. Username
|
|
25
25
|
* автора берётся из JWT в реальном пакете; в этом примере он передаётся
|
|
26
26
|
* аргументом — чтобы пример был запускаемым без сценария на gateway.
|
|
27
27
|
*
|
|
@@ -32,19 +32,19 @@ import { NotesService } from './notes.service';
|
|
|
32
32
|
export class NotesResolver {
|
|
33
33
|
constructor(private readonly notes: NotesService) {}
|
|
34
34
|
|
|
35
|
-
@Query(() => [Note], { name: '
|
|
35
|
+
@Query(() => [Note], { name: 'exampleappNotes' })
|
|
36
36
|
list(
|
|
37
37
|
@Args('limit', { type: () => Int, nullable: true }) limit?: number,
|
|
38
38
|
): Note[] {
|
|
39
39
|
return this.notes.list(limit);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
@Mutation(() => Note, { name: '
|
|
42
|
+
@Mutation(() => Note, { name: 'exampleappAddNote' })
|
|
43
43
|
@UseGuards(ExtensionAccessGuard)
|
|
44
44
|
add(
|
|
45
45
|
// Автор — пайщик, которого опознало ядро, а не аргумент запроса: иначе
|
|
46
46
|
// заметку можно записать от чужого имени.
|
|
47
|
-
@
|
|
47
|
+
@CurrentUser() identity: ExtensionIdentity,
|
|
48
48
|
@Args('body') body: string,
|
|
49
49
|
): Note {
|
|
50
50
|
return this.notes.add(identity.username, body);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AppRightsConfig } from '@coopenomics/extension-sdk';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Права приложения: роль пайщика → ресурс → действия. Операция называет
|
|
5
|
+
* право `@RequireRight('SignProbe', 'run')` и стоит под `RightsGuard`;
|
|
6
|
+
* нехватка прав — отказ с кодом `deniedCode` из словаря приложения.
|
|
7
|
+
*/
|
|
8
|
+
export const exampleappRights: AppRightsConfig = {
|
|
9
|
+
table: {
|
|
10
|
+
chairman: { SignProbe: ['run'] },
|
|
11
|
+
},
|
|
12
|
+
deniedCode: 'EXAMPLEAPP_INSUFFICIENT_RIGHTS',
|
|
13
|
+
};
|
|
@@ -132,9 +132,9 @@ call('init').then(function (ctx) {
|
|
|
132
132
|
applyTheme(ctx.theme);
|
|
133
133
|
text(el('who'), ctx.username);
|
|
134
134
|
text(el('coop'), ctx.coopname);
|
|
135
|
-
return gql('{
|
|
135
|
+
return gql('{ exampleappCooperative { coopname name shortAbbr } }');
|
|
136
136
|
}).then(function (data) {
|
|
137
|
-
var c = data.
|
|
137
|
+
var c = data.exampleappCooperative;
|
|
138
138
|
text(el('coop-name'), c ? c.shortAbbr + ' «' + c.name + '»' : '—');
|
|
139
139
|
}).catch(function (e) { text(el('coop-name'), e.message); });
|
|
140
140
|
|
|
@@ -164,7 +164,7 @@ function renderNotes(notes) {
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
function loadNotes() {
|
|
167
|
-
return gql('{
|
|
167
|
+
return gql('{ exampleappNotes(limit: 10) { id authorUsername body } }').then(function (d) { renderNotes(d.exampleappNotes); });
|
|
168
168
|
}
|
|
169
169
|
loadNotes().catch(function (e) { text(el('note-error'), e.message); });
|
|
170
170
|
|
|
@@ -173,7 +173,7 @@ el('note-add').addEventListener('click', function () {
|
|
|
173
173
|
text(el('note-error'), '');
|
|
174
174
|
if (!body) return;
|
|
175
175
|
el('note-add').disabled = true;
|
|
176
|
-
gql('mutation($b: String!) {
|
|
176
|
+
gql('mutation($b: String!) { exampleappAddNote(body: $b) { id } }', { b: body })
|
|
177
177
|
.then(function () { el('note-body').value = ''; return loadNotes(); })
|
|
178
178
|
.catch(function (e) { text(el('note-error'), e.message); })
|
|
179
179
|
.then(function () { el('note-add').disabled = false; });
|
|
@@ -184,8 +184,8 @@ el('sign').addEventListener('click', function () {
|
|
|
184
184
|
text(el('sign-error'), '');
|
|
185
185
|
el('sign-result').innerHTML = '';
|
|
186
186
|
el('sign').disabled = true;
|
|
187
|
-
gql('mutation {
|
|
188
|
-
.then(function (d) { return call('sign', { hash: d.
|
|
187
|
+
gql('mutation { exampleappDraftDocument { fullTitle hash } }')
|
|
188
|
+
.then(function (d) { return call('sign', { hash: d.exampleappDraftDocument.hash }); })
|
|
189
189
|
.then(function (signed) {
|
|
190
190
|
var first = signed && signed.signatures && signed.signatures[0];
|
|
191
191
|
var box = el('sign-result');
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { createParamDecorator, ExecutionContext } from '@nestjs/common';
|
|
2
|
-
import { GqlExecutionContext } from '@nestjs/graphql';
|
|
3
|
-
import type { ExtensionIdentity } from '@coopenomics/extension-sdk';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Пайщик, сделавший запрос. Его кладёт в запрос `ExtensionAccessGuard` после
|
|
7
|
-
* ответа ядра; без охранника на резолвере значения нет.
|
|
8
|
-
*/
|
|
9
|
-
export const CurrentIdentity = createParamDecorator(
|
|
10
|
-
(_data: unknown, context: ExecutionContext): ExtensionIdentity =>
|
|
11
|
-
GqlExecutionContext.create(context).getContext().req.user,
|
|
12
|
-
);
|