@fairmint/canton-node-sdk 0.0.222 → 0.0.224

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/bin/canton-localnet +182 -0
  2. package/build/src/generated/apps/common/src/main/openapi/common-external.d.ts +295 -0
  3. package/build/src/generated/apps/common/src/main/openapi/common-external.d.ts.map +1 -0
  4. package/build/src/generated/apps/common/src/main/openapi/common-external.js +7 -0
  5. package/build/src/generated/apps/common/src/main/openapi/common-external.js.map +1 -0
  6. package/build/src/generated/apps/common/src/main/openapi/common-internal.d.ts +204 -0
  7. package/build/src/generated/apps/common/src/main/openapi/common-internal.d.ts.map +1 -0
  8. package/build/src/generated/apps/common/src/main/openapi/common-internal.js +7 -0
  9. package/build/src/generated/apps/common/src/main/openapi/common-internal.js.map +1 -0
  10. package/build/src/generated/apps/scan/src/main/openapi/scan-stream-server.d.ts +73 -0
  11. package/build/src/generated/apps/scan/src/main/openapi/scan-stream-server.d.ts.map +1 -0
  12. package/build/src/generated/apps/scan/src/main/openapi/scan-stream-server.js +7 -0
  13. package/build/src/generated/apps/scan/src/main/openapi/scan-stream-server.js.map +1 -0
  14. package/build/src/generated/apps/scan/src/main/openapi/scan.d.ts +4969 -0
  15. package/build/src/generated/apps/scan/src/main/openapi/scan.d.ts.map +1 -0
  16. package/build/src/generated/apps/scan/src/main/openapi/scan.js +7 -0
  17. package/build/src/generated/apps/scan/src/main/openapi/scan.js.map +1 -0
  18. package/build/src/generated/apps/splitwell/src/main/openapi/splitwell-internal.d.ts +636 -0
  19. package/build/src/generated/apps/splitwell/src/main/openapi/splitwell-internal.d.ts.map +1 -0
  20. package/build/src/generated/apps/splitwell/src/main/openapi/splitwell-internal.js +7 -0
  21. package/build/src/generated/apps/splitwell/src/main/openapi/splitwell-internal.js.map +1 -0
  22. package/build/src/generated/apps/sv/src/main/openapi/sv-internal.d.ts +2024 -0
  23. package/build/src/generated/apps/sv/src/main/openapi/sv-internal.d.ts.map +1 -0
  24. package/build/src/generated/apps/sv/src/main/openapi/sv-internal.js +7 -0
  25. package/build/src/generated/apps/sv/src/main/openapi/sv-internal.js.map +1 -0
  26. package/build/src/generated/apps/validator/src/main/openapi/ans-external.d.ts +189 -0
  27. package/build/src/generated/apps/validator/src/main/openapi/ans-external.d.ts.map +1 -0
  28. package/build/src/generated/apps/validator/src/main/openapi/ans-external.js +7 -0
  29. package/build/src/generated/apps/validator/src/main/openapi/ans-external.js.map +1 -0
  30. package/build/src/generated/apps/validator/src/main/openapi/scan-proxy.d.ts +969 -0
  31. package/build/src/generated/apps/validator/src/main/openapi/scan-proxy.d.ts.map +1 -0
  32. package/build/src/generated/apps/validator/src/main/openapi/scan-proxy.js +7 -0
  33. package/build/src/generated/apps/validator/src/main/openapi/scan-proxy.js.map +1 -0
  34. package/build/src/generated/apps/validator/src/main/openapi/validator-internal.d.ts +1230 -0
  35. package/build/src/generated/apps/validator/src/main/openapi/validator-internal.d.ts.map +1 -0
  36. package/build/src/generated/apps/validator/src/main/openapi/validator-internal.js +7 -0
  37. package/build/src/generated/apps/validator/src/main/openapi/validator-internal.js.map +1 -0
  38. package/build/src/generated/apps/wallet/src/main/openapi/wallet-external.d.ts +535 -0
  39. package/build/src/generated/apps/wallet/src/main/openapi/wallet-external.d.ts.map +1 -0
  40. package/build/src/generated/apps/wallet/src/main/openapi/wallet-external.js +7 -0
  41. package/build/src/generated/apps/wallet/src/main/openapi/wallet-external.js.map +1 -0
  42. package/build/src/generated/apps/wallet/src/main/openapi/wallet-internal.d.ts +2521 -0
  43. package/build/src/generated/apps/wallet/src/main/openapi/wallet-internal.d.ts.map +1 -0
  44. package/build/src/generated/apps/wallet/src/main/openapi/wallet-internal.js +7 -0
  45. package/build/src/generated/apps/wallet/src/main/openapi/wallet-internal.js.map +1 -0
  46. package/package.json +18 -8
  47. package/scripts/localnet-cloud.sh +180 -17
  48. package/.gitmodules +0 -6
  49. package/.nvmrc +0 -1
  50. package/scripts/collapse-manifest.ts +0 -66
  51. package/scripts/generate-all-client-methods.ts +0 -332
  52. package/scripts/generate-openapi-types.ts +0 -46
  53. package/scripts/generate-operation-tests.ts +0 -198
  54. package/scripts/grant-user-rights.ts +0 -213
  55. package/scripts/list-identity-providers.ts +0 -46
  56. package/scripts/localnet/localnet-cloud.sh +0 -5
  57. package/scripts/localnet/localnet-status.sh +0 -5
  58. package/scripts/localnet/setup-localnet.sh +0 -5
  59. package/scripts/localnet/setup-quickstart-localnet.sh +0 -5
  60. package/scripts/localnet/start-localnet.sh +0 -5
  61. package/scripts/localnet/stop-localnet.sh +0 -5
  62. package/scripts/localnet-status.sh +0 -5
  63. package/scripts/prepare-release.ts +0 -222
  64. package/scripts/revoke-user-rights.ts +0 -219
  65. package/scripts/setup-localnet.sh +0 -5
  66. package/scripts/setup-quickstart-localnet.sh +0 -5
  67. package/scripts/start-localnet.sh +0 -5
  68. package/scripts/stop-localnet.sh +0 -5
