@things-factory/figure-library 10.1.288 → 10.1.290

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.
@@ -0,0 +1,10 @@
1
+ import './ox-item-types-input.js';
2
+ /**
3
+ * Opens the domain's table of a theme type in the popup and keeps what is confirmed: in its active theme, or a new active
4
+ * theme of that type named after it when the domain has none. `saved` is called once it is kept, so a caller that holds
5
+ * the table reads it again.
6
+ */
7
+ export declare function openDomainTypeTable({ themeType, saved }: {
8
+ themeType: string;
9
+ saved?: () => void;
10
+ }): Promise<void>;
@@ -0,0 +1,68 @@
1
+ /*
2
+ * A domain's item type table (ADR-0155) edited where it is used, with no theme screen: the domain's active theme of the
3
+ * type. An app whose screens have no theme list (operato-twin, which does not carry board-ui) opens the same popup the
4
+ * theme screen opens, and the value is kept in the same theme, so every scene reads it the same way
5
+ * (`fetchDomainItemTypes`).
6
+ */
7
+ import './ox-item-types-input.js';
8
+ import gql from 'graphql-tag';
9
+ import { html } from 'lit';
10
+ import { client } from '@operato/graphql';
11
+ import { i18next } from '@operato/i18n';
12
+ import { openPopup } from '@operato/popup';
13
+ import { rowsOf, valueOf } from './item-types-rows.js';
14
+ const THEMES = gql `
15
+ query ($filters: [Filter!]) {
16
+ themes(filters: $filters) {
17
+ items {
18
+ id
19
+ name
20
+ type
21
+ active
22
+ value
23
+ }
24
+ }
25
+ }
26
+ `;
27
+ const CREATE = gql `
28
+ mutation ($theme: NewTheme!) {
29
+ createTheme(theme: $theme) {
30
+ id
31
+ }
32
+ }
33
+ `;
34
+ const UPDATE = gql `
35
+ mutation ($id: String!, $patch: ThemePatch!) {
36
+ updateTheme(id: $id, patch: $patch) {
37
+ id
38
+ }
39
+ }
40
+ `;
41
+ /**
42
+ * Opens the domain's table of a theme type in the popup and keeps what is confirmed: in its active theme, or a new active
43
+ * theme of that type named after it when the domain has none. `saved` is called once it is kept, so a caller that holds
44
+ * the table reads it again.
45
+ */
46
+ export async function openDomainTypeTable({ themeType, saved }) {
47
+ const { data } = await client.query({ query: THEMES, variables: { filters: [{ name: 'type', operator: 'eq', value: themeType }] }, fetchPolicy: 'network-only' });
48
+ const themes = (data?.themes?.items ?? []);
49
+ const theme = themes.find(t => t.active);
50
+ const asText = typeof theme?.value === 'string';
51
+ const confirmCallback = async (rows) => {
52
+ const value = valueOf(rows);
53
+ if (theme) {
54
+ await client.mutate({ mutation: UPDATE, variables: { id: theme.id, patch: { value: asText ? JSON.stringify(value) : value } } });
55
+ }
56
+ else {
57
+ await client.mutate({ mutation: CREATE, variables: { theme: { name: themeType, type: themeType, active: true, value } } });
58
+ }
59
+ saved?.();
60
+ };
61
+ const title = i18next.t('figure-library.item-types.title');
62
+ openPopup(html `<ox-item-types-input .rows=${rowsOf(theme?.value)} .confirmCallback=${confirmCallback}></ox-item-types-input>`, {
63
+ backdrop: true,
64
+ size: 'large',
65
+ title: theme ? `${title} : ${theme.name}` : title
66
+ });
67
+ }
68
+ //# sourceMappingURL=domain-type-table.js.map
@@ -1,6 +1,7 @@
1
1
  import { ITEM_TYPES_THEME, type ItemTypeTable } from '@hatiolab/things-scene';
2
2
  export { ITEM_TYPES_THEME };
3
3
  export * from './item-types-rows.js';
4
+ export { openDomainTypeTable } from './domain-type-table.js';
4
5
  export declare function registerItemTypesEditor(type?: string): void;
