@zincapp/znvault-plugin-payara 1.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/dist/routes.js ADDED
@@ -0,0 +1,247 @@
1
+ // Path: src/routes.ts
2
+ // HTTP routes for Payara plugin
3
+ /**
4
+ * Register Payara plugin HTTP routes
5
+ *
6
+ * Routes are registered under /plugins/payara/ prefix by the agent
7
+ */
8
+ export async function registerRoutes(fastify, payara, deployer, logger) {
9
+ /**
10
+ * GET /hashes
11
+ * Returns SHA-256 hashes of all files in the current WAR
12
+ * Used by CLI to calculate diff for incremental deployment
13
+ */
14
+ fastify.get('/hashes', async (request, reply) => {
15
+ try {
16
+ const hashes = await deployer.getCurrentHashes();
17
+ return { hashes };
18
+ }
19
+ catch (err) {
20
+ logger.error({ err }, 'Failed to get WAR hashes');
21
+ return reply.code(500).send({
22
+ error: 'Failed to get WAR hashes',
23
+ message: err instanceof Error ? err.message : String(err),
24
+ });
25
+ }
26
+ });
27
+ /**
28
+ * POST /deploy
29
+ * Applies file changes and deploys WAR
30
+ * Receives base64-encoded file contents for changed files
31
+ */
32
+ fastify.post('/deploy', async (request, reply) => {
33
+ const { files, deletions } = request.body;
34
+ // Validate request
35
+ if (!Array.isArray(files)) {
36
+ return reply.code(400).send({
37
+ error: 'Invalid request',
38
+ message: 'files must be an array',
39
+ });
40
+ }
41
+ if (!Array.isArray(deletions)) {
42
+ return reply.code(400).send({
43
+ error: 'Invalid request',
44
+ message: 'deletions must be an array',
45
+ });
46
+ }
47
+ // Check if deployment is already in progress
48
+ if (deployer.isDeploying()) {
49
+ return reply.code(409).send({
50
+ error: 'Deployment in progress',
51
+ message: 'Another deployment is already in progress. Please wait.',
52
+ });
53
+ }
54
+ try {
55
+ // Decode base64 file contents
56
+ const changedFiles = files.map(f => ({
57
+ path: f.path,
58
+ content: Buffer.from(f.content, 'base64'),
59
+ }));
60
+ logger.info({
61
+ filesChanged: changedFiles.length,
62
+ filesDeleted: deletions.length,
63
+ }, 'Starting deployment');
64
+ await deployer.applyChanges(changedFiles, deletions);
65
+ return {
66
+ status: 'deployed',
67
+ filesChanged: changedFiles.length,
68
+ filesDeleted: deletions.length,
69
+ message: 'Deployment successful',
70
+ };
71
+ }
72
+ catch (err) {
73
+ logger.error({ err }, 'Deployment failed');
74
+ return reply.code(500).send({
75
+ error: 'Deployment failed',
76
+ message: err instanceof Error ? err.message : String(err),
77
+ });
78
+ }
79
+ });
80
+ /**
81
+ * POST /deploy/full
82
+ * Triggers a full WAR deployment (no diff)
83
+ */
84
+ fastify.post('/deploy/full', async (request, reply) => {
85
+ if (deployer.isDeploying()) {
86
+ return reply.code(409).send({
87
+ error: 'Deployment in progress',
88
+ message: 'Another deployment is already in progress',
89
+ });
90
+ }
91
+ try {
92
+ await deployer.deploy();
93
+ return {
94
+ status: 'deployed',
95
+ message: 'Full deployment successful',
96
+ };
97
+ }
98
+ catch (err) {
99
+ logger.error({ err }, 'Full deployment failed');
100
+ return reply.code(500).send({
101
+ error: 'Deployment failed',
102
+ message: err instanceof Error ? err.message : String(err),
103
+ });
104
+ }
105
+ });
106
+ /**
107
+ * POST /restart
108
+ * Restart Payara domain
109
+ */
110
+ fastify.post('/restart', async (request, reply) => {
111
+ try {
112
+ logger.info('Restarting Payara');
113
+ await payara.restart();
114
+ return {
115
+ status: 'restarted',
116
+ message: 'Payara restarted successfully',
117
+ };
118
+ }
119
+ catch (err) {
120
+ logger.error({ err }, 'Restart failed');
121
+ return reply.code(500).send({
122
+ error: 'Restart failed',
123
+ message: err instanceof Error ? err.message : String(err),
124
+ });
125
+ }
126
+ });
127
+ /**
128
+ * POST /start
129
+ * Start Payara domain
130
+ */
131
+ fastify.post('/start', async (request, reply) => {
132
+ try {
133
+ logger.info('Starting Payara');
134
+ await payara.start();
135
+ return {
136
+ status: 'started',
137
+ message: 'Payara started successfully',
138
+ };
139
+ }
140
+ catch (err) {
141
+ logger.error({ err }, 'Start failed');
142
+ return reply.code(500).send({
143
+ error: 'Start failed',
144
+ message: err instanceof Error ? err.message : String(err),
145
+ });
146
+ }
147
+ });
148
+ /**
149
+ * POST /stop
150
+ * Stop Payara domain
151
+ */
152
+ fastify.post('/stop', async (request, reply) => {
153
+ try {
154
+ logger.info('Stopping Payara');
155
+ await payara.stop();
156
+ return {
157
+ status: 'stopped',
158
+ message: 'Payara stopped successfully',
159
+ };
160
+ }
161
+ catch (err) {
162
+ logger.error({ err }, 'Stop failed');
163
+ return reply.code(500).send({
164
+ error: 'Stop failed',
165
+ message: err instanceof Error ? err.message : String(err),
166
+ });
167
+ }
168
+ });
169
+ /**
170
+ * GET /status
171
+ * Get current Payara status
172
+ */
173
+ fastify.get('/status', async (request, reply) => {
174
+ try {
175
+ const status = await payara.getStatus();
176
+ return status;
177
+ }
178
+ catch (err) {
179
+ logger.error({ err }, 'Failed to get status');
180
+ return reply.code(500).send({
181
+ error: 'Failed to get status',
182
+ message: err instanceof Error ? err.message : String(err),
183
+ });
184
+ }
185
+ });
186
+ /**
187
+ * GET /applications
188
+ * List deployed applications
189
+ */
190
+ fastify.get('/applications', async (request, reply) => {
191
+ try {
192
+ const applications = await payara.listApplications();
193
+ return { applications };
194
+ }
195
+ catch (err) {
196
+ logger.error({ err }, 'Failed to list applications');
197
+ return reply.code(500).send({
198
+ error: 'Failed to list applications',
199
+ message: err instanceof Error ? err.message : String(err),
200
+ });
201
+ }
202
+ });
203
+ /**
204
+ * GET /file/:path
205
+ * Get a specific file from the WAR
206
+ */
207
+ fastify.get('/file/*', async (request, reply) => {
208
+ const filePath = request.params['*'];
209
+ if (!filePath) {
210
+ return reply.code(400).send({
211
+ error: 'Invalid request',
212
+ message: 'File path is required',
213
+ });
214
+ }
215
+ try {
216
+ const content = await deployer.getFile(filePath);
217
+ if (!content) {
218
+ return reply.code(404).send({
219
+ error: 'Not found',
220
+ message: `File not found: ${filePath}`,
221
+ });
222
+ }
223
+ // Determine content type based on extension
224
+ const ext = filePath.split('.').pop()?.toLowerCase();
225
+ const contentTypes = {
226
+ 'xml': 'application/xml',
227
+ 'html': 'text/html',
228
+ 'css': 'text/css',
229
+ 'js': 'application/javascript',
230
+ 'json': 'application/json',
231
+ 'properties': 'text/plain',
232
+ 'txt': 'text/plain',
233
+ 'class': 'application/java-vm',
234
+ 'jar': 'application/java-archive',
235
+ };
236
+ reply.type(contentTypes[ext ?? ''] ?? 'application/octet-stream');
237
+ return content;
238
+ }
239
+ catch (err) {
240
+ logger.error({ err, filePath }, 'Failed to get file');
241
+ return reply.code(500).send({
242
+ error: 'Failed to get file',
243
+ message: err instanceof Error ? err.message : String(err),
244
+ });
245
+ }
246
+ });
247
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.js","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,gCAAgC;AAQhC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAAwB,EACxB,MAAqB,EACrB,QAAqB,EACrB,MAAc;IAGd;;;;OAIG;IACH,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QAC9C,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,gBAAgB,EAAE,CAAC;YACjD,OAAO,EAAE,MAAM,EAAE,CAAC;QACpB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,0BAA0B,CAAC,CAAC;YAClD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBAC1B,KAAK,EAAE,0BAA0B;gBACjC,OAAO,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aAC1D,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;IAEH;;;;OAIG;IACH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from 'pino';
2
+ /**
3
+ * Payara plugin configuration
4
+ */
5
+ export interface PayaraPluginConfig {
6
+ /** Path to Payara installation (e.g., /opt/payara) */
7
+ payaraHome: string;
8
+ /** Payara domain name (e.g., domain1) */
9
+ domain: string;
10
+ /** User to run Payara commands as (for sudo) */
11
+ user: string;
12
+ /** Path to WAR file to deploy */
13
+ warPath: string;
14
+ /** Application name in Payara */
15
+ appName: string;
16
+ /** Health check endpoint URL (e.g., http://localhost:8080/health) */
17
+ healthEndpoint?: string;
18
+ /** Restart Payara when certificates change */
19
+ restartOnCertChange?: boolean;
20
+ /** Timeout for health check in milliseconds (default: 30000) */
21
+ healthCheckTimeout?: number;
22
+ /** Timeout for Payara start/stop operations in milliseconds (default: 120000) */
23
+ operationTimeout?: number;
24
+ /** Deploy context root (default: /) */
25
+ contextRoot?: string;
26
+ /** Enable verbose logging */
27
+ verbose?: boolean;
28
+ }
29
+ /**
30
+ * Payara manager options
31
+ */
32
+ export interface PayaraManagerOptions {
33
+ payaraHome: string;
34
+ domain: string;
35
+ user: string;
36
+ healthEndpoint?: string;
37
+ healthCheckTimeout?: number;
38
+ operationTimeout?: number;
39
+ logger: Logger;
40
+ }
41
+ /**
42
+ * WAR deployer options
43
+ */
44
+ export interface WarDeployerOptions {
45
+ warPath: string;
46
+ appName: string;
47
+ contextRoot?: string;
48
+ payara: PayaraManager;
49
+ logger: Logger;
50
+ }
51
+ /**
52
+ * File hash map for WAR diff deployment
53
+ */
54
+ export interface WarFileHashes {
55
+ [relativePath: string]: string;
56
+ }
57
+ /**
58
+ * File change for deployment
59
+ */
60
+ export interface FileChange {
61
+ path: string;
62
+ content: Buffer;
63
+ }
64
+ /**
65
+ * Deploy request body
66
+ */
67
+ export interface DeployRequest {
68
+ files: Array<{
69
+ path: string;
70
+ content: string;
71
+ }>;
72
+ deletions: string[];
73
+ }
74
+ /**
75
+ * Deploy response
76
+ */
77
+ export interface DeployResponse {
78
+ status: 'deployed' | 'failed';
79
+ filesChanged: number;
80
+ filesDeleted: number;
81
+ message?: string;
82
+ }
83
+ /**
84
+ * Payara status response
85
+ */
86
+ export interface PayaraStatus {
87
+ healthy: boolean;
88
+ running: boolean;
89
+ domain: string;
90
+ pid?: number;
91
+ uptime?: number;
92
+ }
93
+ import type { PayaraManager } from './payara-manager.js';
94
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,sDAAsD;IACtD,UAAU,EAAE,MAAM,CAAC;IAEnB,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;IAEf,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IAEb,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAEhB,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAEhB,qEAAqE;IACrE,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,8CAA8C;IAC9C,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B,gEAAgE;IAChE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B,iFAAiF;IACjF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,uCAAuC;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,6BAA6B;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChD,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,UAAU,GAAG,QAAQ,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAGD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ // Path: src/types.ts
2
+ // Type definitions for Payara plugin
3
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,qCAAqC"}
@@ -0,0 +1,77 @@
1
+ import type { WarDeployerOptions, WarFileHashes, FileChange } from './types.js';
2
+ /**
3
+ * WAR file deployer with diff-based updates
4
+ *
5
+ * Supports:
6
+ * - Full WAR deployment
7
+ * - Diff-based updates (only changed files)
8
+ * - Hash calculation for change detection
9
+ */
10
+ export declare class WarDeployer {
11
+ private readonly warPath;
12
+ private readonly appName;
13
+ private readonly contextRoot?;
14
+ private readonly payara;
15
+ private readonly logger;
16
+ private deployLock;
17
+ constructor(options: WarDeployerOptions);
18
+ /**
19
+ * Check if WAR file exists
20
+ */
21
+ warExists(): Promise<boolean>;
22
+ /**
23
+ * Get SHA-256 hashes of all files in the WAR
24
+ */
25
+ getCurrentHashes(): Promise<WarFileHashes>;
26
+ /**
27
+ * Apply file changes to WAR and deploy
28
+ *
29
+ * This method:
30
+ * 1. Extracts the current WAR to a temp directory
31
+ * 2. Applies file changes and deletions
32
+ * 3. Repackages the WAR
33
+ * 4. Deploys to Payara
34
+ */
35
+ applyChanges(changedFiles: FileChange[], deletedFiles: string[]): Promise<void>;
36
+ /**
37
+ * Apply file changes to WAR without deploying to Payara
38
+ * (Useful for testing or when deployment is handled separately)
39
+ */
40
+ applyChangesWithoutDeploy(changedFiles: FileChange[], deletedFiles: string[]): Promise<void>;
41
+ /**
42
+ * Deploy WAR to Payara (full deployment)
43
+ */
44
+ deploy(): Promise<void>;
45
+ /**
46
+ * Deploy if WAR exists (for startup)
47
+ */
48
+ deployIfExists(): Promise<boolean>;
49
+ /**
50
+ * Check if deployment is in progress
51
+ */
52
+ isDeploying(): boolean;
53
+ /**
54
+ * Get a specific file from the WAR
55
+ */
56
+ getFile(path: string): Promise<Buffer | null>;
57
+ /**
58
+ * Recursively add directory contents to ZIP
59
+ */
60
+ private addDirectoryToZip;
61
+ }
62
+ /**
63
+ * Calculate diff between local and remote hashes
64
+ */
65
+ export declare function calculateDiff(localHashes: WarFileHashes, remoteHashes: WarFileHashes): {
66
+ changed: string[];
67
+ deleted: string[];
68
+ };
69
+ /**
70
+ * Calculate hashes for a local WAR file
71
+ */
72
+ export declare function calculateWarHashes(warPath: string): Promise<WarFileHashes>;
73
+ /**
74
+ * Get file content from a WAR file
75
+ */
76
+ export declare function getWarEntry(warPath: string, path: string): Buffer;
77
+ //# sourceMappingURL=war-deployer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"war-deployer.d.ts","sourceRoot":"","sources":["../src/war-deployer.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEhF;;;;;;;GAOG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAGhC,OAAO,CAAC,UAAU,CAAS;gBAEf,OAAO,EAAE,kBAAkB;IAQvC;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IASnC;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC;IAyBhD;;;;;;;;OAQG;IACG,YAAY,CAChB,YAAY,EAAE,UAAU,EAAE,EAC1B,YAAY,EAAE,MAAM,EAAE,GACrB,OAAO,CAAC,IAAI,CAAC;IA2EhB;;;OAGG;IACG,yBAAyB,CAC7B,YAAY,EAAE,UAAU,EAAE,EAC1B,YAAY,EAAE,MAAM,EAAE,GACrB,OAAO,CAAC,IAAI,CAAC;IAoDhB;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IA6B7B;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IAQxC;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;OAEG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,M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