@intra-mart/accel 0.3.0-next.202605250439 → 0.3.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.
Files changed (68) hide show
  1. package/README.md +157 -41
  2. package/dist/asset/deployer.js +8 -17
  3. package/dist/asset/foreach-replacement.d.ts +2 -0
  4. package/dist/asset/foreach-replacement.js +20 -0
  5. package/dist/asset/github-provider.d.ts +2 -0
  6. package/dist/asset/github-provider.js +37 -0
  7. package/dist/asset/local-provider.js +1 -22
  8. package/dist/asset/walker.js +4 -15
  9. package/dist/commands/attach.d.ts +13 -1
  10. package/dist/commands/attach.js +33 -12
  11. package/dist/commands/deploy.d.ts +42 -3
  12. package/dist/commands/deploy.js +274 -40
  13. package/dist/commands/init.d.ts +13 -1
  14. package/dist/commands/init.js +33 -12
  15. package/dist/commands/login.d.ts +31 -0
  16. package/dist/commands/login.js +76 -0
  17. package/dist/core/catalog.d.ts +11 -0
  18. package/dist/core/catalog.js +40 -0
  19. package/dist/core/condition-evaluator.js +6 -3
  20. package/dist/core/constants.d.ts +3 -3
  21. package/dist/core/constants.js +6 -11
  22. package/dist/core/eval-context.d.ts +3 -0
  23. package/dist/core/eval-context.js +45 -0
  24. package/dist/core/types.d.ts +61 -12
  25. package/dist/core/types.js +2 -1
  26. package/dist/core/validators.d.ts +7 -2
  27. package/dist/core/validators.js +25 -12
  28. package/dist/core/variable-interpolator.d.ts +1 -1
  29. package/dist/core/variable-interpolator.js +19 -19
  30. package/dist/deploy/api-client.d.ts +5 -2
  31. package/dist/deploy/api-client.js +47 -1
  32. package/dist/deploy/target-selector.d.ts +11 -0
  33. package/dist/deploy/target-selector.js +16 -0
  34. package/dist/i18n/en.js +38 -5
  35. package/dist/i18n/ja.js +38 -5
  36. package/dist/i18n/zh_CN.js +38 -5
  37. package/dist/index.js +2 -0
  38. package/dist/interactive/agent-detect.js +1 -0
  39. package/dist/interactive/credential-auth.d.ts +15 -0
  40. package/dist/interactive/credential-auth.js +61 -0
  41. package/dist/interactive/credentials-prompts.d.ts +3 -1
  42. package/dist/interactive/credentials-prompts.js +50 -7
  43. package/dist/interactive/next-steps.js +3 -0
  44. package/dist/interactive/prompts.d.ts +3 -0
  45. package/dist/interactive/prompts.js +112 -52
  46. package/dist/interactive/summary.js +5 -1
  47. package/dist/juggling/extractor.d.ts +3 -2
  48. package/dist/juggling/extractor.js +9 -9
  49. package/dist/utils/args.d.ts +1 -0
  50. package/dist/utils/args.js +4 -0
  51. package/dist/utils/credentials.d.ts +7 -0
  52. package/dist/utils/credentials.js +21 -0
  53. package/dist/utils/date-formatter.d.ts +1 -0
  54. package/dist/utils/date-formatter.js +23 -0
  55. package/dist/utils/https.d.ts +2 -0
  56. package/dist/utils/https.js +44 -0
  57. package/dist/utils/mcp-sync.d.ts +4 -0
  58. package/dist/utils/mcp-sync.js +97 -0
  59. package/dist/utils/settings-io.d.ts +1 -0
  60. package/dist/utils/settings-io.js +8 -0
  61. package/package.json +6 -5
  62. package/assets/assets.tar.gz +0 -0
  63. package/dist/asset/default-source.d.ts +0 -1
  64. package/dist/asset/default-source.js +0 -6
  65. package/dist/core/module-map.d.ts +0 -3
  66. package/dist/core/module-map.js +0 -7
  67. package/dist/core/version-map.d.ts +0 -7
  68. package/dist/core/version-map.js +0 -45