5
6
  /**
6
7
  * The domain's item type table (ADR-0155): its active theme of the type, read by things-scene's rule. Asked each time a
@@ -11,6 +11,7 @@ import { OxGristEditorItemTypes } from './item-types-editor.js';
11
11
  import { OxGristRendererItemTypes } from './item-types-renderer.js';
12
12
  export { ITEM_TYPES_THEME };
13
13
  export * from './item-types-rows.js';
14
+ export { openDomainTypeTable } from './domain-type-table.js';
14
15
  export function registerItemTypesEditor(type = ITEM_TYPES_THEME) {
15
16
  registerEditor(type, OxGristEditorItemTypes);
16
17
  registerRenderer(type, OxGristRendererItemTypes);
@@ -21,6 +21,7 @@ export declare class FigureSourceSettingLet extends FigureSourceSettingLet_base
21
21
  connectedCallback(): Promise<void>;
22
22
  private get setting();
23
23
  render(): import("lit-html").TemplateResult<1> | typeof nothing;
24
+ private renderCapabilityModule;
24
25
  private check;
25
26
  private save;
26
27
  }
@@ -10,7 +10,7 @@ import { i18next, localize } from '@operato/i18n';
10
10
  import { notify } from '@operato/layout';
11
11
  import { FieldHintStyles } from '@operato/styles';
12
12
  import { hasPrivilege } from '@things-factory/auth-base/dist-client';
13
- const FIELDS = 'url domain tokenSet tokenHint';
13
+ const FIELDS = 'url domain tokenSet tokenHint capabilityModule { provider version pushed error }';
14
14
  /**
15
15
  * 「피규어 서버 연결」 (ADR-0114 decision 21) - the figure server this domain installs figures from: its address, the
16
16
  * domain on it and the access token it issued. Domain attributes, so shown to whoever may change them (privilege
@@ -80,9 +80,17 @@ let FigureSourceSettingLet = class FigureSourceSettingLet extends localize(i18ne
80
80
  small[missing] {
81
81
  color: var(--ui-warn, #b26b00);
82
82
  }
83
- [checked][failed] {
83
+ [checked][failed],
84
+ small[capability][failed] {
84
85
  color: var(--ui-crit, var(--md-sys-color-error));
85
86
  }
87
+ small[capability] {
88
+ grid-column: 1 / -1;
89
+ /* A provider name is lower-case by rule: the card's capitalised words must not reach it. */
90
+ text-transform: none;
91
+ font-size: var(--ui-t-small, 11.5px);
92
+ color: var(--md-sys-color-on-surface-variant);
93
+ }
86
94
  `
87
95
  ]; }
88
96
  async connectedCallback() {
@@ -131,6 +139,7 @@ let FigureSourceSettingLet = class FigureSourceSettingLet extends localize(i18ne
131
139
  : i18next.t('figure-library.setting.token-unset')}</small
132
140
  ></label
133
141
  >
142
+ ${this.renderCapabilityModule(setting.capabilityModule)}
134
143
  <div actions>
135
144
  ${this.checked ? html `<span checked ?failed=${!this.checked.ok} role="status">${this.checked.text}</span>` : nothing}
136
145
  <md-text-button ?disabled=${busy || this.checking || !setting.url || !setting.tokenSet} @click=${() => this.check()}
@@ -142,6 +151,20 @@ let FigureSourceSettingLet = class FigureSourceSettingLet extends localize(i18ne
142
151
  </setting-let>
143
152
  `;
144
153
  }
154
+ /*
155
+ This app's capability module on the linked domain (ADR-0172 amendment 1): pushed when the link is saved or checked
156
+ and when the server starts. A push that failed is said here; the app works on.
157
+ */
158
+ renderCapabilityModule(push) {
159
+ if (!push)
160
+ return nothing;
161
+ const { provider, version } = push;
162
+ if (push.error)
163
+ return html `<small capability failed role="status">${i18next.t('figure-library.setting.capability-push-failed', { provider, version, reason: push.error })}</small>`;
164
+ if (push.pushed)
165
+ return html `<small capability>${i18next.t('figure-library.setting.capability-pushed', { provider, version })}</small>`;
166
+ return html `<small capability>${i18next.t('figure-library.setting.capability-not-pushed', { provider, version })}</small>`;
167
+ }
145
168
  /* One catalog row asked with the saved setting: the answer says what to fix. */
146
169
  async check() {
147
170
  this.checking = true;
@@ -161,6 +184,8 @@ let FigureSourceSettingLet = class FigureSourceSettingLet extends localize(i18ne
161
184
  fetchPolicy: 'no-cache'
162
185
  });
163
186
  const answer = response.data.checkFigureLibrarySource;