@@ -1,213 +0,0 @@
1
- #!/usr/bin/env tsx
2
- import 'dotenv/config';
3
- import { CantonRuntime, EnvLoader, LedgerJsonApiClient, ValidatorApiClient } from '../src';
4
- import type { GrantUserRightsParams } from '../src/clients/ledger-json-api/schemas/operations/users';
5
- import type { NetworkType } from '../src/core/types';
6
-
7
- /** Rights type expected by grant/revoke APIs (with value wrapper) */
8
- type GrantableRight = NonNullable<GrantUserRightsParams['rights']>[number];
9
-
10
- /** Create default admin rights for a user */
11
- function createAdminRights(): GrantableRight[] {
12
- return [
13
- {
14
- kind: {
15
- ParticipantAdmin: { value: {} },
16
- },
17
- },
18
- ];
19
- }
20
-
21
- /** Create CanExecuteAsAnyParty rights for a user */
22
- function createExecuteAsAnyPartyRights(): GrantableRight[] {
23
- return [
24
- {
25
- kind: {
26
- CanExecuteAsAnyParty: { value: {} },
27
- },
28
- },
29
- ];
30
- }
31
-
32
- /** Create CanReadAsAnyParty rights for a user */
33
- function createReadAsAnyPartyRights(): GrantableRight[] {
34
- return [
35
- {
36
- kind: {
37
- CanReadAsAnyParty: { value: {} },
38
- },
39
- },
40
- ];
41
- }
42
-
43
- /** Create party-specific rights for a user */
44
- function createPartyRights(partyId: string): GrantableRight[] {
45
- return [
46
- {
47
- kind: {
48
- CanActAs: { value: { party: partyId } },
49
- },
50
- },
51
- ];
52
- }
53
-
54
- async function main(): Promise<void> {
55
- console.log('=== Grant User Rights Utility ===\n');
56
-
57
- // Parse command line arguments
58
- const args = process.argv.slice(2);
59
-
60
- if (args.includes('--help') || args.includes('-h')) {
61
- console.log(`
62
- Usage: tsx scripts/grant-user-rights.ts [options]
63
-
64
- Options:
65
- --user-id <id> User ID to grant rights to (defaults to authenticated user)
66
- --party-id <id> Party ID for party-specific rights (optional)
67
- --admin Grant ParticipantAdmin rights (default if no other right specified)
68
- --execute-any-party Grant CanExecuteAsAnyParty rights
69
- --read-any-party Grant CanReadAsAnyParty rights
70
- --network <network> Target network (devnet|testnet|mainnet, defaults to CANTON_CURRENT_NETWORK)
71
- --provider <provider> Target provider (defaults to CANTON_CURRENT_PROVIDER)
72
- --help, -h Show this help message
73
-
74
- Examples:
75
- # Grant admin rights to authenticated user (uses current network/provider from env)
76
- npm run grant-user-rights -- --admin
77
-
78
- # Grant CanExecuteAsAnyParty rights to authenticated user
79
- npm run grant-user-rights -- --execute-any-party
80
-
81
- # Grant CanReadAsAnyParty rights to authenticated user
82
- npm run grant-user-rights -- --read-any-party
83
-
84
- # Grant admin rights to specific user on devnet/intellect
85
- npm run grant-user-rights -- --user-id "5" --admin --network devnet --provider intellect
86
-
87
- # Grant party rights to authenticated user
88
- npm run grant-user-rights -- --party-id "alice::party1"
89
- `);
90
- process.exit(0);
91
- }
92
-
93
- // Parse arguments
94
- const userIdIndex = args.indexOf('--user-id');
95
- const targetUserId = userIdIndex !== -1 ? args[userIdIndex + 1] : undefined;
96
-
97
- const partyIdIndex = args.indexOf('--party-id');
98
- const partyId = partyIdIndex !== -1 ? args[partyIdIndex + 1] : undefined;
99
-
100
- const executeAnyParty = args.includes('--execute-any-party');
101
- const readAnyParty = args.includes('--read-any-party');
102
-
103
- const networkIndex = args.indexOf('--network');
104
- const network = networkIndex !== -1 ? (args[networkIndex + 1] as NetworkType) : undefined;
105
-
106
- const providerIndex = args.indexOf('--provider');
107
- const provider = providerIndex !== -1 ? args[providerIndex + 1] : undefined;
108
-
109
- // Determine which rights to grant
110
- let rights: GrantableRight[];
111
- let rightsType: string;
112
-
113
- if (partyId) {
114
- rights = createPartyRights(partyId);
115
- rightsType = 'Party Rights (CanActAs)';
116
- } else if (executeAnyParty) {
117
- rights = createExecuteAsAnyPartyRights();
118
- rightsType = 'CanExecuteAsAnyParty';
119
- } else if (readAnyParty) {
120
- rights = createReadAsAnyPartyRights();
121
- rightsType = 'CanReadAsAnyParty';
122
- } else {
123
- rights = createAdminRights();
124
- rightsType = 'ParticipantAdmin';
125
- }
126
-
127
- console.log('Configuration:');
128
- console.log(` Network: ${network ?? 'from CANTON_CURRENT_NETWORK'}`);
129
- console.log(` Provider: ${provider ?? 'from CANTON_CURRENT_PROVIDER'}`);
130
- if (targetUserId) {
131
- console.log(` Target User ID: ${targetUserId}`);
132
- } else {
133
- console.log(` Target User ID: <will auto-detect from authenticated user>`);
134
- }
135
- if (partyId) {
136
- console.log(` Party ID: ${partyId}`);
137
- }
138
- console.log(` Rights Type: ${rightsType}\n`);
139
-
140
- try {
141
- const configOptions = {
142
- ...(network !== undefined && { network }),
143
- ...(provider !== undefined && { provider }),
144
- };
145
- const runtime = new CantonRuntime(EnvLoader.getConfig('LEDGER_JSON_API', configOptions));
146
- const client = new LedgerJsonApiClient(runtime);
147
- const validatorClient = new ValidatorApiClient(runtime);
148
-
149
- console.log(`Connected to Ledger JSON API`);
150
-
151
- // If no target user ID provided, get the authenticated user
152
- let resolvedUserId: string;
153
- if (!targetUserId) {
154
- console.log('Fetching authenticated user ID...');
155
- const authenticatedUser = await validatorClient.getValidatorUserInfo();
156
- resolvedUserId = authenticatedUser.user_name;
157
- console.log(`Using authenticated user: ${resolvedUserId}`);
158
- } else {
159
- resolvedUserId = targetUserId;
160
- console.log(`Target user: ${resolvedUserId}`);
161
- }
162
-
163
- console.log(`\nRights to grant: ${JSON.stringify(rights, null, 2)}`);
164
-
165
- // Check current rights
166
- console.log('\nChecking current rights...');
167
- try {
168
- const currentRights = await client.listUserRights({
169
- userId: resolvedUserId,
170
- });
171
- console.log(`Current rights count: ${currentRights.rights?.length ?? 0}`);
172
- } catch (error) {
173
- console.log(`Could not list current rights: ${error instanceof Error ? error.message : String(error)}`);
174
- }
175
-
176
- // Grant the rights
177
- console.log('\nGranting rights...');
178
- const result = await client.grantUserRights({
179
- userId: resolvedUserId,
180
- rights,
181
- });
182
-
183
- console.log(`\n✓ Successfully granted ${result.newlyGrantedRights?.length ?? 0} new rights`);
184
- if (result.newlyGrantedRights && result.newlyGrantedRights.length > 0) {
185
- console.log(`\nNewly granted rights:`);
186
- console.log(JSON.stringify(result.newlyGrantedRights, null, 2));
187
- } else {
188
- console.log('\n(Rights may have already existed)');
189
- }
190
-
191
- // Verify by listing rights again
192
- console.log('\nVerifying...');
193
- const finalRights = await client.listUserRights({
194
- userId: resolvedUserId,
195
- });
196
- console.log(`Final rights count: ${finalRights.rights?.length ?? 0}`);
197
-
198
- console.log('\n✓ Done!');
199
- } catch (error) {
200
- console.error('\n✗ Failed to grant rights:');
201
- console.error(` ${error instanceof Error ? error.message : String(error)}`);
202
- if (error instanceof Error && error.stack) {
203
- console.error(`\nStack trace:`);
204
- console.error(error.stack);
205
- }
206
- process.exit(1);
207
- }
208
- }
209
-
210
- main().catch((error) => {
211
- console.error('Fatal error:', error);
212
- process.exit(1);
213
- });
@@ -1,46 +0,0 @@
1
- #!/usr/bin/env tsx
2
- import 'dotenv/config';
3
- import { CantonRuntime, EnvLoader, LedgerJsonApiClient } from '../src';
4
-
5
- /** List all configured identity providers in the Canton system */
6
- async function main(): Promise<void> {
7
- console.log('=== List Identity Providers ===\n');
8
-
9
- try {
10
- const client = new LedgerJsonApiClient(new CantonRuntime(EnvLoader.getConfig('LEDGER_JSON_API')));
11
-
12
- console.log('Fetching identity provider configs...\n');
13
- const result = await client.listIdentityProviderConfigs({});
14
-
15
- if (result.identityProviderConfigs.length === 0) {
16
- console.log('No identity providers configured.');
17
- return;
18
- }
19
-
20
- console.log(`Found ${result.identityProviderConfigs.length} identity provider(s):\n`);
21
-
22
- result.identityProviderConfigs.forEach((config, index) => {
23
- console.log(`${index + 1}. Identity Provider ID: "${config.identityProviderId}"`);
24
- console.log(` Issuer: ${config.issuer}`);
25
- console.log(` JWKS URL: ${config.jwksUrl}`);
26
- console.log(` Audience: ${config.audience ?? 'N/A'}`);
27
- console.log(` Is Deactivated: ${config.isDeactivated}`);
28
- console.log('');
29
- });
30
-
31
- console.log('✓ Done!');
32
- } catch (error) {
33
- console.error('\n✗ Failed to list identity providers:');
34
- console.error(` ${error instanceof Error ? error.message : String(error)}`);
35
- if (error instanceof Error && error.stack) {
36
- console.error(`\nStack trace:`);
37
- console.error(error.stack);
38
- }
39
- process.exit(1);
40
- }
41
- }
42
-
43
- main().catch((error) => {
44
- console.error('Fatal error:', error);
45
- process.exit(1);
46
- });
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
-
4
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
- bash "${SCRIPT_DIR}/../localnet-cloud.sh" "$@"
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
-
4
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
- bash "${SCRIPT_DIR}/../localnet-status.sh"
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
-
4
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
- bash "${SCRIPT_DIR}/../setup-localnet.sh"
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
-
4
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
- bash "${SCRIPT_DIR}/../setup-quickstart-localnet.sh"
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
-
4
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
- bash "${SCRIPT_DIR}/../start-localnet.sh"
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
-
4
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
- bash "${SCRIPT_DIR}/../stop-localnet.sh"
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
-
4
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
- bash "${SCRIPT_DIR}/localnet-cloud.sh" status
@@ -1,222 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Prepare Release Script
5
- *
6
- * Prepares a new release by incrementing version and generating changelog.
7
- *
8
- * Usage: npm run prepare-release
9
- *
10
- * Features:
11
- *
12
- * - Increments patch version in package.json
13
- * - Checks both npm registry and git tags to determine next version
14
- * - Creates changelog from commits since last tag
15
- * - Links commits to GitHub PRs
16
- * - Safe for local testing (no git operations)
17
- * - Saves changelog to CHANGELOG.md
18
- */
19
-
20
- import { execSync } from 'child_process';
21
- import fs from 'fs';
22
- import path from 'path';
23
-
24
- interface PackageJson {
25
- name: string;
26
- version: string;
27
- [key: string]: unknown;
28
- }
29
-
30
- /** Check if a git tag exists */
31
- function tagExists(tag: string): boolean {
32
- try {
33
- execSync(`git rev-parse "refs/tags/${tag}"`, { stdio: 'ignore' });
34
- return true;
35
- } catch {
36
- return false;
37
- }
38
- }
39
-
40
- /** Get the latest version from npm registry */
41
- function getNpmLatestVersion(packageName: string): string | null {
42
- try {
43
- const version = execSync(`npm view ${packageName} version 2>/dev/null`, {
44
- encoding: 'utf8',
45
- }).trim();
46
- return version || null;
47
- } catch {
48
- return null;
49
- }
50
- }
51
-
52
- /** Check if a version exists on npm registry */
53
- function npmVersionExists(packageName: string, version: string): boolean {
54
- try {
55
- const versions = execSync(`npm view ${packageName} versions --json 2>/dev/null`, {
56
- encoding: 'utf8',
57
- });
58
- const versionList = JSON.parse(versions) as string[];
59
- return versionList.includes(version);
60
- } catch {
61
- return false;
62
- }
63
- }
64
-
65
- /** Parse version string into components */
66
- function parseVersion(version: string): { major: number; minor: number; patch: number } | null {
67
- const parts = version.split('.').map(Number);
68
- if (parts.length !== 3 || parts.some(isNaN)) {
69
- return null;
70
- }
71
- const major = parts[0];
72
- const minor = parts[1];
73
- const patch = parts[2];
74
- if (major === undefined || minor === undefined || patch === undefined) {
75
- return null;
76
- }
77
- return { major, minor, patch };
78
- }
79
-
80
- /** Find the next available version by checking both git tags and npm registry */
81
- function findNextAvailableVersion(packageName: string, major: number, minor: number, startPatch: number): string {
82
- let patch = startPatch;
83
- let version: string;
84
-
85
- do {
86
- patch++;
87
- version = `${major}.${minor}.${patch}`;
88
- } while (tagExists(`v${version}`) || npmVersionExists(packageName, version));
89
-
90
- return version;
91
- }
92
-
93
- /** Get the highest version from git tags and npm, then find next available */
94
- function determineNextVersion(packageName: string, currentVersion: string): string {
95
- const current = parseVersion(currentVersion);
96
- if (!current) {
97
- throw new Error(`Invalid version format: ${currentVersion}`);
98
- }
99
-
100
- // Get latest version from npm registry
101
- const npmVersion = getNpmLatestVersion(packageName);
102
- const npm = npmVersion ? parseVersion(npmVersion) : null;
103
-
104
- // Get latest version from git tags
105
- let gitVersion: string | null = null;
106
- try {
107
- gitVersion = execSync('git describe --tags --abbrev=0 2>/dev/null', {
108
- encoding: 'utf8',
109
- }).trim();
110
- if (gitVersion.startsWith('v')) {
111
- gitVersion = gitVersion.slice(1);
112
- }
113
- } catch {
114
- gitVersion = null;
115
- }
116
- const git = gitVersion ? parseVersion(gitVersion) : null;
117
-
118
- // Determine the highest patch version among current, npm, and git
119
- let highestPatch = current.patch;
120
-
121
- if (npm?.major === current.major && npm.minor === current.minor) {
122
- highestPatch = Math.max(highestPatch, npm.patch);
123
- }
124
-
125
- if (git?.major === current.major && git.minor === current.minor) {
126
- highestPatch = Math.max(highestPatch, git.patch);
127
- }
128
-
129
- console.log(`Current version: ${currentVersion}`);
130
- console.log(`NPM latest version: ${npmVersion ?? 'not found'}`);
131
- console.log(`Git latest tag: ${gitVersion ? `v${gitVersion}` : 'not found'}`);
132
- console.log(`Highest patch in ${current.major}.${current.minor}.x: ${highestPatch}`);
133
-
134
- // Find next available version starting from the highest
135
- return findNextAvailableVersion(packageName, current.major, current.minor, highestPatch);
136
- }
137
-
138
- /**
139
- * Prepare release by incrementing version and generating changelog This script can be run locally to test the release
140
- * process
141
- */
142
- function prepareRelease(): void {
143
- try {
144
- // Read package.json
145
- const packageJsonPath: string = path.join(process.cwd(), 'package.json');
146
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')) as PackageJson;
147
-
148
- const currentVersion: string = packageJson.version;
149
- const packageName: string = packageJson.name;
150
-
151
- // Find next available version by checking both npm and git tags
152
- const newVersion: string = determineNextVersion(packageName, currentVersion);
153
-
154
- // Update version in package.json (without git tag)
155
- packageJson.version = newVersion;
156
- fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`);
157
-
158
- // Generate changelog since last tag or main branch
159
- let commits: string;
160
- let lastTag: string | null = null;
161
- try {
162
- lastTag = execSync('git describe --tags --abbrev=0 2>/dev/null', {
163
- encoding: 'utf8',
164
- }).trim();
165
-
166
- commits = execSync(`git log --oneline --format="%s" ${lastTag}..HEAD`, {
167
- encoding: 'utf8',
168
- }).trim();
169
- } catch {
170
- // No previous tag, get commits ahead of main branch
171
-
172
- commits = execSync('git log --oneline --format="%s" main..HEAD', {
173
- encoding: 'utf8',
174
- }).trim();
175
- }
176
-
177
- if (!commits) {
178
- return;
179
- }
180
-
181
- // Extract PR numbers and create changelog
182
- const commitLines: string[] = commits.split('\n').map((commit: string): string => `- ${commit}`);
183
-
184
- const changelog: string = commitLines.join('\n');
185
-
186
- // Create detailed tag message
187
- const _tagMessage = `Release v${newVersion}\n\nChanges:\n${changelog}`;
188
-
189
- console.log('Release tag prepared:', _tagMessage);
190
-
191
- // Save changelog to file for reference
192
- const changelogPath: string = path.join(process.cwd(), 'CHANGELOG.md');
193
-
194
- // Add previous version link if available
195
- const previousVersionLink: string = lastTag
196
- ? `\n[Previous version: ${lastTag}](https://github.com/Fairmint/canton-node-sdk/releases/tag/${lastTag})`
197
- : '';
198
-
199
- const changelogContent = `# Changelog for v${newVersion}\n\n${changelog}${previousVersionLink}\n\n`;
200
-
201
- // Prepend to existing changelog if it exists
202
- if (fs.existsSync(changelogPath)) {
203
- const existingChangelog: string = fs.readFileSync(changelogPath, 'utf8');
204
- fs.writeFileSync(changelogPath, changelogContent + existingChangelog);
205
- } else {
206
- fs.writeFileSync(changelogPath, changelogContent);
207
- }
208
-
209
- console.log('Changelog updated successfully');
210
- console.log('Release preparation complete');
211
- } catch (_error) {
212
- console.error('Error preparing release:', _error);
213
- process.exit(1);
214
- }
215
- }
216
-
217
- // Run the script
218
- if (require.main === module) {
219
- prepareRelease();
220
- }
221
-
222
- export { prepareRelease };