@@ -0,0 +1,11 @@
1
+ import type { Release, ModuleEntry, FunctionEntry, Labels } from "@intra-mart/catalog";
2
+ import type { AccelplatformVersion, ModuleContextItem, FeatureContextItem } from "./types.js";
3
+ export type { Release, ModuleEntry, FunctionEntry, Labels };
4
+ export declare const getReleases: () => readonly Release[];
5
+ export declare const findReleaseById: (id: string) => Release | undefined;
6
+ export declare const findReleaseBySemver: (semver: string) => Release | undefined;
7
+ export declare const resolveAccelplatformVersion: (id: string) => AccelplatformVersion;
8
+ export declare const resolveLabel: (labels: Labels, locale: string) => string;
9
+ export declare const findModuleByCatalogId: (release: Release, id: string) => ModuleEntry | undefined;
10
+ export declare const toModuleContextItems: (release: Release, artifactIds: string[], locale: string) => ModuleContextItem[];
11
+ export declare const toFeatureContextItems: (release: Release, functionIds: string[], locale: string) => FeatureContextItem[];
@@ -0,0 +1,40 @@
1
+ import { catalog } from "@intra-mart/catalog";
2
+ export const getReleases = () => catalog;
3
+ export const findReleaseById = (id) => catalog.find((r) => r.id === id);
4
+ export const findReleaseBySemver = (semver) => catalog.find((r) => r.version === semver);
5
+ export const resolveAccelplatformVersion = (id) => {
6
+ const release = findReleaseById(id);
7
+ if (!release) {
8
+ throw new Error(`Unknown iAP release id: ${id}`);
9
+ }
10
+ return { label: release.id, semver: release.version };
11
+ };
12
+ export const resolveLabel = (labels, locale) => labels[locale] ?? labels.en;
13
+ export const findModuleByCatalogId = (release, id) => release.modules.find((m) => m.id === id);
14
+ export const toModuleContextItems = (release, artifactIds, locale) => artifactIds.flatMap((artifactId) => {
15
+ const entry = release.modules.find((m) => m.artifactId === artifactId);
16
+ if (!entry)
17
+ return [];
18
+ return [
19
+ {
20
+ id: entry.id,
21
+ groupId: entry.groupId,
22
+ artifactId: entry.artifactId,
23
+ version: entry.version,
24
+ name: entry.name,
25
+ label: resolveLabel(entry.labels, locale),
26
+ },
27
+ ];
28
+ });
29
+ export const toFeatureContextItems = (release, functionIds, locale) => functionIds.flatMap((functionId) => {
30
+ const entry = release.functions.find((f) => f.id === functionId);
31
+ if (!entry)
32
+ return [];
33
+ return [
34
+ {
35
+ id: entry.id,
36
+ name: entry.name,
37
+ label: resolveLabel(entry.labels, locale),
38
+ },
39
+ ];
40
+ });
@@ -1,5 +1,5 @@
1
1
  import { satisfies } from "semver";