187
+ /* The check pushes the capability module too: read where it stands again. */
188
+ this.settingRead.refetch?.();
164
189
  this.checked = answer.ok
165
190
  ? { ok: true, text: i18next.t('figure-library.setting.check-ok', { count: answer.total ?? 0 }) }
166
191
  : { ok: false, text: answer.message ?? answer.code };
@@ -19,6 +19,7 @@ export * from './source/source-setting-rules';
19
19
  export * from './source/source-client';
20
20
  export * from './source/source-install';
21
21
  export * from './source/figure-source-resolver';
22
+ export * from './source/capability-push';
22
23
  export declare const entities: (typeof FigureLibraryRelease | typeof FigureTypeMapEntry)[];
23
24
  export declare const schema: {
24
25
  resolverClasses: (typeof FigureSourceResolver | typeof FigureLibraryResolver)[];
@@ -27,6 +27,7 @@ tslib_1.__exportStar(require("./source/source-setting-rules"), exports);
27
27
  tslib_1.__exportStar(require("./source/source-client"), exports);
28
28
  tslib_1.__exportStar(require("./source/source-install"), exports);
29
29
  tslib_1.__exportStar(require("./source/figure-source-resolver"), exports);
30
+ tslib_1.__exportStar(require("./source/capability-push"), exports);
30
31
  /* The shell builds the database and the schema from these two names; a module without them has no tables and no doors. */
31
32
  exports.entities = [figure_library_release_1.FigureLibraryRelease, figure_type_map_entry_1.FigureTypeMapEntry];
32
33
  exports.schema = { resolverClasses: [figure_library_resolver_1.FigureLibraryResolver, figure_source_resolver_1.FigureSourceResolver] };
@@ -0,0 +1,62 @@
1
+ import { EntityManager } from 'typeorm';
2
+ import type { FigureCapabilityChoice } from '@hatiolab/figure-model';
3
+ import { type SourceFetch } from './source-client';
4
+ import { type FigureSource } from './source-setting-rules';
5
+ /** The module an app carries: the file, and its provider and version as the module exports them. */
6
+ export interface FigureCapabilityModuleDeclaration {
7
+ /** The module file (one ESM file, ADR-0172 decision 3), an absolute path */
8
+ file: string;
9
+ /** Read from the module when left out */
10
+ provider?: string;
11
+ version?: string;
12
+ /**
13
+ * The choice lists of the module's settings (ADR-0172 amendment 2, decision 19), by `<capability>.<setting>`: what this
14
+ * app holds now, asked of the app's domain linked to the figure server. Pushed with the module, again when they change.
15
+ */
16
+ choices?: (domain: {
17
+ id: string;
18
+ }) => Promise<Record<string, readonly FigureCapabilityChoice[]>>;
19
+ }
20
+ /** One item of a choice list, as figure-model defines it: value, words, group `{ value, label }` and facts. */
21
+ export type { FigureCapabilityChoice } from '@hatiolab/figure-model';
22
+ /** Where the last push of a domain stands, as the link's card shows it. */
23
+ export interface FigureCapabilityPushState {
24
+ provider: string;
25
+ version: string;
26
+ /** The hash pushed last, when the last push went up */
27
+ pushed?: string;
28
+ /** Why the last push did not go up */
29
+ error?: string;
30
+ }
31
+ /** The domain attributes the push keeps: the hashes it last pushed (module, choices), and why the last one failed. */
32
+ export declare const PUSHED_HASH = "FigureLibrary::source::capability-module-hash";
33
+ export declare const PUSHED_CHOICES_HASH = "FigureLibrary::source::capability-choices-hash";
34
+ export declare const PUSH_ERROR = "FigureLibrary::source::capability-module-error";
35
+ /**
36
+ * Declares the app's capability module (one per app). Call it when the server module loads. The provider and version
37
+ * left out are read from the module itself.
38
+ */
39
+ export declare function declareFigureCapabilityModule(declaration: FigureCapabilityModuleDeclaration): void;
40
+ /** The app's declared module, or none. */
41
+ export declare const declaredFigureCapabilityModule: () => Required<Omit<FigureCapabilityModuleDeclaration, "choices">> & Pick<FigureCapabilityModuleDeclaration, "choices">;
42
+ /** Where the domain's push stands; none when the app declares no module. */
43
+ export declare function capabilityPushState(manager: EntityManager, domain: {
44
+ id: string;
45
+ }): Promise<FigureCapabilityPushState | undefined>;
46
+ /**
47
+ * Pushes the app's module to the linked figure server domain when its hash is not the one last pushed (decision 13).
48
+ * Never throws: what failed is kept for the card, and the app goes on.
49
+ */
50
+ export declare function pushCapabilityModule(manager: EntityManager, domain: {
51
+ id: string;
52
+ }, source: FigureSource | null, options?: {
53
+ force?: boolean;
54
+ doFetch?: SourceFetch;
55
+ read?: (file: string) => Buffer;
56
+ t?: (key: string, options?: Record<string, unknown>) => string;
57
+ }): Promise<FigureCapabilityPushState | undefined>;
58
+ /** At server start: every domain linked to a figure server pushes, when its module changed since. */
59
+ export declare function pushCapabilityModulesOfLinkedDomains(manager?: EntityManager, options?: {
60
+ doFetch?: SourceFetch;
61
+ read?: (file: string) => Buffer;
62
+ }): Promise<void>;
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.declaredFigureCapabilityModule = exports.PUSH_ERROR = exports.PUSHED_CHOICES_HASH = exports.PUSHED_HASH = void 0;
4
+ exports.declareFigureCapabilityModule = declareFigureCapabilityModule;
5
+ exports.capabilityPushState = capabilityPushState;
6
+ exports.pushCapabilityModule = pushCapabilityModule;
7
+ exports.pushCapabilityModulesOfLinkedDomains = pushCapabilityModulesOfLinkedDomains;
8
+ const crypto_1 = require("crypto");
9
+ const fs_1 = require("fs");
10
+ const shell_1 = require("@things-factory/shell");
11
+ const source_client_1 = require("./source-client");
12
+ const source_setting_rules_1 = require("./source-setting-rules");
13
+ /* Node's own require, which loads an ES module file (22.12+), past any loader in front of this file's `require`. */
14
+ const nodeRequire = process.getBuiltinModule?.('node:module')?.createRequire(__filename) ?? require;
15
+ /** The domain attributes the push keeps: the hashes it last pushed (module, choices), and why the last one failed. */
16
+ exports.PUSHED_HASH = 'FigureLibrary::source::capability-module-hash';
17
+ exports.PUSHED_CHOICES_HASH = 'FigureLibrary::source::capability-choices-hash';
18
+ exports.PUSH_ERROR = 'FigureLibrary::source::capability-module-error';
19
+ let declared;
20
+ /**
21
+ * Declares the app's capability module (one per app). Call it when the server module loads. The provider and version
22
+ * left out are read from the module itself.
23
+ */
24
+ function declareFigureCapabilityModule(declaration) {
25
+ const { provider, version } = declaration.provider && declaration.version ? declaration : nodeRequire(declaration.file);
26
+ declared = { file: declaration.file, provider, version, ...(declaration.choices ? { choices: declaration.choices } : {}) };
27
+ }
28
+ /** The app's declared module, or none. */
29
+ const declaredFigureCapabilityModule = () => declared;
30
+ exports.declaredFigureCapabilityModule = declaredFigureCapabilityModule;
31
+ const PUSH = `mutation ($source: String!, $choices: Object) { pushFigureCapabilityModule(source: $source, choices: $choices) { provider version sha256 } }`;
32
+ async function attribute(manager, domain, name) {
33
+ return manager.getRepository(shell_1.EnvVar).findOne({ where: { domain: { id: domain.id }, name } });
34
+ }
35
+ async function write(manager, domain, name, value) {
36
+ const repository = manager.getRepository(shell_1.EnvVar);
37
+ const own = await attribute(manager, domain, name);
38
+ if (value === null) {
39
+ if (own)
40
+ await repository.delete(own.id);
41
+ }
42
+ else if (own)
43
+ await repository.save({ ...own, value, active: true });
44
+ else
45
+ await repository.save({ domain, name, value, active: true, description: 'Figure server link: the capability module pushed (ADR-0172)' });
46
+ }
47
+ /** Where the domain's push stands; none when the app declares no module. */
48
+ async function capabilityPushState(manager, domain) {
49
+ if (!declared)
50
+ return undefined;
51
+ const pushed = (await attribute(manager, domain, exports.PUSHED_HASH))?.value || undefined;
52
+ const error = (await attribute(manager, domain, exports.PUSH_ERROR))?.value || undefined;
53
+ return { provider: declared.provider, version: declared.version, ...(pushed ? { pushed } : {}), ...(error ? { error } : {}) };
54
+ }
55
+ /**
56
+ * Pushes the app's module to the linked figure server domain when its hash is not the one last pushed (decision 13).
57
+ * Never throws: what failed is kept for the card, and the app goes on.
58
+ */
59
+ async function pushCapabilityModule(manager, domain, source, options = {}) {
60
+ if (!declared || !source)
61
+ return capabilityPushState(manager, domain);
62
+ try {
63
+ const bytes = (options.read ?? fs_1.readFileSync)(declared.file);
64
+ const hash = (0, crypto_1.createHash)('sha256').update(bytes).digest('hex');
65
+ /* The lists as the app holds them now; a list that cannot be read goes up as none rather than stopping the module. */
66
+ const choices = declared.choices ? await declared.choices(domain) : undefined;
67
+ const choicesHash = choices ? (0, crypto_1.createHash)('sha256').update(JSON.stringify(choices)).digest('hex') : null;
68
+ const last = (await attribute(manager, domain, exports.PUSHED_HASH))?.value;
69
+ const lastChoices = (await attribute(manager, domain, exports.PUSHED_CHOICES_HASH))?.value ?? null;
70
+ const failed = (await attribute(manager, domain, exports.PUSH_ERROR))?.value;
71
+ if (!options.force && last === hash && lastChoices === choicesHash && !failed)
72
+ return capabilityPushState(manager, domain);
73
+ await (0, source_client_1.sourceQuery)(source, PUSH, { source: bytes.toString('utf8'), ...(choices ? { choices } : {}) }, options.doFetch);
74
+ await write(manager, domain, exports.PUSHED_HASH, hash);
75
+ await write(manager, domain, exports.PUSHED_CHOICES_HASH, choicesHash);
76
+ await write(manager, domain, exports.PUSH_ERROR, null);
77
+ }
78
+ catch (error) {
79
+ const said = error instanceof shell_1.Refusal
80
+ ? options.t
81
+ ? options.t(`error.${error.code}`, { ...error.params, defaultValue: error.message })
82
+ : error.message.replace(/\{(\w+)\}/g, (all, key) => String(error.params?.[key] ?? all))
83
+ : error?.message ?? String(error);
84
+ await write(manager, domain, exports.PUSH_ERROR, String(said).slice(0, 1000));
85
+ console.warn(`[figure-library] the capability module ${declared.provider} ${declared.version} was not pushed: ${said}`);
86
+ }
87
+ return capabilityPushState(manager, domain);
88
+ }
89
+ /** At server start: every domain linked to a figure server pushes, when its module changed since. */
90
+ async function pushCapabilityModulesOfLinkedDomains(manager = (0, shell_1.getDataSource)().manager, options = {}) {
91
+ if (!declared)
92
+ return;
93
+ const rows = await manager.getRepository(shell_1.EnvVar).find({ where: { name: (0, source_setting_rules_1.sourceAttributeOf)('url'), active: true }, relations: { domain: true } });
94
+ for (const row of rows) {
95
+ if (!row.domain)
96
+ continue;
97
+ const attributes = Object.fromEntries((await manager.getRepository(shell_1.EnvVar).find({ where: { domain: { id: row.domain.id }, active: true } })).map(one => [one.name, one.value]));
98
+ await pushCapabilityModule(manager, row.domain, (0, source_setting_rules_1.sourceOf)(attributes), options);
99
+ }
100
+ }
101
+ process.on('bootstrap-module-start', () => {
102
+ /* After the app's modules have declared theirs; nothing waits on it. */
103
+ setTimeout(() => pushCapabilityModulesOfLinkedDomains().catch(e => console.warn(`[figure-library] capability module push at start: ${e?.message ?? e}`)), 0);
104
+ });
105
+ //# sourceMappingURL=capability-push.js.map
@@ -2,7 +2,14 @@ import { EntityManager } from 'typeorm';
2
2
  import { ListParam } from '@things-factory/shell';
3
3
  import { FigureImportResult } from '../figure-library-types';
4
4
  import { type FigureSource } from './source-setting-rules';
5
+ export declare class FigureCapabilityPush {
6
+ provider: string;
7
+ version: string;
8
+ pushed?: string;
9
+ error?: string;
10
+ }
5
11
  export declare class FigureSourceSetting {
12
+ capabilityModule?: FigureCapabilityPush;
6
13
  url?: string;
7
14
  domain?: string;
8
15
  tokenSet: boolean;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FigureSourceResolver = exports.FigureSourceCatalog = exports.FigureSourceCatalogItem = exports.FigureSourceCheck = exports.FigureSourceSettingPatch = exports.FigureSourceSetting = void 0;
3
+ exports.FigureSourceResolver = exports.FigureSourceCatalog = exports.FigureSourceCatalogItem = exports.FigureSourceCheck = exports.FigureSourceSettingPatch = exports.FigureSourceSetting = exports.FigureCapabilityPush = void 0;
4
4
  exports.figureSourceOf = figureSourceOf;
5
5
  const tslib_1 = require("tslib");
6
6
  const type_graphql_1 = require("type-graphql");
@@ -9,10 +9,37 @@ const typeorm_1 = require("typeorm");
9
9
  const shell_1 = require("@things-factory/shell");
10
10
  const figure_library_types_1 = require("../figure-library-types");
11
11
  const source_install_1 = require("./source-install");
12
+ const capability_push_1 = require("./capability-push");
12
13
  const source_setting_rules_1 = require("./source-setting-rules");
14
+ let FigureCapabilityPush = class FigureCapabilityPush {
15
+ };
16
+ exports.FigureCapabilityPush = FigureCapabilityPush;
17
+ tslib_1.__decorate([
18
+ (0, type_graphql_1.Field)({ description: 'The capability provider of this app.' }),
19
+ tslib_1.__metadata("design:type", String)
20
+ ], FigureCapabilityPush.prototype, "provider", void 0);
21
+ tslib_1.__decorate([
22
+ (0, type_graphql_1.Field)({ description: 'The module version this app carries.' }),
23
+ tslib_1.__metadata("design:type", String)
24
+ ], FigureCapabilityPush.prototype, "version", void 0);
25
+ tslib_1.__decorate([
26
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The hash pushed last, when the last push went up.' }),
27
+ tslib_1.__metadata("design:type", String)
28
+ ], FigureCapabilityPush.prototype, "pushed", void 0);
29
+ tslib_1.__decorate([
30
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Why the last push did not go up.' }),
31
+ tslib_1.__metadata("design:type", String)
32
+ ], FigureCapabilityPush.prototype, "error", void 0);
33
+ exports.FigureCapabilityPush = FigureCapabilityPush = tslib_1.__decorate([
34
+ (0, type_graphql_1.ObjectType)({ description: "Where this app's capability module stands on the linked figure server domain (ADR-0172 amendment 1)." })
35
+ ], FigureCapabilityPush);
13
36
  let FigureSourceSetting = class FigureSourceSetting {
14
37
  };
15
38
  exports.FigureSourceSetting = FigureSourceSetting;
39
+ tslib_1.__decorate([
40
+ (0, type_graphql_1.Field)(type => FigureCapabilityPush, { nullable: true, description: "This app's capability module on the linked domain; none when the app carries none." }),
41
+ tslib_1.__metadata("design:type", FigureCapabilityPush)
42
+ ], FigureSourceSetting.prototype, "capabilityModule", void 0);
16
43
  tslib_1.__decorate([
17
44
  (0, type_graphql_1.Field)({ nullable: true, description: 'The figure server address, e.g. https://figure.hatiolab.com.' }),
18
45
  tslib_1.__metadata("design:type", String)
@@ -169,7 +196,8 @@ async function figureSourceOf(domain, manager) {
169
196
  let FigureSourceResolver = class FigureSourceResolver {
170
197
  async figureLibrarySource(context) {
171
198
  const { domain, tx } = context.state;
172
- return (0, source_setting_rules_1.sourceSettingState)(await sourceAttributes(domain, tx ?? (0, shell_1.getDataSource)().manager), shell_1.secretHint);
199
+ const manager = tx ?? (0, shell_1.getDataSource)().manager;
200
+ return { ...(0, source_setting_rules_1.sourceSettingState)(await sourceAttributes(domain, manager), shell_1.secretHint), capabilityModule: await (0, capability_push_1.capabilityPushState)(manager, domain) };
173
201
  }
174
202
  async updateFigureLibrarySource(patch, context) {
175
203
  const { domain, tx } = context.state;
@@ -194,13 +222,18 @@ let FigureSourceResolver = class FigureSourceResolver {
194
222
  else
195
223
  await repository.save({ domain, name, value, active: true, description: 'Figure server to install from (ADR-0114) - set on the Settings screen' });
196
224
  }
197
- return (0, source_setting_rules_1.sourceSettingState)(await sourceAttributes(domain, tx), shell_1.secretHint);
225
+ const attributes = await sourceAttributes(domain, tx);
226
+ /* Linked again: the app's capability module goes up when it is not the one last pushed (ADR-0172 decision 13). */
227
+ const capabilityModule = await (0, capability_push_1.pushCapabilityModule)(tx, domain, (0, source_setting_rules_1.sourceOf)(attributes), { t: context.t });
228
+ return { ...(0, source_setting_rules_1.sourceSettingState)(attributes, shell_1.secretHint), capabilityModule };
198
229
  }
199
230
  async checkFigureLibrarySource(context) {
200
231
  const { domain, tx } = context.state;
201
232
  try {
202
- const source = await figureSourceOf(domain, tx ?? (0, shell_1.getDataSource)().manager);
233
+ const manager = tx ?? (0, shell_1.getDataSource)().manager;
234
+ const source = await figureSourceOf(domain, manager);
203
235
  const { total } = await (0, source_install_1.sourceCatalogPage)(source, { pagination: { page: 1, limit: 1 } });
236
+ await (0, capability_push_1.pushCapabilityModule)(manager, domain, source, { t: context.t });
204
237
  return { ok: true, total };
205
238
  }
206
239
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/figure-library",
3
- "version": "10.1.288",
3
+ "version": "10.1.290",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "files": [
@@ -41,8 +41,8 @@
41
41
  "test": "node --import ./test/resolve-ts-siblings.mjs --test test/*.test.ts"
42
42
  },
43
43
  "dependencies": {
44
- "@hatiolab/figure-model": "^0.12.4",
45
- "@hatiolab/things-scene": "^10.1.111",
44
+ "@hatiolab/figure-model": "^0.12.16",
45
+ "@hatiolab/things-scene": "^10.1.123",
46
46
  "@material/web": "^2.0.0",
47
47
  "@operato/data-grist": "^10.29.69",
48
48
  "@operato/graphql": "^10.29.69",
@@ -55,13 +55,13 @@
55
55
  "@operato/slot-layout-editor": "^10.29.87",
56
56
  "@operato/styles": "^10.29.23",
57
57
  "@operato/utils": "^10.0.0",
58
- "@things-factory/attachment-base": "^10.1.283",
59
- "@things-factory/auth-base": "^10.1.283",
60
- "@things-factory/board-service": "^10.1.283",
58
+ "@things-factory/attachment-base": "^10.1.290",
59
+ "@things-factory/auth-base": "^10.1.290",
60
+ "@things-factory/board-service": "^10.1.290",
61
61
  "@things-factory/env": "^10.1.281",
62
- "@things-factory/figure-viewer": "^10.1.281",
63
- "@things-factory/setting-base": "^10.1.283",
64
- "@things-factory/shell": "^10.1.283",
62
+ "@things-factory/figure-viewer": "^10.1.290",
63
+ "@things-factory/setting-base": "^10.1.290",
64
+ "@things-factory/shell": "^10.1.290",
65
65
  "graphql-scalars": "^1.22.4",
66
66
  "graphql-tag": "^2.12.6",
67
67
  "graphql-upload": "^15.0.2",
@@ -69,5 +69,5 @@
69
69
  "koa-router": "^7.4.0",
70
70
  "lit": "^3.1.2"
71
71
  },
72
- "gitHead": "78eaee46dd9b425ed845b02952b082f35a0faca7"
72
+ "gitHead": "b3d769457fc4976b73726bb1556b5036351f1b10"
73
73
  }
@@ -184,5 +184,8 @@
184
184
  "error.figure-import-conflict": "The same version is already here with another content.",
185
185
  "figure-library.button.change-source": "Change connection",
186
186
  "figure-library.setting.example": "e.g. {value}",
187
- "figure-library.setting.missing": "Needed to connect."
187
+ "figure-library.setting.missing": "Needed to connect.",
188
+ "figure-library.setting.capability-pushed": "This app's capability module ({provider} {version}) is on the figure server.",
189
+ "figure-library.setting.capability-not-pushed": "This app's capability module ({provider} {version}) is not on the figure server yet. Saving or checking the link pushes it.",
190
+ "figure-library.setting.capability-push-failed": "This app's capability module ({provider} {version}) could not be pushed to the figure server. The app works on. Reason: {reason}"
188
191
  }
@@ -184,5 +184,8 @@
184
184
  "error.figure-import-conflict": "La misma versión ya está aquí con otro contenido.",
185
185
  "figure-library.button.change-source": "Cambiar conexión",
186
186
  "figure-library.setting.example": "p. ej. {value}",
187
- "figure-library.setting.missing": "Necesario para conectar."
187
+ "figure-library.setting.missing": "Necesario para conectar.",
188
+ "figure-library.setting.capability-pushed": "This app's capability module ({provider} {version}) is on the figure server.",
189
+ "figure-library.setting.capability-not-pushed": "This app's capability module ({provider} {version}) is not on the figure server yet. Saving or checking the link pushes it.",
190
+ "figure-library.setting.capability-push-failed": "This app's capability module ({provider} {version}) could not be pushed to the figure server. The app works on. Reason: {reason}"
188
191
  }
@@ -184,5 +184,8 @@
184
184
  "error.figure-import-conflict": "同じバージョンが別の内容で既に登録されているため、登録できません。",
185
185
  "figure-library.button.change-source": "接続を変更",
186
186
  "figure-library.setting.example": "例: {value}",
187
- "figure-library.setting.missing": "入力すると接続されます。"
187
+ "figure-library.setting.missing": "入力すると接続されます。",
188
+ "figure-library.setting.capability-pushed": "This app's capability module ({provider} {version}) is on the figure server.",
189
+ "figure-library.setting.capability-not-pushed": "This app's capability module ({provider} {version}) is not on the figure server yet. Saving or checking the link pushes it.",
190
+ "figure-library.setting.capability-push-failed": "This app's capability module ({provider} {version}) could not be pushed to the figure server. The app works on. Reason: {reason}"
188
191
  }
@@ -184,5 +184,8 @@
184
184
  "error.figure-import-conflict": "같은 버전이 다른 내용으로 이미 등록되어 있어 등록할 수 없습니다.",
185
185
  "figure-library.button.change-source": "연결 바꾸기",
186
186
  "figure-library.setting.example": "예: {value}",
187
- "figure-library.setting.missing": "입력해야 연결됩니다."
187
+ "figure-library.setting.missing": "입력해야 연결됩니다.",
188
+ "figure-library.setting.capability-pushed": "이 앱의 능력 모듈({provider} {version})을 피규어 서버에 올렸습니다.",
189
+ "figure-library.setting.capability-not-pushed": "이 앱의 능력 모듈({provider} {version})을 아직 피규어 서버에 올리지 않았습니다. 연결을 저장하거나 확인하면 올립니다.",
190
+ "figure-library.setting.capability-push-failed": "이 앱의 능력 모듈({provider} {version})을 피규어 서버에 올리지 못했습니다. 앱은 그대로 동작합니다. 사유: {reason}"
188
191
  }
@@ -184,5 +184,8 @@
184
184
  "error.figure-import-conflict": "Versi yang sama sudah ada dengan kandungan lain.",
185
185
  "figure-library.button.change-source": "Tukar sambungan",
186
186
  "figure-library.setting.example": "cth. {value}",
187
- "figure-library.setting.missing": "Diperlukan untuk menyambung."
187
+ "figure-library.setting.missing": "Diperlukan untuk menyambung.",
188
+ "figure-library.setting.capability-pushed": "This app's capability module ({provider} {version}) is on the figure server.",
189
+ "figure-library.setting.capability-not-pushed": "This app's capability module ({provider} {version}) is not on the figure server yet. Saving or checking the link pushes it.",
190
+ "figure-library.setting.capability-push-failed": "This app's capability module ({provider} {version}) could not be pushed to the figure server. The app works on. Reason: {reason}"
188
191
  }
@@ -184,5 +184,8 @@
184
184
  "error.figure-import-conflict": "相同版本已以不同内容注册,无法注册。",
185
185
  "figure-library.button.change-source": "更改连接",
186
186
  "figure-library.setting.example": "例如:{value}",
187
- "figure-library.setting.missing": "需要填写才能连接。"
187
+ "figure-library.setting.missing": "需要填写才能连接。",
188
+ "figure-library.setting.capability-pushed": "This app's capability module ({provider} {version}) is on the figure server.",
189
+ "figure-library.setting.capability-not-pushed": "This app's capability module ({provider} {version}) is not on the figure server yet. Saving or checking the link pushes it.",
190
+ "figure-library.setting.capability-push-failed": "This app's capability module ({provider} {version}) could not be pushed to the figure server. The app works on. Reason: {reason}"
188
191
  }