@factorialco/fcode-cli 2.3.0 → 3.0.0
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 +334 -117
- package/dist/commands/clone.d.ts +0 -12
- package/dist/commands/clone.js +22 -135
- package/dist/commands/{settings → config}/get.d.ts +1 -1
- package/dist/commands/{settings → config}/get.js +7 -7
- package/dist/commands/{settings → config}/remove.d.ts +1 -1
- package/dist/commands/{settings → config}/remove.js +6 -6
- package/dist/commands/{settings → config}/set.d.ts +1 -1
- package/dist/commands/{settings → config}/set.js +8 -8
- package/dist/commands/dependencies/diff.d.ts +9 -0
- package/dist/commands/dependencies/diff.js +15 -0
- package/dist/commands/dependencies/pull.d.ts +9 -0
- package/dist/commands/dependencies/pull.js +44 -1
- package/dist/commands/dependencies/status.d.ts +11 -0
- package/dist/commands/dependencies/status.js +43 -0
- package/dist/commands/diff.d.ts +12 -0
- package/dist/commands/diff.js +48 -0
- package/dist/commands/http.d.ts +1 -1
- package/dist/commands/http.js +7 -7
- package/dist/commands/i18n/diff.d.ts +9 -0
- package/dist/commands/i18n/diff.js +15 -0
- package/dist/commands/i18n/status.d.ts +3 -0
- package/dist/commands/i18n/status.js +1 -0
- package/dist/commands/modules/diff.d.ts +9 -0
- package/dist/commands/modules/diff.js +15 -0
- package/dist/commands/modules/status.d.ts +3 -0
- package/dist/commands/modules/status.js +1 -0
- package/dist/commands/processes/diff.d.ts +9 -0
- package/dist/commands/processes/diff.js +15 -0
- package/dist/commands/processes/status.d.ts +3 -0
- package/dist/commands/processes/status.js +1 -0
- package/dist/commands/pull.js +3 -3
- package/dist/commands/push.js +2 -2
- package/dist/commands/{team → settings}/aliases/delete.d.ts +1 -1
- package/dist/commands/{team → settings}/aliases/delete.js +6 -6
- package/dist/commands/{team → settings}/aliases/list.d.ts +1 -1
- package/dist/commands/{team → settings}/aliases/list.js +8 -8
- package/dist/commands/{team → settings}/aliases/set.d.ts +1 -1
- package/dist/commands/{team → settings}/aliases/set.js +8 -8
- package/dist/commands/settings/diff.d.ts +8 -0
- package/dist/commands/settings/diff.js +39 -0
- package/dist/commands/{team/push.d.ts → settings/pull.d.ts} +3 -3
- package/dist/commands/settings/pull.js +41 -0
- package/dist/commands/settings/push.d.ts +13 -0
- package/dist/commands/settings/push.js +103 -0
- package/dist/commands/settings/status.d.ts +8 -0
- package/dist/commands/settings/status.js +46 -0
- package/dist/commands/{team → settings}/versions/create.d.ts +1 -2
- package/dist/commands/settings/versions/create.js +36 -0
- package/dist/commands/{team → settings}/versions/delete.d.ts +1 -1
- package/dist/commands/{team → settings}/versions/delete.js +10 -10
- package/dist/commands/{team → settings}/versions/list.d.ts +1 -1
- package/dist/commands/{team → settings}/versions/list.js +8 -8
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.js +10 -7
- package/dist/commands/team/clone.d.ts +14 -0
- package/dist/commands/team/clone.js +91 -0
- package/dist/commands/team/pull.d.ts +3 -4
- package/dist/commands/team/pull.js +25 -19
- package/dist/commands/team/status.d.ts +3 -4
- package/dist/commands/team/status.js +34 -27
- package/dist/commands/variables/diff.d.ts +9 -0
- package/dist/commands/variables/diff.js +15 -0
- package/dist/commands/variables/status.d.ts +3 -0
- package/dist/commands/variables/status.js +1 -0
- package/dist/config/dev-team.d.ts +48 -0
- package/dist/config/dev-team.js +62 -0
- package/dist/config/workspace.d.ts +2 -2
- package/dist/config/workspace.js +4 -2
- package/dist/core/commands/base-command.js +5 -0
- package/dist/core/commands/dependency-command.d.ts +2 -1
- package/dist/core/commands/dependency-command.js +3 -0
- package/dist/core/commands/i18n-command.js +2 -0
- package/dist/core/commands/modules-command.js +2 -0
- package/dist/core/commands/processes-command.js +2 -0
- package/dist/core/commands/resource-command.d.ts +26 -1
- package/dist/core/commands/resource-command.js +100 -3
- package/dist/core/commands/variables-command.d.ts +7 -0
- package/dist/core/commands/variables-command.js +13 -0
- package/dist/core/dependencies/env-dependencies-command.js +6 -3
- package/dist/core/executors/javascript-execution-task.js +36 -5
- package/dist/core/types.d.ts +59 -9
- package/dist/core/types.js +64 -10
- package/dist/core/utils/dependencies.js +4 -1
- package/dist/env.js +1 -1
- package/dist/repositories/process.d.ts +8 -2
- package/dist/repositories/process.js +29 -15
- package/dist/repositories/programming-language-manifest.d.ts +31 -1
- package/dist/repositories/programming-language-manifest.js +96 -2
- package/dist/repositories/settings.d.ts +52 -0
- package/dist/repositories/settings.js +214 -0
- package/dist/runtime/libs/python/fcode/context.py +42 -8
- package/dist/services/dashboard-client.d.ts +31 -0
- package/dist/services/dashboard-client.js +99 -0
- package/dist/services/dev-team-service.d.ts +41 -0
- package/dist/services/dev-team-service.js +162 -0
- package/dist/services/fcode-graphql-client.d.ts +17 -2
- package/dist/services/fcode-graphql-client.js +127 -15
- package/dist/services/locale-resolver.d.ts +17 -1
- package/dist/services/locale-resolver.js +62 -7
- package/dist/services/resource-differ.d.ts +60 -0
- package/dist/services/resource-differ.js +135 -0
- package/dist/services/skills-installer.d.ts +16 -0
- package/dist/services/skills-installer.js +77 -0
- package/dist/services/team-versioning.d.ts +16 -0
- package/dist/services/team-versioning.js +40 -0
- package/dist/services/webhook-auth.js +1 -1
- package/dist/services/workspace-cloner.d.ts +31 -0
- package/dist/services/workspace-cloner.js +95 -0
- package/dist/utils/dev-slug.d.ts +12 -0
- package/dist/utils/dev-slug.js +37 -0
- package/dist/utils/diff.d.ts +19 -0
- package/dist/utils/diff.js +58 -0
- package/dist/utils/gitignore.d.ts +3 -1
- package/dist/utils/gitignore.js +11 -2
- package/dist/utils/slugify.d.ts +17 -0
- package/dist/utils/slugify.js +41 -0
- package/oclif.manifest.json +433 -113
- package/package.json +12 -7
- package/dist/commands/team/push.js +0 -52
- package/dist/commands/team/versions/create.js +0 -42
- package/dist/repositories/team.d.ts +0 -31
- package/dist/repositories/team.js +0 -127
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@factorialco/fcode-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"packageManager": "pnpm@11.7.0",
|
|
5
5
|
"description": "Factorial Code Command Line Interface",
|
|
6
6
|
"homepage": "https://code.factorialhr.com/docs/cli/",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"@oclif/core": "^4.0.37",
|
|
34
34
|
"@oclif/plugin-help": "^6.2.36",
|
|
35
35
|
"chalk": "^4.1.2",
|
|
36
|
+
"diff": "^5.2.0",
|
|
36
37
|
"dotenv": "^16.4.7",
|
|
37
38
|
"fs-extra": "^11.2.0",
|
|
38
39
|
"lodash": "^4.17.21",
|
|
@@ -53,6 +54,7 @@
|
|
|
53
54
|
"@oclif/test": "^4.1.15",
|
|
54
55
|
"@types/chai": "^4.3.20",
|
|
55
56
|
"@types/cli-table": "^0.3.4",
|
|
57
|
+
"@types/diff": "^5.2.3",
|
|
56
58
|
"@types/fs-extra": "^11.0.4",
|
|
57
59
|
"@types/lodash": "^4.17.21",
|
|
58
60
|
"@types/mocha": "^10.0.10",
|
|
@@ -103,8 +105,8 @@
|
|
|
103
105
|
"variables": {
|
|
104
106
|
"description": "Manage variables resources"
|
|
105
107
|
},
|
|
106
|
-
"
|
|
107
|
-
"description": "Manage CLI
|
|
108
|
+
"config": {
|
|
109
|
+
"description": "Manage CLI configuration"
|
|
108
110
|
},
|
|
109
111
|
"dependencies": {
|
|
110
112
|
"description": "Manage dependencies resources"
|
|
@@ -112,16 +114,19 @@
|
|
|
112
114
|
"remote": {
|
|
113
115
|
"description": "Manage remote team workspaces"
|
|
114
116
|
},
|
|
115
|
-
"
|
|
116
|
-
"description": "Manage
|
|
117
|
+
"settings": {
|
|
118
|
+
"description": "Manage workspace settings (timezone, error handler, inheritance) and workspace versions",
|
|
117
119
|
"subtopics": {
|
|
118
120
|
"versions": {
|
|
119
|
-
"description": "Manage
|
|
121
|
+
"description": "Manage workspace versions across every owned process and module"
|
|
120
122
|
},
|
|
121
123
|
"aliases": {
|
|
122
|
-
"description": "Manage
|
|
124
|
+
"description": "Manage workspace version aliases (e.g. production)"
|
|
123
125
|
}
|
|
124
126
|
}
|
|
127
|
+
},
|
|
128
|
+
"team": {
|
|
129
|
+
"description": "Work with every App your development team owns, in one folder"
|
|
125
130
|
}
|
|
126
131
|
}
|
|
127
132
|
},
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const color_1 = require("@oclif/color");
|
|
4
|
-
const api_client_command_1 = require("../../core/commands/api-client-command");
|
|
5
|
-
const team_1 = require("../../repositories/team");
|
|
6
|
-
const types_1 = require("../../core/types");
|
|
7
|
-
const cli_1 = require("../../utils/cli");
|
|
8
|
-
class TeamPushCommand extends api_client_command_1.default {
|
|
9
|
-
constructor() {
|
|
10
|
-
super(...arguments);
|
|
11
|
-
this._teamRepository = new team_1.default();
|
|
12
|
-
}
|
|
13
|
-
async run() {
|
|
14
|
-
const { flags: { force }, } = await this.parse(TeamPushCommand);
|
|
15
|
-
if (!this._teamRepository.exists()) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
cli_1.default.log(color_1.default.cyan('\n☁️ pushing team settings...'));
|
|
19
|
-
const team = await this._teamRepository.find();
|
|
20
|
-
const storedHash = await this.workspaceConfig.getTeamStoredHash();
|
|
21
|
-
if (!force && storedHash === team.contentHash) {
|
|
22
|
-
cli_1.default.log('Team settings already up to date');
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
// team.json's `versions`/`aliases` fields are pull-only and intentionally left out of the
|
|
26
|
-
// update payload: team versions and aliases are only written through the explicit
|
|
27
|
-
// team:versions/team:aliases commands.
|
|
28
|
-
const update = { parentTeamSlugs: team.parentTeamSlugs };
|
|
29
|
-
if (team.zoneId !== undefined) {
|
|
30
|
-
update.zoneId = team.zoneId;
|
|
31
|
-
}
|
|
32
|
-
if (team.errorHandlerConfig) {
|
|
33
|
-
const processId = await this._teamRepository.resolveSlugToId(team.errorHandlerConfig.processSlug);
|
|
34
|
-
update.executionErrorHandlerConfig = { processId, tag: team.errorHandlerConfig.tag ?? null };
|
|
35
|
-
}
|
|
36
|
-
// Sent unconditionally, null arm included: team.json is the source of truth, so removing
|
|
37
|
-
// webhookAuth from it must clear the cloud configuration rather than leave it dangling.
|
|
38
|
-
update.webhookAuth = team.webhookAuth
|
|
39
|
-
? { headerName: team.webhookAuth.headerName ?? null, variableKey: team.webhookAuth.variableKey }
|
|
40
|
-
: { variableKey: null };
|
|
41
|
-
// Sent unconditionally for the same reason as webhookAuth: team.json is the source of truth,
|
|
42
|
-
// so removing primaryLocale from it must clear the cloud setting. Empty string is the clear.
|
|
43
|
-
update.primaryLocale = team.primaryLocale ?? '';
|
|
44
|
-
await this._fcodeGraphQLClient.pushTeam(update);
|
|
45
|
-
await this.workspaceConfig.setTeamStoredHash(team.contentHash);
|
|
46
|
-
cli_1.default.log(color_1.default.green('✅ team settings pushed'));
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
TeamPushCommand.description = 'Update cloud team settings (timezone, error handler, inheritance, webhook auth) from team.json';
|
|
50
|
-
TeamPushCommand.examples = ['$ fcode team:push'];
|
|
51
|
-
TeamPushCommand.flags = types_1.ForceFlag;
|
|
52
|
-
exports.default = TeamPushCommand;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const core_1 = require("@oclif/core");
|
|
4
|
-
const color_1 = require("@oclif/color");
|
|
5
|
-
const api_client_command_1 = require("../../../core/commands/api-client-command");
|
|
6
|
-
const pull_1 = require("../../pull");
|
|
7
|
-
const cli_1 = require("../../../utils/cli");
|
|
8
|
-
class TeamVersionsCreateCommand extends api_client_command_1.default {
|
|
9
|
-
async run() {
|
|
10
|
-
const { args: { tag }, flags: { comment }, } = await this.parse(TeamVersionsCreateCommand);
|
|
11
|
-
cli_1.default.log(color_1.default.cyan(`\n🏷️ publishing team version ${tag}...`));
|
|
12
|
-
const teamVersion = await this._fcodeGraphQLClient.createTeamVersion(tag, comment);
|
|
13
|
-
const failedCount = this.logManifest(teamVersion);
|
|
14
|
-
// Refresh the local workspace: per-entity versions/<tag>/ folders and team.json.
|
|
15
|
-
await pull_1.default.run([]);
|
|
16
|
-
// Release pipelines must be able to detect an incomplete version. Re-running the
|
|
17
|
-
// command converges: it publishes only what is still missing.
|
|
18
|
-
if (failedCount > 0) {
|
|
19
|
-
this.error(`team version ${tag} published with ${failedCount} failed entities`, { exit: 1 });
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
logManifest(teamVersion) {
|
|
23
|
-
const created = teamVersion.manifest.filter(({ outcome }) => outcome === 'CREATED');
|
|
24
|
-
const skipped = teamVersion.manifest.filter(({ outcome }) => outcome === 'SKIPPED_EXISTS');
|
|
25
|
-
const failed = teamVersion.manifest.filter(({ outcome }) => outcome === 'FAILED');
|
|
26
|
-
cli_1.default.log(color_1.default.green(`✅ ${created.length} created`) + `, ${skipped.length} skipped (tag already exists)` + (failed.length > 0 ? `, ${color_1.default.red(`${failed.length} failed`)}` : ''));
|
|
27
|
-
for (const entry of failed) {
|
|
28
|
-
cli_1.default.error(`${entry.resourceType.toLowerCase()} ${entry.slug} — ${entry.error ?? 'unknown error'}`);
|
|
29
|
-
}
|
|
30
|
-
return failed.length;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
TeamVersionsCreateCommand.description = 'Publish a team version: creates a version with the tag on every owned process and module ' +
|
|
34
|
-
'(existing tags are skipped) and pins bare module imports in the published snapshots';
|
|
35
|
-
TeamVersionsCreateCommand.examples = ['$ fcode team:versions:create v1.0.0', '$ fcode team:versions:create v1.0.0 --comment "First stable release"'];
|
|
36
|
-
TeamVersionsCreateCommand.args = {
|
|
37
|
-
tag: core_1.Args.string({ description: 'version tag to publish (e.g. v1.0.0)', required: true }),
|
|
38
|
-
};
|
|
39
|
-
TeamVersionsCreateCommand.flags = {
|
|
40
|
-
comment: core_1.Flags.string({ char: 'c', description: 'comment describing the version' }),
|
|
41
|
-
};
|
|
42
|
-
exports.default = TeamVersionsCreateCommand;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { RawTeamSettings, Team, TeamVersion, TeamVersionAlias } from '../core/types';
|
|
2
|
-
import WorkspaceConfig from '../config/workspace';
|
|
3
|
-
/**
|
|
4
|
-
* Reads/writes the singleton team.json (timezone, error handler, inheritance, webhook auth) at the
|
|
5
|
-
* workspace root. Unlike collection resources this is not a ResourceRepositoryBase:
|
|
6
|
-
* there is exactly one team, so there is no slug-keyed collection to manage.
|
|
7
|
-
*
|
|
8
|
-
* team.json references the error-handler process by slug for portability; the cloud
|
|
9
|
-
* references it by id, so this repository resolves slug<->id against the tracked
|
|
10
|
-
* process metadata in .fcode/.
|
|
11
|
-
*/
|
|
12
|
-
export default class TeamRepository {
|
|
13
|
-
protected workspaceConfig: WorkspaceConfig;
|
|
14
|
-
exists(): boolean;
|
|
15
|
-
find(): Promise<Team>;
|
|
16
|
-
save(team: Team): void;
|
|
17
|
-
/** Builds a Team from the cloud's raw settings, resolving the error-handler id to a slug. */
|
|
18
|
-
fromRaw(raw: RawTeamSettings): Promise<Team>;
|
|
19
|
-
/**
|
|
20
|
-
* Writes the cloud's team versions and aliases into the Team as the pull-only team.json
|
|
21
|
-
* fields (sorted for stable git diffs). These fields never enter the content hash and are
|
|
22
|
-
* stripped from pushes: all writes go through the team:versions/team:aliases commands.
|
|
23
|
-
*/
|
|
24
|
-
applyCloudVersioning(team: Team, versions: TeamVersion[], aliases: TeamVersionAlias[]): void;
|
|
25
|
-
resolveSlugToId(processSlug: string): Promise<string>;
|
|
26
|
-
resolveIdToSlug(processId: string): Promise<string>;
|
|
27
|
-
private parseErrorHandler;
|
|
28
|
-
/** A configuration without a variable key is meaningless, so it is read as absent. */
|
|
29
|
-
private parseWebhookAuth;
|
|
30
|
-
private toFile;
|
|
31
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const fs = require("fs-extra");
|
|
4
|
-
const types_1 = require("../core/types");
|
|
5
|
-
const workspace_1 = require("../config/workspace");
|
|
6
|
-
const file_utils_1 = require("../utils/file-utils");
|
|
7
|
-
const TEAM_FILENAME = 'team.json';
|
|
8
|
-
/**
|
|
9
|
-
* Reads/writes the singleton team.json (timezone, error handler, inheritance, webhook auth) at the
|
|
10
|
-
* workspace root. Unlike collection resources this is not a ResourceRepositoryBase:
|
|
11
|
-
* there is exactly one team, so there is no slug-keyed collection to manage.
|
|
12
|
-
*
|
|
13
|
-
* team.json references the error-handler process by slug for portability; the cloud
|
|
14
|
-
* references it by id, so this repository resolves slug<->id against the tracked
|
|
15
|
-
* process metadata in .fcode/.
|
|
16
|
-
*/
|
|
17
|
-
class TeamRepository {
|
|
18
|
-
constructor() {
|
|
19
|
-
this.workspaceConfig = new workspace_1.default();
|
|
20
|
-
}
|
|
21
|
-
exists() {
|
|
22
|
-
return fs.pathExistsSync(TEAM_FILENAME);
|
|
23
|
-
}
|
|
24
|
-
async find() {
|
|
25
|
-
const slug = await this.workspaceConfig.getActiveTeamSlug();
|
|
26
|
-
let raw = {};
|
|
27
|
-
try {
|
|
28
|
-
raw = fs.readJsonSync(TEAM_FILENAME) || {};
|
|
29
|
-
}
|
|
30
|
-
catch { }
|
|
31
|
-
const parentTeamSlugs = Array.isArray(raw.parentTeamSlugs) ? raw.parentTeamSlugs : [];
|
|
32
|
-
const team = new types_1.Team(slug, parentTeamSlugs, raw.zoneId, this.parseErrorHandler(raw.errorHandlerConfig), this.parseWebhookAuth(raw.webhookAuth), typeof raw.primaryLocale === 'string' && raw.primaryLocale.length > 0 ? raw.primaryLocale : undefined);
|
|
33
|
-
// Parsed so a find()+save() round-trip does not drop the pull-only fields.
|
|
34
|
-
if (Array.isArray(raw.versions)) {
|
|
35
|
-
team.versions = raw.versions;
|
|
36
|
-
}
|
|
37
|
-
if (Array.isArray(raw.aliases)) {
|
|
38
|
-
team.aliases = raw.aliases;
|
|
39
|
-
}
|
|
40
|
-
return team;
|
|
41
|
-
}
|
|
42
|
-
save(team) {
|
|
43
|
-
(0, file_utils_1.outputFileSyncIfChanged)(TEAM_FILENAME, JSON.stringify(this.toFile(team), null, 2));
|
|
44
|
-
}
|
|
45
|
-
/** Builds a Team from the cloud's raw settings, resolving the error-handler id to a slug. */
|
|
46
|
-
async fromRaw(raw) {
|
|
47
|
-
let errorHandlerConfig;
|
|
48
|
-
if (raw.errorHandlerConfig?.processId) {
|
|
49
|
-
errorHandlerConfig = {
|
|
50
|
-
processSlug: await this.resolveIdToSlug(raw.errorHandlerConfig.processId),
|
|
51
|
-
tag: raw.errorHandlerConfig.tag ?? null,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
return new types_1.Team(raw.slug, raw.parentTeamSlugs ?? [], raw.zoneId, errorHandlerConfig, this.parseWebhookAuth(raw.webhookAuth), raw.primaryLocale ?? undefined);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Writes the cloud's team versions and aliases into the Team as the pull-only team.json
|
|
58
|
-
* fields (sorted for stable git diffs). These fields never enter the content hash and are
|
|
59
|
-
* stripped from pushes: all writes go through the team:versions/team:aliases commands.
|
|
60
|
-
*/
|
|
61
|
-
applyCloudVersioning(team, versions, aliases) {
|
|
62
|
-
team.versions = versions
|
|
63
|
-
.map((version) => {
|
|
64
|
-
const entry = { tag: version.tag, createdAt: version.createdAt };
|
|
65
|
-
if (version.comment) {
|
|
66
|
-
entry.comment = version.comment;
|
|
67
|
-
}
|
|
68
|
-
return entry;
|
|
69
|
-
})
|
|
70
|
-
.sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
71
|
-
team.aliases = aliases
|
|
72
|
-
.map((alias) => ({ name: alias.name, tag: alias.tag }))
|
|
73
|
-
.sort((a, b) => a.name.localeCompare(b.name));
|
|
74
|
-
}
|
|
75
|
-
async resolveSlugToId(processSlug) {
|
|
76
|
-
const { processes } = await this.workspaceConfig.getActiveTeam();
|
|
77
|
-
return processes[processSlug]?.id ?? processSlug;
|
|
78
|
-
}
|
|
79
|
-
async resolveIdToSlug(processId) {
|
|
80
|
-
const { processes } = await this.workspaceConfig.getActiveTeam();
|
|
81
|
-
const match = Object.values(processes).find((process) => process.id === processId);
|
|
82
|
-
return match?.slug ?? processId;
|
|
83
|
-
}
|
|
84
|
-
parseErrorHandler(raw) {
|
|
85
|
-
if (!raw || !raw.processSlug) {
|
|
86
|
-
return undefined;
|
|
87
|
-
}
|
|
88
|
-
return { processSlug: raw.processSlug, tag: raw.tag ?? null };
|
|
89
|
-
}
|
|
90
|
-
/** A configuration without a variable key is meaningless, so it is read as absent. */
|
|
91
|
-
parseWebhookAuth(raw) {
|
|
92
|
-
if (!raw || typeof raw.variableKey !== 'string' || raw.variableKey.length === 0) {
|
|
93
|
-
return undefined;
|
|
94
|
-
}
|
|
95
|
-
const webhookAuth = { variableKey: raw.variableKey };
|
|
96
|
-
// The default header is left out so a pull writes the minimal form.
|
|
97
|
-
if (typeof raw.headerName === 'string' && raw.headerName.length > 0 && raw.headerName !== types_1.DEFAULT_WEBHOOK_AUTH_HEADER) {
|
|
98
|
-
webhookAuth.headerName = raw.headerName;
|
|
99
|
-
}
|
|
100
|
-
return webhookAuth;
|
|
101
|
-
}
|
|
102
|
-
toFile(team) {
|
|
103
|
-
const file = { parentTeamSlugs: team.parentTeamSlugs ?? [] };
|
|
104
|
-
if (team.zoneId !== undefined) {
|
|
105
|
-
file.zoneId = team.zoneId;
|
|
106
|
-
}
|
|
107
|
-
if (team.errorHandlerConfig !== undefined) {
|
|
108
|
-
file.errorHandlerConfig = team.errorHandlerConfig;
|
|
109
|
-
}
|
|
110
|
-
// Last, so adding webhook auth to an existing team.json is a purely additive diff.
|
|
111
|
-
if (team.webhookAuth !== undefined) {
|
|
112
|
-
file.webhookAuth = team.webhookAuth;
|
|
113
|
-
}
|
|
114
|
-
if (team.primaryLocale !== undefined) {
|
|
115
|
-
file.primaryLocale = team.primaryLocale;
|
|
116
|
-
}
|
|
117
|
-
// Pull-only global versioning fields, appended after the pushable settings.
|
|
118
|
-
if (team.versions !== undefined) {
|
|
119
|
-
file.versions = team.versions;
|
|
120
|
-
}
|
|
121
|
-
if (team.aliases !== undefined) {
|
|
122
|
-
file.aliases = team.aliases;
|
|
123
|
-
}
|
|
124
|
-
return file;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
exports.default = TeamRepository;
|