2
- import { isAndCondition, isOrCondition, isVersionCondition, isModuleCondition, isLocaleCondition, isAgentCondition, isPackageManagerCondition, isJavascriptCondition, } from "./types.js";
2
+ import { isAndCondition, isOrCondition, isAccelplatformVersionCondition, isModuleCondition, isFeatureCondition, isLocaleCondition, isAgentCondition, isPackageManagerCondition, isJavascriptCondition, } from "./types.js";
3
3
  export const evaluateCondition = (condition, context) => {
4
4
  if (condition === undefined) {
5
5
  return true;
@@ -10,12 +10,15 @@ export const evaluateCondition = (condition, context) => {
10
10
  if (isOrCondition(condition)) {
11
11
  return condition.or.some((c) => evaluateCondition(c, context));
12
12
  }
13
- if (isVersionCondition(condition)) {
14
- return satisfies(context.version, condition.version);
13
+ if (isAccelplatformVersionCondition(condition)) {
14
+ return satisfies(context.accelplatformVersion.semver, condition.accelplatformVersion);
15
15
  }
16
16
  if (isModuleCondition(condition)) {
17
17
  return context.modules.includes(condition.module);
18
18
  }
19
+ if (isFeatureCondition(condition)) {
20
+ return context.features.includes(condition.feature);
21
+ }
19
22
  if (isLocaleCondition(condition)) {
20
23
  return context.locale === condition.locale;
21
24
  }
@@ -2,12 +2,12 @@ import type { AccelSettings } from "./types.js";
2
2
  export declare const CLI_VERSION = "0.1.0";
3
3
  export declare const DATABASE_OPTIONS: readonly ["postgresql", "oracle", "sqlserver"];
4
4
  export type DatabaseOption = (typeof DATABASE_OPTIONS)[number];
5
- export declare const AGENT_OPTIONS: readonly ["claude-code", "github-copilot"];
5
+ export declare const AGENT_OPTIONS: readonly ["claude-code", "codex", "github-copilot"];
6
6
  export type AgentOption = (typeof AGENT_OPTIONS)[number];
7
- export declare const MODULE_OPTIONS: readonly ["workflow", "bpm", "copilot", "imbox", "pdfd", "kaiden"];
8
- export type ModuleOption = (typeof MODULE_OPTIONS)[number];
9
7
  export declare const LOCALE_OPTIONS: readonly ["ja", "en", "zh_CN"];
10
8
  export type LocaleOption = (typeof LOCALE_OPTIONS)[number];
11
9
  export declare const PACKAGE_MANAGER_OPTIONS: readonly ["bun", "npm", "yarn", "pnpm"];
12
10
  export type PackageManagerOption = (typeof PACKAGE_MANAGER_OPTIONS)[number];
11
+ export declare const DEFAULT_ASSET_REPO_URL = "https://github.com/accelplatform/skills";
12
+ export declare const DEFAULT_ASSET_REF = "2026-07-01-release";
13
13
  export declare const DEFAULT_SETTINGS: Omit<AccelSettings, "cliVersion" | "createdAt" | "deployedAssets">;
@@ -1,14 +1,6 @@
1
1
  export const CLI_VERSION = "0.1.0";
2
2
  export const DATABASE_OPTIONS = ["postgresql", "oracle", "sqlserver"];
3
- export const AGENT_OPTIONS = ["claude-code", "github-copilot"];
4
- export const MODULE_OPTIONS = [
5
- "workflow",
6
- "bpm",
7
- "copilot",
8
- "imbox",
9
- "pdfd",
10
- "kaiden",
11
- ];
3
+ export const AGENT_OPTIONS = ["claude-code", "codex", "github-copilot"];
12
4
  export const LOCALE_OPTIONS = ["ja", "en", "zh_CN"];
13
5
  export const PACKAGE_MANAGER_OPTIONS = [
14
6
  "bun",
@@ -16,16 +8,19 @@ export const PACKAGE_MANAGER_OPTIONS = [
16
8
  "yarn",
17
9
  "pnpm",
18
10
  ];
11
+ export const DEFAULT_ASSET_REPO_URL = "https://github.com/accelplatform/skills";
12
+ export const DEFAULT_ASSET_REF = "2026-07-01-release";
19
13
  export const DEFAULT_SETTINGS = {
20
14
  name: "my-accel-project",
21
15
  artifactId: "",
22
16
  group: "com.example",
23
17
  projectVersion: "0.1.0",
24
18
  description: "",
25
- accelplatformVersion: "2026-Spring",
19
+ accelplatformVersion: { label: "2026-spring", semver: "8.0.39" },
26
20
  modules: [],
21
+ features: [],
27
22
  database: "postgresql",
28
- agents: ["claude-code", "github-copilot"],
23
+ agents: ["claude-code", "codex", "github-copilot"],
29
24
  javascript: false,
30
25
  locale: "ja",
31
26
  packageManager: "bun",
@@ -0,0 +1,3 @@
1
+ import type { AccelSettings, EvalContext } from "./types.js";
2
+ export declare const buildEvalContext: (settings: AccelSettings) => EvalContext;
3
+ export declare const emptyEvalContext: (overrides?: Partial<EvalContext>) => EvalContext;
@@ -0,0 +1,45 @@
1
+ import { findReleaseById, findReleaseBySemver, toModuleContextItems, toFeatureContextItems, } from "./catalog.js";
2
+ export const buildEvalContext = (settings) => {
3
+ const features = settings.features ?? [];
4
+ const release = findReleaseById(settings.accelplatformVersion.label) ??
5
+ findReleaseBySemver(settings.accelplatformVersion.semver);
6
+ return {
7
+ accelplatformVersion: settings.accelplatformVersion,
8
+ modules: settings.modules,
9
+ features,
10
+ moduleItems: release
11
+ ? toModuleContextItems(release, settings.modules, settings.locale)
12
+ : [],
13
+ featureItems: release
14
+ ? toFeatureContextItems(release, features, settings.locale)
15
+ : [],
16
+ locale: settings.locale,
17
+ agents: settings.agents,
18
+ name: settings.name,
19
+ artifactId: settings.artifactId,
20
+ group: settings.group,
21
+ description: settings.description,
22
+ database: settings.database,
23
+ projectVersion: settings.projectVersion,
24
+ packageManager: settings.packageManager,
25
+ javascript: settings.javascript,
26
+ };
27
+ };
28
+ export const emptyEvalContext = (overrides = {}) => ({
29
+ accelplatformVersion: { label: "", semver: "0.0.0" },
30
+ modules: [],
31
+ features: [],
32
+ moduleItems: [],
33
+ featureItems: [],
34
+ locale: "",
35
+ agents: [],
36
+ name: "",
37
+ artifactId: "",
38
+ group: "",
39
+ description: "",
40
+ database: "",
41
+ projectVersion: "",
42
+ packageManager: "",
43
+ javascript: false,
44
+ ...overrides,
45
+ });
@@ -4,12 +4,15 @@ export type AndCondition = {
4
4
  export type OrCondition = {
5
5
  or: Condition[];
6
6
  };
7
- export type VersionCondition = {
8
- version: string;
7
+ export type AccelplatformVersionCondition = {
8
+ accelplatformVersion: string;
9
9
  };
10
10
  export type ModuleCondition = {
11
11
  module: string;
12
12
  };
13
+ export type FeatureCondition = {
14
+ feature: string;
15
+ };
13
16
  export type LocaleCondition = {
14
17
  locale: string;
15
18
  };
@@ -22,7 +25,7 @@ export type PackageManagerCondition = {
22
25
  export type JavascriptCondition = {
23
26
  javascript: boolean;
24
27
  };
25
- export type LeafCondition = VersionCondition | ModuleCondition | LocaleCondition | AgentCondition | PackageManagerCondition | JavascriptCondition;
28
+ export type LeafCondition = AccelplatformVersionCondition | ModuleCondition | FeatureCondition | LocaleCondition | AgentCondition | PackageManagerCondition | JavascriptCondition;
26
29
  export type Condition = AndCondition | OrCondition | LeafCondition;
27
30
  export type TextReplacement = {
28
31
  type: "text";
@@ -43,7 +46,15 @@ export type RegexReplacement = {
43
46
  replacement: string;
44
47
  condition: Condition;
45
48
  };
46
- export type Replacement = TextReplacement | SectionReplacement | RegexReplacement;
49
+ export type ForeachReplacement = {
50
+ type: "foreach";
51
+ target: string;
52
+ items: "modules" | "features";
53
+ template: string;
54
+ separator?: string;
55
+ condition?: Condition;
56
+ };
57
+ export type Replacement = TextReplacement | SectionReplacement | RegexReplacement | ForeachReplacement;
47
58
  export type RenameRule = {
48
59
  condition: Condition;
49
60
  from: string;
@@ -56,10 +67,22 @@ export type MetaJson = {
56
67
  rename?: RenameRule[];
57
68
  replacements?: Replacement[];
58
69
  };
59
- export type IapVersion = {
70
+ export type AccelplatformVersion = {
71
+ label: string;
60
72
  semver: string;
73
+ };
74
+ export type ModuleContextItem = {
75
+ id: string;
76
+ groupId: string;
77
+ artifactId: string;
78
+ version: string;
79
+ name: string;
80
+ label: string;
81
+ };
82
+ export type FeatureContextItem = {
83
+ id: string;
84
+ name: string;
61
85
  label: string;
62
- codename: string;
63
86
  };
64
87
  export type AccelSettings = {
65
88
  cliVersion: string;
@@ -69,8 +92,9 @@ export type AccelSettings = {
69
92
  group: string;
70
93
  projectVersion: string;
71
94
  description: string;
72
- accelplatformVersion: string;
95
+ accelplatformVersion: AccelplatformVersion;
73
96
  modules: string[];
97
+ features: string[];
74
98
  database: string;
75
99
  agents: string[];
76
100
  javascript: boolean;
@@ -89,15 +113,17 @@ export type AssetProvider = {
89
113
  cleanup: () => Promise<void>;
90
114
  };
91
115
  export type EvalContext = {
92
- version: string;
116
+ accelplatformVersion: AccelplatformVersion;
93
117
  modules: string[];
118
+ features: string[];
119
+ moduleItems: ModuleContextItem[];
120
+ featureItems: FeatureContextItem[];
94
121
  locale: string;
95
122
  agents: string[];
96
123
  name: string;
97
124
  artifactId: string;
98
125
  group: string;
99
126
  description: string;
100
- accelplatformVersion: string;
101
127
  database: string;
102
128
  projectVersion: string;
103
129
  packageManager: string;
@@ -105,8 +131,9 @@ export type EvalContext = {
105
131
  };
106
132
  export declare const isAndCondition: (c: Condition) => c is AndCondition;
107
133
  export declare const isOrCondition: (c: Condition) => c is OrCondition;
108
- export declare const isVersionCondition: (c: Condition) => c is VersionCondition;
134
+ export declare const isAccelplatformVersionCondition: (c: Condition) => c is AccelplatformVersionCondition;
109
135
  export declare const isModuleCondition: (c: Condition) => c is ModuleCondition;
136
+ export declare const isFeatureCondition: (c: Condition) => c is FeatureCondition;
110
137
  export declare const isLocaleCondition: (c: Condition) => c is LocaleCondition;
111
138
  export declare const isAgentCondition: (c: Condition) => c is AgentCondition;
112
139
  export declare const isPackageManagerCondition: (c: Condition) => c is PackageManagerCondition;
@@ -120,7 +147,7 @@ export type StagingResponse = {
120
147
  description?: string | null;
121
148
  currentDeployId?: string | null;
122
149
  createUserCd: string;
123
- createDate: string;
150
+ createDate: number;
124
151
  };
125
152
  export type StagingListResponse = {
126
153
  totalCount: number;
@@ -134,7 +161,29 @@ export type DeploymentResponse = {
134
161
  status: "STAGED" | "UNDEPLOYED";
135
162
  description?: string | null;
136
163
  createUserCd: string;
137
- createDate: string;
164
+ createDate: number;
165
+ };
166
+ export type SetupConfigResponse = {
167
+ moduleId: string;
168
+ configNumber: number;
169
+ sections: string[];
170
+ };
171
+ export type DeploymentCreateResponse = DeploymentResponse & {
172
+ shortcutUrl?: string | null;
173
+ setupConfigs?: SetupConfigResponse[] | null;
174
+ };
175
+ export type SetupExecuteResultResponse = {
176
+ configNumber: number;
177
+ section: string;
178
+ label: string;
179
+ target: string;
180
+ success: boolean;
181
+ message?: string | null;
182
+ };
183
+ export type SetupExecuteResponse = {
184
+ success: boolean;
185
+ totalCount: number;
186
+ results: SetupExecuteResultResponse[];
138
187
  };
139
188
  export type ApiSuccess<T> = {
140
189
  error: false;
@@ -1,7 +1,8 @@
1
1
  export const isAndCondition = (c) => "and" in c;
2
2
  export const isOrCondition = (c) => "or" in c;
3
- export const isVersionCondition = (c) => "version" in c && !("and" in c) && !("or" in c);
3
+ export const isAccelplatformVersionCondition = (c) => "accelplatformVersion" in c;
4
4
  export const isModuleCondition = (c) => "module" in c;
5
+ export const isFeatureCondition = (c) => "feature" in c;
5
6
  export const isLocaleCondition = (c) => "locale" in c;
6
7
  export const isAgentCondition = (c) => "agent" in c;
7
8
  export const isPackageManagerCondition = (c) => "packageManager" in c;
@@ -1,13 +1,18 @@
1
+ import { type Release } from "./catalog.js";
1
2
  export type Validator = (value: string | undefined) => string | undefined;
2
3
  export type Validators = {
3
4
  name: Validator;
4
5
  artifactId: Validator;
5
6
  group: Validator;
6
7
  projectVersion: Validator;
7
- versionLabel: Validator;
8
- module: Validator;
8
+ accelplatformVersion: Validator;
9
9
  database: Validator;
10
10
  agent: Validator;
11
11
  packageManager: Validator;
12
12
  };
13
+ export type ReleaseValidators = {
14
+ module: Validator;
15
+ feature: Validator;
16
+ };
13
17
  export declare const createValidators: (locale: string) => Validators;
18
+ export declare const createReleaseValidators: (locale: string, release: Release) => ReleaseValidators;
@@ -1,6 +1,6 @@
1
1
  import { getMessage } from "../i18n/index.js";
2
- import { AGENT_OPTIONS, DATABASE_OPTIONS, MODULE_OPTIONS, PACKAGE_MANAGER_OPTIONS, } from "./constants.js";
3
- import { SELECTABLE_VERSIONS } from "./version-map.js";
2
+ import { AGENT_OPTIONS, DATABASE_OPTIONS, PACKAGE_MANAGER_OPTIONS, } from "./constants.js";
3
+ import { findReleaseById } from "./catalog.js";
4
4
  const ARTIFACT_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
5
5
  const GROUP_PATTERN = /^[A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*)*$/;
6
6
  const PROJECT_VERSION_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
@@ -19,8 +19,7 @@ const isValidName = (value) => {
19
19
  const isValidArtifactId = (value) => ARTIFACT_ID_PATTERN.test(value);
20
20
  const isValidGroup = (value) => GROUP_PATTERN.test(value);
21
21
  const isValidProjectVersion = (value) => PROJECT_VERSION_PATTERN.test(value);
22
- const isValidVersionLabel = (value) => SELECTABLE_VERSIONS.some((v) => v.label === value);
23
- const isValidModule = (value) => MODULE_OPTIONS.includes(value);
22
+ const isValidReleaseId = (value) => findReleaseById(value) !== undefined;
24
23
  const isValidDatabase = (value) => DATABASE_OPTIONS.includes(value);
25
24
  const isValidAgent = (value) => AGENT_OPTIONS.includes(value);
26
25
  const isValidPackageManager = (value) => PACKAGE_MANAGER_OPTIONS.includes(value);
@@ -49,18 +48,12 @@ export const createValidators = (locale) => ({
49
48
  ? undefined
50
49
  : getMessage("error.invalidProjectVersion", locale, { value: v });
51
50
  },
52
- versionLabel: (value) => {
51
+ accelplatformVersion: (value) => {
53
52
  const v = value ?? "";
54
- return isValidVersionLabel(v)
53
+ return isValidReleaseId(v)
55
54
  ? undefined
56
55
  : getMessage("error.invalidVersion", locale, { version: v });
57
56
  },
58
- module: (value) => {
59
- const v = value ?? "";
60
- return isValidModule(v)
61
- ? undefined
62
- : getMessage("error.invalidModule", locale, { module: v });
63
- },
64
57
  database: (value) => {
65
58
  const v = value ?? "";
66
59
  return isValidDatabase(v)
@@ -82,3 +75,23 @@ export const createValidators = (locale) => ({
82
75
  });
83
76
  },
84
77
  });
78
+ export const createReleaseValidators = (locale, release) => ({
79
+ module: (value) => {
80
+ const v = value ?? "";
81
+ return release.modules.some((m) => m.artifactId === v)
82
+ ? undefined
83
+ : getMessage("error.invalidModule", locale, {
84
+ module: v,
85
+ release: release.id,
86
+ });
87
+ },
88
+ feature: (value) => {
89
+ const v = value ?? "";
90
+ return release.functions.some((f) => f.id === v)
91
+ ? undefined
92
+ : getMessage("error.invalidFeature", locale, {
93
+ feature: v,
94
+ release: release.id,
95
+ });
96
+ },
97
+ });
@@ -1,2 +1,2 @@
1
1
  import type { EvalContext } from "./types.js";
2
- export declare const interpolateVariables: (template: string, context: EvalContext) => string;
2
+ export declare const interpolateVariables: (template: string, context: EvalContext, extraVariables?: ReadonlyMap<string, string>) => string;
@@ -1,26 +1,26 @@
1
- const VARIABLE_MAP = new Map([
2
- ["name", "name"],
3
- ["artifactId", "artifactId"],
4
- ["group", "group"],
5
- ["description", "description"],
6
- ["version", "version"],
7
- ["accelplatformVersion", "accelplatformVersion"],
8
- ["locale", "locale"],
9
- ["database", "database"],
10
- ["projectVersion", "projectVersion"],
11
- ["packageManager", "packageManager"],
1
+ const VARIABLE_RESOLVERS = new Map([
2
+ ["name", (c) => c.name],
3
+ ["artifactId", (c) => c.artifactId],
4
+ ["group", (c) => c.group],
5
+ ["description", (c) => c.description],
6
+ ["accelplatformVersion.semver", (c) => c.accelplatformVersion.semver],
7
+ ["accelplatformVersion.label", (c) => c.accelplatformVersion.label],
8
+ ["locale", (c) => c.locale],
9
+ ["database", (c) => c.database],
10
+ ["projectVersion", (c) => c.projectVersion],
11
+ ["packageManager", (c) => c.packageManager],
12
12
  ]);
13
- const INTERPOLATION_PATTERN = /\{\{\$(\w+)\}\}/g;
14
- export const interpolateVariables = (template, context) => {
13
+ const INTERPOLATION_PATTERN = /\{\{\$([\w.]+)\}\}/g;
14
+ export const interpolateVariables = (template, context, extraVariables) => {
15
15
  return template.replace(INTERPOLATION_PATTERN, (match, varName) => {
16
- const field = VARIABLE_MAP.get(varName);
17
- if (field === undefined) {
18
- return match;
16
+ const extra = extraVariables?.get(varName);
17
+ if (extra !== undefined) {
18
+ return extra;
19
19
  }
20
- const value = context[field];
21
- if (typeof value !== "string") {
20
+ const resolver = VARIABLE_RESOLVERS.get(varName);
21
+ if (resolver === undefined) {
22
22
  return match;
23
23
  }
24
- return value;
24
+ return resolver(context);
25
25
  });
26
26
  };
@@ -1,4 +1,4 @@
1
- import type { StagingResponse, DeploymentResponse, DeployError } from "../core/types.js";
1
+ import type { StagingResponse, DeploymentCreateResponse, DeployError, SetupExecuteResponse } from "../core/types.js";
2
2
  type FetchFn = typeof globalThis.fetch;
3
3
  export declare const makeDeployError: (kind: DeployError["kind"], extra?: {
4
4
  status?: number;
@@ -6,8 +6,11 @@ export declare const makeDeployError: (kind: DeployError["kind"], extra?: {
6
6
  }) => DeployError;
7
7
  export declare const isDeployError: (e: unknown) => e is DeployError;
8
8
  export type ApiClient = {
9
+ verifyToken: () => Promise<void>;
9
10
  listStagings: () => Promise<StagingResponse[]>;
10
- createDeployment: (stagingId: string, bytes: Uint8Array, immFileName: string, description?: string) => Promise<DeploymentResponse>;
11
+ createDeployment: (stagingId: string, bytes: Uint8Array, immFileName: string, description?: string) => Promise<DeploymentCreateResponse>;
12
+ executeSetup: (stagingId: string) => Promise<SetupExecuteResponse>;
13
+ executeSetupConfig: (stagingId: string, configNumber: number) => Promise<SetupExecuteResponse>;
11
14
  };
12
15
  export declare const createApiClient: (endpoint: string, apiKey: string, deps?: {
13
16
  fetch?: FetchFn;
@@ -1,4 +1,5 @@
1
1
  const STAGING_PATH = "/api/bearer/development/staging";
2
+ const VERIFY_PATH = "/oauth/token/verify";
2
3
  const PAGE_LIMIT = 100;
3
4
  const MAX_PAGES = 1000;
4
5
  export const makeDeployError = (kind, extra = {}) => ({ _tag: "DeployError", kind, ...extra });
@@ -47,6 +48,29 @@ export const createApiClient = (endpoint, apiKey, deps = {}) => {
47
48
  }
48
49
  throw makeDeployError("http", { status: res.status });
49
50
  };
51
+ const verifyToken = async () => {
52
+ const url = `${endpoint}${VERIFY_PATH}`;
53
+ const body = new URLSearchParams({ access_token: apiKey }).toString();
54
+ let res;
55
+ try {
56
+ res = await doFetch(url, {
57
+ method: "POST",
58
+ headers: {
59
+ ...baseHeaders,
60
+ "Content-Type": "application/x-www-form-urlencoded",
61
+ },
62
+ body,
63
+ });
64
+ }
65
+ catch (err) {
66
+ throw makeDeployError("network", {
67
+ serverMessage: err instanceof Error ? err.message : String(err),
68
+ });
69
+ }
70
+ if (res.status === 200)
71
+ return;
72
+ throw makeDeployError("http", { status: res.status });
73
+ };
50
74
  const listStagings = async () => {
51
75
  const records = [];
52
76
  let offset = 0;
@@ -77,5 +101,27 @@ export const createApiClient = (endpoint, apiKey, deps = {}) => {
77
101
  body: form,
78
102
  });
79
103
  };
80
- return { listStagings, createDeployment };
104
+ const executeSetup = async (stagingId) => {
105
+ const url = `${endpoint}${STAGING_PATH}/${encodeURIComponent(stagingId)}/setup/execute`;
106
+ return request(url, {
107
+ method: "POST",
108
+ headers: { ...baseHeaders, "Content-Type": "application/json" },
109
+ body: JSON.stringify({}),
110
+ });
111
+ };
112
+ const executeSetupConfig = async (stagingId, configNumber) => {
113
+ const url = `${endpoint}${STAGING_PATH}/${encodeURIComponent(stagingId)}/setup/configs/${configNumber}/execute`;
114
+ return request(url, {
115
+ method: "POST",
116
+ headers: { ...baseHeaders, "Content-Type": "application/json" },
117
+ body: JSON.stringify({}),
118
+ });
119
+ };
120
+ return {
121
+ verifyToken,
122
+ listStagings,
123
+ createDeployment,
124
+ executeSetup,
125
+ executeSetupConfig,
126
+ };
81
127
  };
@@ -0,0 +1,11 @@
1
+ export type TargetSelection = {
2
+ auto: string;
3
+ } | {
4
+ candidates: string[];
5
+ };
6
+ type ArtifactInfo = {
7
+ artifactId: string;
8
+ projectVersion: string;
9
+ };
10
+ export declare const selectDeployTarget: (zips: string[], settings: ArtifactInfo | null) => TargetSelection;
11
+ export {};
@@ -0,0 +1,16 @@
1
+ import { basename } from "node:path";
2
+ const escapeRegExp = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3
+ export const selectDeployTarget = (zips, settings) => {
4
+ if (!settings) {
5
+ return { candidates: zips };
6
+ }
7
+ const { artifactId, projectVersion } = settings;
8
+ const exactName = `${artifactId}-${projectVersion}.zip`;
9
+ const exact = zips.find((z) => basename(z) === exactName);
10
+ if (exact) {
11
+ return { auto: exact };
12
+ }
13
+ const intermediate = new RegExp(`^${escapeRegExp(artifactId)}-\\D`);
14
+ const filtered = zips.filter((z) => !intermediate.test(basename(z)));
15
+ return { candidates: filtered.length > 0 ? filtered : zips };
16
+ };