@things-factory/figure-library 10.1.292 → 10.1.296

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.
@@ -170,9 +170,9 @@ let FigureSourceSettingLet = class FigureSourceSettingLet extends localize(i18ne
170
170
  this.checking = true;
171
171
  this.checked = undefined;
172
172
  try {
173
- const response = await client.query({
174
- query: gql `
175
- query {
173
+ const response = await client.mutate({
174
+ mutation: gql `
175
+ mutation {
176
176
  checkFigureLibrarySource {
177
177
  ok
178
178
  code
@@ -180,8 +180,7 @@ let FigureSourceSettingLet = class FigureSourceSettingLet extends localize(i18ne
180
180
  total
181
181
  }
182
182
  }
183
- `,
184
- fetchPolicy: 'no-cache'
183
+ `
185
184
  });
186
185
  const answer = response.data.checkFigureLibrarySource;
187
186
  /* The check pushes the capability module too: read where it stands again. */
@@ -22,5 +22,5 @@ export * from './source/figure-source-resolver';
22
22
  export * from './source/capability-push';
23
23
  export declare const entities: (typeof FigureLibraryRelease | typeof FigureTypeMapEntry)[];
24
24
  export declare const schema: {
25
- resolverClasses: (typeof FigureLibraryResolver | typeof FigureSourceResolver)[];
25
+ resolverClasses: (typeof FigureSourceResolver | typeof FigureLibraryResolver)[];
26
26
  };
@@ -8,10 +8,9 @@ exports.pushCapabilityModulesOfLinkedDomains = pushCapabilityModulesOfLinkedDoma
8
8
  const crypto_1 = require("crypto");
9
9
  const fs_1 = require("fs");
10
10
  const shell_1 = require("@things-factory/shell");
11
+ const env_1 = require("@things-factory/env");
11
12
  const source_client_1 = require("./source-client");
12
13
  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
14
  /** The domain attributes the push keeps: the hashes it last pushed (module, choices), and why the last one failed. */
16
15
  exports.PUSHED_HASH = 'FigureLibrary::source::capability-module-hash';
17
16
  exports.PUSHED_CHOICES_HASH = 'FigureLibrary::source::capability-choices-hash';
@@ -22,7 +21,7 @@ let declared;
22
21
  * left out are read from the module itself.
23
22
  */
24
23
  function declareFigureCapabilityModule(declaration) {
25
- const { provider, version } = declaration.provider && declaration.version ? declaration : nodeRequire(declaration.file);
24
+ const { provider, version } = declaration.provider && declaration.version ? declaration : (0, env_1.requireModuleFile)(declaration.file);
26
25
  declared = { file: declaration.file, provider, version, ...(declaration.choices ? { choices: declaration.choices } : {}) };
27
26
  }
28
27
  /** The app's declared module, or none. */
@@ -62,7 +61,7 @@ async function pushCapabilityModule(manager, domain, source, options = {}) {
62
61
  try {
63
62
  const bytes = (options.read ?? fs_1.readFileSync)(declared.file);
64
63
  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. */
64
+ /* The lists as the app holds them now. One that cannot be read stops the push: what failed is kept for the card. */
66
65
  const choices = declared.choices ? await declared.choices(domain) : undefined;
67
66
  const choicesHash = choices ? (0, crypto_1.createHash)('sha256').update(JSON.stringify(choices)).digest('hex') : null;
68
67
  const last = (await attribute(manager, domain, exports.PUSHED_HASH))?.value;
@@ -227,13 +227,16 @@ let FigureSourceResolver = class FigureSourceResolver {
227
227
  const capabilityModule = await (0, capability_push_1.pushCapabilityModule)(tx, domain, (0, source_setting_rules_1.sourceOf)(attributes), { t: context.t });
228
228
  return { ...(0, source_setting_rules_1.sourceSettingState)(attributes, shell_1.secretHint), capabilityModule };
229
229
  }
230
+ /*
231
+ A mutation: besides asking, it pushes the app's capability module again when it is not the one last pushed and keeps
232
+ where that stands -- writes, so it runs in a transaction and asks the setting's mutation privilege.
233
+ */
230
234
  async checkFigureLibrarySource(context) {
231
235
  const { domain, tx } = context.state;
232
236
  try {
233
- const manager = tx ?? (0, shell_1.getDataSource)().manager;
234
- const source = await figureSourceOf(domain, manager);
237
+ const source = await figureSourceOf(domain, tx);
235
238
  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 });
239
+ await (0, capability_push_1.pushCapabilityModule)(tx, domain, source, { t: context.t });
237
240
  return { ok: true, total };
238
241
  }
239
242
  catch (error) {
@@ -279,8 +282,9 @@ tslib_1.__decorate([
279
282
  tslib_1.__metadata("design:returntype", Promise)
280
283
  ], FigureSourceResolver.prototype, "updateFigureLibrarySource", null);
281
284
  tslib_1.__decorate([
282
- (0, type_graphql_1.Directive)('@privilege(category: "env-var", privilege: "query", domainOwnerGranted: true)'),
283
- (0, type_graphql_1.Query)(returns => FigureSourceCheck, { description: 'Asks the figure server for one catalog row with the setting as it is.' }),
285
+ (0, type_graphql_1.Directive)('@transaction'),
286
+ (0, type_graphql_1.Directive)('@privilege(category: "env-var", privilege: "mutation", domainOwnerGranted: true)'),
287
+ (0, type_graphql_1.Mutation)(returns => FigureSourceCheck, { description: "Asks the figure server for one catalog row with the setting as it is, and pushes the app's capability module when it changed." }),
284
288
  tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
285
289
  tslib_1.__metadata("design:type", Function),
286
290
  tslib_1.__metadata("design:paramtypes", [Object]),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/figure-library",
3
- "version": "10.1.292",
3
+ "version": "10.1.296",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "files": [
@@ -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.291",
59
- "@things-factory/auth-base": "^10.1.291",
60
- "@things-factory/board-service": "^10.1.292",
61
- "@things-factory/env": "^10.1.281",
58
+ "@things-factory/attachment-base": "^10.1.296",
59
+ "@things-factory/auth-base": "^10.1.296",
60
+ "@things-factory/board-service": "^10.1.296",
61
+ "@things-factory/env": "^10.1.296",
62
62
  "@things-factory/figure-viewer": "^10.1.291",
63
- "@things-factory/setting-base": "^10.1.291",
64
- "@things-factory/shell": "^10.1.291",
63
+ "@things-factory/setting-base": "^10.1.296",
64
+ "@things-factory/shell": "^10.1.296",
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": "579131696a2ef7eccb2a79ec774a805adface625"
72
+ "gitHead": "0cd4b6207e4dfc557157f86630d82aed423b1dde"
73
73
  }