@factorialco/fcode-cli 3.6.0 → 3.6.1

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 CHANGED
@@ -20,7 +20,7 @@ $ npm install -g @factorialco/fcode-cli
20
20
  $ fcode COMMAND
21
21
  running command...
22
22
  $ fcode (--version)
23
- @factorialco/fcode-cli/3.6.0 linux-x64 node-v22.23.3
23
+ @factorialco/fcode-cli/3.6.1 linux-x64 node-v22.23.4
24
24
  $ fcode --help [COMMAND]
25
25
  USAGE
26
26
  $ fcode COMMAND
@@ -5,6 +5,7 @@ const processes_command_1 = require("../../core/commands/processes-command");
5
5
  const types_1 = require("../../core/types");
6
6
  const cli_1 = require("../../utils/cli");
7
7
  const settings_1 = require("../../config/settings");
8
+ const retired_app_role_1 = require("../../services/retired-app-role");
8
9
  class ProcessesPush extends processes_command_1.default {
9
10
  async pushVersioned() {
10
11
  const processes = (await this._resourceRepository.findAll()).filter((process) => process.id && !process.deletion);
@@ -25,6 +26,10 @@ class ProcessesPush extends processes_command_1.default {
25
26
  await Promise.allSettled(allPromises);
26
27
  }
27
28
  async run() {
29
+ const appRoleError = (0, retired_app_role_1.retiredAppRoleError)(await this.getLocalResources());
30
+ if (appRoleError) {
31
+ this.error(appRoleError);
32
+ }
28
33
  await super.pushResources();
29
34
  const ignoreProcessVersions = (await this.globalConfig.getSetting(settings_1.SettingKeys.IGNORE_PROCESS_VERSIONS)) === 'true';
30
35
  if (!ignoreProcessVersions) {
@@ -142,6 +142,10 @@ export type AppRole = 'INSTALL' | 'SETTINGS' | 'USER_FACING_FORM' | 'UNINSTALL'
142
142
  export type FormAuthMode = 'NONE' | 'FACTORIAL';
143
143
  export interface ProcessForm {
144
144
  enabled: boolean;
145
+ /**
146
+ * @deprecated Retired: push refuses it and pull no longer writes it. Kept so a metadata.json that
147
+ * still carries it can be read and reported.
148
+ */
145
149
  appRole?: AppRole;
146
150
  authMode?: FormAuthMode;
147
151
  }
@@ -1019,10 +1019,9 @@ class FcodeGraphQLClient {
1019
1019
  metadata.webhook = webhook;
1020
1020
  }
1021
1021
  if (settings?.formSettings) {
1022
+ // `appRole` is retired and push refuses it, so it is not written back: a role the cloud
1023
+ // already holds stays there, and `factorial.form.appTool` carries the user-facing one.
1022
1024
  metadata.form = { enabled: Boolean(settings.formSettings.enabled) };
1023
- if (settings.formSettings.appRole && settings.formSettings.appRole !== 'NONE') {
1024
- metadata.form.appRole = settings.formSettings.appRole;
1025
- }
1026
1025
  if (settings.formSettings.authMode && settings.formSettings.authMode !== 'NONE') {
1027
1026
  metadata.form.authMode = settings.formSettings.authMode;
1028
1027
  }
@@ -0,0 +1,15 @@
1
+ import { Process } from '../core/types';
2
+ /**
3
+ * Refuses to push a process that still declares `form.appRole`.
4
+ *
5
+ * The role is retired: a lifecycle form is named by its reserved slug, and the form offered from
6
+ * the app's page is `factorial.form.appTool`. Writing the role kept agents copying it into new
7
+ * Apps, where it beats the slug and, set by `appTool`, took the install role away. A process that
8
+ * already holds a role in the cloud keeps it when the line is deleted, since a push only sends the
9
+ * role when metadata.json names it — so legacy Apps need no rename to push again.
10
+ *
11
+ * Inherited and deleted processes are not pushed, so they are not checked.
12
+ *
13
+ * @returns the message to fail the push with, or undefined when no process declares a role.
14
+ */
15
+ export declare function retiredAppRoleError(processes: Array<Process>): string | undefined;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.retiredAppRoleError = retiredAppRoleError;
4
+ const types_1 = require("../core/types");
5
+ const LIFECYCLE_SLUGS = ['install', 'settings', 'uninstall'];
6
+ /**
7
+ * Refuses to push a process that still declares `form.appRole`.
8
+ *
9
+ * The role is retired: a lifecycle form is named by its reserved slug, and the form offered from
10
+ * the app's page is `factorial.form.appTool`. Writing the role kept agents copying it into new
11
+ * Apps, where it beats the slug and, set by `appTool`, took the install role away. A process that
12
+ * already holds a role in the cloud keeps it when the line is deleted, since a push only sends the
13
+ * role when metadata.json names it — so legacy Apps need no rename to push again.
14
+ *
15
+ * Inherited and deleted processes are not pushed, so they are not checked.
16
+ *
17
+ * @returns the message to fail the push with, or undefined when no process declares a role.
18
+ */
19
+ function retiredAppRoleError(processes) {
20
+ const offenders = processes.filter((process) => !(0, types_1.isReadOnly)(process) && process.form?.appRole && process.form.appRole !== 'NONE');
21
+ if (offenders.length === 0) {
22
+ return undefined;
23
+ }
24
+ const lines = offenders.map((process) => ` - processes/${process.slug}: ${fixFor(process)}`);
25
+ return [
26
+ '`form.appRole` is no longer supported. Remove it from metadata.json:',
27
+ ...lines,
28
+ `Install, settings and uninstall forms are the processes named ${LIFECYCLE_SLUGS.map((slug) => `'${slug}'`).join(', ')}.`,
29
+ ].join('\n');
30
+ }
31
+ function fixFor(process) {
32
+ const role = process.form.appRole;
33
+ if (role === 'USER_FACING_FORM') {
34
+ return 'set `factorial.form.appTool: true` instead.';
35
+ }
36
+ const slug = role.toLowerCase();
37
+ if (process.slug === slug) {
38
+ return `the '${slug}' slug already makes it the ${slug} form.`;
39
+ }
40
+ if (process.id) {
41
+ return `the cloud keeps the ${role} role it already has once the line is gone.`;
42
+ }
43
+ return `rename the process to '${slug}'.`;
44
+ }
@@ -2516,5 +2516,5 @@
2516
2516
  ]
2517
2517
  }
2518
2518
  },
2519
- "version": "3.6.0"
2519
+ "version": "3.6.1"
2520
2520
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@factorialco/fcode-cli",
3
- "version": "3.6.0",
3
+ "version": "3.6.1",
4
4
  "packageManager": "pnpm@11.7.0",
5
5
  "description": "Factorial Code Command Line Interface",
6
6
  "homepage": "https://code.factorialhr.com/docs/cli/",