@vue-skuilder/common 0.1.7 → 0.1.8-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.
@@ -42,7 +42,7 @@ export declare class CouchDBManager extends EventEmitter {
42
42
  */
43
43
  private buildDockerCommand;
44
44
  /**
45
- * Wait for CouchDB to be ready
45
+ * Wait for CouchDB to be ready with admin credentials working
46
46
  */
47
47
  private waitForReady;
48
48
  /**
@@ -77,7 +77,7 @@ export declare class CouchDBManager extends EventEmitter {
77
77
  url: string;
78
78
  };
79
79
  /**
80
- * Configure CORS settings for browser access
80
+ * Configure CORS settings for browser access with retry logic
81
81
  */
82
82
  private configureCORS;
83
83
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CouchDBManager.d.ts","sourceRoot":"","sources":["../../src/docker/CouchDBManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,GAAG,WAAW,GAAG,QAAQ,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED,qBAAa,cAAe,SAAQ,YAAY;IAC9C,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,OAAO,CAAwB;IACvC,OAAO,CA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C,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED,qBAAa,cAAe,SAAQ,YAAY;IAC9C,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,OAAO,CAAwB;IACvC,OAAO,CAAC,UAAU,CAAS;gBAEf,MAAM,EAAE,aAAa,EAAE,OAAO,GAAE,qBAA0B;IAsBtE,OAAO,CAAC,GAAG;IAIX,OAAO,CAAC,KAAK;IAIb;;OAEG;IACG,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC;IAS9C;;OAEG;YACW,eAAe;IAY7B;;OAEG;YACW,kBAAkB;IAYhC;;OAEG;YACW,wBAAwB;IAqBtC;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAoC1B;;OAEG;YACW,YAAY;IAsC1B;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAwC5B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAgB3B;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAgB7B;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IAY7D;;OAEG;IACH,gBAAgB,IAAI,MAAM;IAI1B;;OAEG;IACH,oBAAoB;;;;;;;;IAWpB;;OAEG;YACW,aAAa;CAyE5B"}
@@ -127,7 +127,7 @@ class CouchDBManager extends events_1.EventEmitter {
127
127
  return cmd;
128
128
  }
129
129
  /**
130
- * Wait for CouchDB to be ready
130
+ * Wait for CouchDB to be ready with admin credentials working
131
131
  */
132
132
  async waitForReady() {
133
133
  const maxAttempts = Math.floor(this.config.maxStartupWaitMs / 1000);
@@ -136,10 +136,25 @@ class CouchDBManager extends events_1.EventEmitter {
136
136
  const checkInterval = setInterval(() => {
137
137
  attempts++;
138
138
  try {
139
+ // First check basic connectivity
139
140
  (0, child_process_1.execSync)(`curl -s http://localhost:${this.config.port}/`, { stdio: 'pipe' });
140
- clearInterval(checkInterval);
141
- this.log('CouchDB is ready!');
142
- resolve();
141
+ // Then verify admin credentials work by checking _up endpoint
142
+ const auth = `${this.config.username}:${this.config.password}`;
143
+ const result = (0, child_process_1.execSync)(`curl -s http://${auth}@localhost:${this.config.port}/_up`, { stdio: 'pipe' }).toString();
144
+ // _up endpoint should return {"status":"ok"} when admin is ready
145
+ if (result.includes('"status":"ok"')) {
146
+ clearInterval(checkInterval);
147
+ this.log('CouchDB is ready with admin credentials!');
148
+ resolve();
149
+ }
150
+ else {
151
+ // CouchDB responds but admin not ready yet
152
+ this.log(`CouchDB responding but admin not ready (attempt ${attempts}/${maxAttempts})`);
153
+ if (attempts >= maxAttempts) {
154
+ clearInterval(checkInterval);
155
+ reject(new Error('CouchDB admin credentials failed to become ready within timeout period'));
156
+ }
157
+ }
143
158
  }
144
159
  catch {
145
160
  if (attempts >= maxAttempts) {
@@ -256,50 +271,75 @@ class CouchDBManager extends events_1.EventEmitter {
256
271
  };
257
272
  }
258
273
  /**
259
- * Configure CORS settings for browser access
274
+ * Configure CORS settings for browser access with retry logic
260
275
  */
261
276
  async configureCORS() {
262
- try {
263
- this.log('Configuring CORS for browser access...');
264
- const baseUrl = `http://localhost:${this.config.port}`;
265
- const auth = `${this.config.username}:${this.config.password}`;
266
- // Enable CORS with comprehensive PouchDB-compatible headers
267
- // Note: CouchDB requires BOTH chttpd/enable_cors AND cors section settings
268
- const corsCommands = [
269
- // First: Enable CORS globally in chttpd section (CRITICAL!)
270
- `curl -X PUT "${baseUrl}/_node/_local/_config/chttpd/enable_cors" -d '"true"' -H "Content-Type: application/json" -u "${auth}"`,
271
- // Then: Configure CORS settings in cors section
272
- `curl -X PUT "${baseUrl}/_node/_local/_config/cors/enable" -d '"true"' -H "Content-Type: application/json" -u "${auth}"`,
273
- `curl -X PUT "${baseUrl}/_node/_local/_config/cors/origins" -d '"*"' -H "Content-Type: application/json" -u "${auth}"`,
274
- `curl -X PUT "${baseUrl}/_node/_local/_config/cors/methods" -d '"GET,POST,PUT,DELETE,OPTIONS,HEAD"' -H "Content-Type: application/json" -u "${auth}"`,
275
- `curl -X PUT "${baseUrl}/_node/_local/_config/cors/headers" -d '"accept,authorization,content-type,origin,referer,x-csrf-token,cache-control,if-none-match,x-requested-with,pragma,expires,x-couch-request-id,x-couch-update-newrev"' -H "Content-Type: application/json" -u "${auth}"`,
276
- `curl -X PUT "${baseUrl}/_node/_local/_config/cors/credentials" -d '"true"' -H "Content-Type: application/json" -u "${auth}"`,
277
- ];
278
- for (const cmd of corsCommands) {
277
+ const maxRetries = 3;
278
+ let attempt = 0;
279
+ while (attempt < maxRetries) {
280
+ try {
281
+ attempt++;
282
+ this.log(`Configuring CORS for browser access (attempt ${attempt}/${maxRetries})...`);
283
+ const baseUrl = `http://localhost:${this.config.port}`;
284
+ const auth = `${this.config.username}:${this.config.password}`;
285
+ // Enable CORS with comprehensive PouchDB-compatible headers
286
+ // Note: CouchDB requires BOTH chttpd/enable_cors AND cors section settings
287
+ const corsCommands = [
288
+ // First: Enable CORS globally in chttpd section (CRITICAL!)
289
+ `curl -X PUT "${baseUrl}/_node/_local/_config/chttpd/enable_cors" -d '"true"' -H "Content-Type: application/json" -u "${auth}"`,
290
+ // Then: Configure CORS settings in cors section
291
+ `curl -X PUT "${baseUrl}/_node/_local/_config/cors/enable" -d '"true"' -H "Content-Type: application/json" -u "${auth}"`,
292
+ `curl -X PUT "${baseUrl}/_node/_local/_config/cors/origins" -d '"*"' -H "Content-Type: application/json" -u "${auth}"`,
293
+ `curl -X PUT "${baseUrl}/_node/_local/_config/cors/methods" -d '"GET,POST,PUT,DELETE,OPTIONS,HEAD"' -H "Content-Type: application/json" -u "${auth}"`,
294
+ `curl -X PUT "${baseUrl}/_node/_local/_config/cors/headers" -d '"accept,authorization,content-type,origin,referer,x-csrf-token,cache-control,if-none-match,x-requested-with,pragma,expires,x-couch-request-id,x-couch-update-newrev"' -H "Content-Type: application/json" -u "${auth}"`,
295
+ `curl -X PUT "${baseUrl}/_node/_local/_config/cors/credentials" -d '"true"' -H "Content-Type: application/json" -u "${auth}"`,
296
+ ];
297
+ for (const cmd of corsCommands) {
298
+ const result = (0, child_process_1.execSync)(cmd, { stdio: 'pipe' }).toString().trim();
299
+ // Check for CouchDB error responses
300
+ if (result.includes('"error":"unauthorized"')) {
301
+ this.error(`CORS command failed with unauthorized: ${cmd}`);
302
+ this.error(`Response: ${result}`);
303
+ throw new Error(`CORS configuration failed: unauthorized access. Admin credentials may not be ready.`);
304
+ }
305
+ else if (result.includes('"error":')) {
306
+ this.error(`CORS command failed with error: ${cmd}`);
307
+ this.error(`Response: ${result}`);
308
+ throw new Error(`CORS configuration failed: ${result}`);
309
+ }
310
+ else {
311
+ this.log(`CORS command success: ${result || 'OK'}`);
312
+ }
313
+ }
314
+ // Verify CORS configuration took effect
279
315
  try {
280
- const result = (0, child_process_1.execSync)(cmd, { stdio: 'pipe' }).toString();
281
- this.log(`CORS command success: ${result.trim()}`);
316
+ this.log('Verifying CORS configuration...');
317
+ const verifyCmd = `curl -s "${baseUrl}/_node/_local/_config/cors" -u "${auth}"`;
318
+ const corsSettings = (0, child_process_1.execSync)(verifyCmd, { stdio: 'pipe' }).toString();
319
+ this.log(`CORS verification result: ${corsSettings.trim()}`);
282
320
  }
283
321
  catch (error) {
284
- this.error(`CORS command failed: ${cmd} - ${error instanceof Error ? error.message : String(error)}`);
285
- throw error;
322
+ this.log(`Warning: CORS verification failed: ${error instanceof Error ? error.message : String(error)}`);
286
323
  }
287
- }
288
- // Verify CORS configuration took effect
289
- try {
290
- this.log('Verifying CORS configuration...');
291
- const verifyCmd = `curl -s "${baseUrl}/_node/_local/_config/cors" -u "${auth}"`;
292
- const corsSettings = (0, child_process_1.execSync)(verifyCmd, { stdio: 'pipe' }).toString();
293
- this.log(`CORS verification result: ${corsSettings.trim()}`);
324
+ this.log('CORS configuration completed successfully');
325
+ return; // Success - exit retry loop
294
326
  }
295
327
  catch (error) {
296
- this.log(`Warning: CORS verification failed: ${error instanceof Error ? error.message : String(error)}`);
328
+ const errorMessage = error instanceof Error ? error.message : String(error);
329
+ if (attempt < maxRetries && errorMessage.includes('unauthorized')) {
330
+ // Retry with exponential backoff for auth issues
331
+ const delay = Math.pow(2, attempt - 1) * 1000; // 1s, 2s, 4s
332
+ this.log(`CORS configuration failed (attempt ${attempt}/${maxRetries}), retrying in ${delay}ms...`);
333
+ await new Promise(resolve => setTimeout(resolve, delay));
334
+ continue;
335
+ }
336
+ else {
337
+ // Final attempt failed or non-auth error
338
+ this.error(`CORS configuration failed after ${attempt} attempts: ${errorMessage}`);
339
+ // Don't throw - CORS failure shouldn't prevent container startup
340
+ return;
341
+ }
297
342
  }
298
- this.log('CORS configuration completed');
299
- }
300
- catch (error) {
301
- this.log(`Warning: CORS configuration failed: ${error instanceof Error ? error.message : String(error)}`);
302
- // Don't throw - CORS failure shouldn't prevent container startup
303
343
  }
304
344
  }
305
345
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CouchDBManager.js","sourceRoot":"","sources":["../../src/docker/CouchDBManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAmBtC,MAAM,OAAO,cAAe,SAAQ,YAAY;IACtC,MAAM,CAA0B;IAChC,OAAO,CAAwB;IAC/B,UAAU,GAAG,KAAK,CAAC;IAE3B,YAAY,MAAqB,EAAE,UAAiC,EAAE;QACpE,KAAK,EAAE,CAAC;QAER,eAAe;QACf,IAAI,CAAC,MAAM,GAAG;YACZ,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,aAAa,EAAE,MAAM,CAAC,aAAa,IAAI,kBAAkB,MAAM,CAAC,IAAI,EAAE;YACtE,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,eA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CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;oBACzD,SAAS;gBACX,CAAC;qBAAM,CAAC;oBACN,yCAAyC;oBACzC,IAAI,CAAC,KAAK,CAAC,mCAAmC,OAAO,cAAc,YAAY,EAAE,CAAC,CAAC;oBACnF,iEAAiE;oBACjE,OAAO;gBACT,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
@@ -124,7 +124,7 @@ export class CouchDBManager extends EventEmitter {
124
124
  return cmd;
125
125
  }
126
126
  /**
127
- * Wait for CouchDB to be ready
127
+ * Wait for CouchDB to be ready with admin credentials working
128
128
  */
129
129
  async waitForReady() {
130
130
  const maxAttempts = Math.floor(this.config.maxStartupWaitMs / 1000);
@@ -133,10 +133,25 @@ export class CouchDBManager extends EventEmitter {
133
133
  const checkInterval = setInterval(() => {
134
134
  attempts++;
135
135
  try {
136
+ // First check basic connectivity
136
137
  execSync(`curl -s http://localhost:${this.config.port}/`, { stdio: 'pipe' });
137
- clearInterval(checkInterval);
138
- this.log('CouchDB is ready!');
139
- resolve();
138
+ // Then verify admin credentials work by checking _up endpoint
139
+ const auth = `${this.config.username}:${this.config.password}`;
140
+ const result = execSync(`curl -s http://${auth}@localhost:${this.config.port}/_up`, { stdio: 'pipe' }).toString();
141
+ // _up endpoint should return {"status":"ok"} when admin is ready
142
+ if (result.includes('"status":"ok"')) {
143
+ clearInterval(checkInterval);
144
+ this.log('CouchDB is ready with admin credentials!');
145
+ resolve();
146
+ }
147
+ else {
148
+ // CouchDB responds but admin not ready yet
149
+ this.log(`CouchDB responding but admin not ready (attempt ${attempts}/${maxAttempts})`);
150
+ if (attempts >= maxAttempts) {
151
+ clearInterval(checkInterval);
152
+ reject(new Error('CouchDB admin credentials failed to become ready within timeout period'));
153
+ }
154
+ }
140
155
  }
141
156
  catch {
142
157
  if (attempts >= maxAttempts) {
@@ -253,50 +268,75 @@ export class CouchDBManager extends EventEmitter {
253
268
  };
254
269
  }
255
270
  /**
256
- * Configure CORS settings for browser access
271
+ * Configure CORS settings for browser access with retry logic
257
272
  */
258
273
  async configureCORS() {
259
- try {
260
- this.log('Configuring CORS for browser access...');
261
- const baseUrl = `http://localhost:${this.config.port}`;
262
- const auth = `${this.config.username}:${this.config.password}`;
263
- // Enable CORS with comprehensive PouchDB-compatible headers
264
- // Note: CouchDB requires BOTH chttpd/enable_cors AND cors section settings
265
- const corsCommands = [
266
- // First: Enable CORS globally in chttpd section (CRITICAL!)
267
- `curl -X PUT "${baseUrl}/_node/_local/_config/chttpd/enable_cors" -d '"true"' -H "Content-Type: application/json" -u "${auth}"`,
268
- // Then: Configure CORS settings in cors section
269
- `curl -X PUT "${baseUrl}/_node/_local/_config/cors/enable" -d '"true"' -H "Content-Type: application/json" -u "${auth}"`,
270
- `curl -X PUT "${baseUrl}/_node/_local/_config/cors/origins" -d '"*"' -H "Content-Type: application/json" -u "${auth}"`,
271
- `curl -X PUT "${baseUrl}/_node/_local/_config/cors/methods" -d '"GET,POST,PUT,DELETE,OPTIONS,HEAD"' -H "Content-Type: application/json" -u "${auth}"`,
272
- `curl -X PUT "${baseUrl}/_node/_local/_config/cors/headers" -d '"accept,authorization,content-type,origin,referer,x-csrf-token,cache-control,if-none-match,x-requested-with,pragma,expires,x-couch-request-id,x-couch-update-newrev"' -H "Content-Type: application/json" -u "${auth}"`,
273
- `curl -X PUT "${baseUrl}/_node/_local/_config/cors/credentials" -d '"true"' -H "Content-Type: application/json" -u "${auth}"`,
274
- ];
275
- for (const cmd of corsCommands) {
274
+ const maxRetries = 3;
275
+ let attempt = 0;
276
+ while (attempt < maxRetries) {
277
+ try {
278
+ attempt++;
279
+ this.log(`Configuring CORS for browser access (attempt ${attempt}/${maxRetries})...`);
280
+ const baseUrl = `http://localhost:${this.config.port}`;
281
+ const auth = `${this.config.username}:${this.config.password}`;
282
+ // Enable CORS with comprehensive PouchDB-compatible headers
283
+ // Note: CouchDB requires BOTH chttpd/enable_cors AND cors section settings
284
+ const corsCommands = [
285
+ // First: Enable CORS globally in chttpd section (CRITICAL!)
286
+ `curl -X PUT "${baseUrl}/_node/_local/_config/chttpd/enable_cors" -d '"true"' -H "Content-Type: application/json" -u "${auth}"`,
287
+ // Then: Configure CORS settings in cors section
288
+ `curl -X PUT "${baseUrl}/_node/_local/_config/cors/enable" -d '"true"' -H "Content-Type: application/json" -u "${auth}"`,
289
+ `curl -X PUT "${baseUrl}/_node/_local/_config/cors/origins" -d '"*"' -H "Content-Type: application/json" -u "${auth}"`,
290
+ `curl -X PUT "${baseUrl}/_node/_local/_config/cors/methods" -d '"GET,POST,PUT,DELETE,OPTIONS,HEAD"' -H "Content-Type: application/json" -u "${auth}"`,
291
+ `curl -X PUT "${baseUrl}/_node/_local/_config/cors/headers" -d '"accept,authorization,content-type,origin,referer,x-csrf-token,cache-control,if-none-match,x-requested-with,pragma,expires,x-couch-request-id,x-couch-update-newrev"' -H "Content-Type: application/json" -u "${auth}"`,
292
+ `curl -X PUT "${baseUrl}/_node/_local/_config/cors/credentials" -d '"true"' -H "Content-Type: application/json" -u "${auth}"`,
293
+ ];
294
+ for (const cmd of corsCommands) {
295
+ const result = execSync(cmd, { stdio: 'pipe' }).toString().trim();
296
+ // Check for CouchDB error responses
297
+ if (result.includes('"error":"unauthorized"')) {
298
+ this.error(`CORS command failed with unauthorized: ${cmd}`);
299
+ this.error(`Response: ${result}`);
300
+ throw new Error(`CORS configuration failed: unauthorized access. Admin credentials may not be ready.`);
301
+ }
302
+ else if (result.includes('"error":')) {
303
+ this.error(`CORS command failed with error: ${cmd}`);
304
+ this.error(`Response: ${result}`);
305
+ throw new Error(`CORS configuration failed: ${result}`);
306
+ }
307
+ else {
308
+ this.log(`CORS command success: ${result || 'OK'}`);
309
+ }
310
+ }
311
+ // Verify CORS configuration took effect
276
312
  try {
277
- const result = execSync(cmd, { stdio: 'pipe' }).toString();
278
- this.log(`CORS command success: ${result.trim()}`);
313
+ this.log('Verifying CORS configuration...');
314
+ const verifyCmd = `curl -s "${baseUrl}/_node/_local/_config/cors" -u "${auth}"`;
315
+ const corsSettings = execSync(verifyCmd, { stdio: 'pipe' }).toString();
316
+ this.log(`CORS verification result: ${corsSettings.trim()}`);
279
317
  }
280
318
  catch (error) {
281
- this.error(`CORS command failed: ${cmd} - ${error instanceof Error ? error.message : String(error)}`);
282
- throw error;
319
+ this.log(`Warning: CORS verification failed: ${error instanceof Error ? error.message : String(error)}`);
283
320
  }
284
- }
285
- // Verify CORS configuration took effect
286
- try {
287
- this.log('Verifying CORS configuration...');
288
- const verifyCmd = `curl -s "${baseUrl}/_node/_local/_config/cors" -u "${auth}"`;
289
- const corsSettings = execSync(verifyCmd, { stdio: 'pipe' }).toString();
290
- this.log(`CORS verification result: ${corsSettings.trim()}`);
321
+ this.log('CORS configuration completed successfully');
322
+ return; // Success - exit retry loop
291
323
  }
292
324
  catch (error) {
293
- this.log(`Warning: CORS verification failed: ${error instanceof Error ? error.message : String(error)}`);
325
+ const errorMessage = error instanceof Error ? error.message : String(error);
326
+ if (attempt < maxRetries && errorMessage.includes('unauthorized')) {
327
+ // Retry with exponential backoff for auth issues
328
+ const delay = Math.pow(2, attempt - 1) * 1000; // 1s, 2s, 4s
329
+ this.log(`CORS configuration failed (attempt ${attempt}/${maxRetries}), retrying in ${delay}ms...`);
330
+ await new Promise(resolve => setTimeout(resolve, delay));
331
+ continue;
332
+ }
333
+ else {
334
+ // Final attempt failed or non-auth error
335
+ this.error(`CORS configuration failed after ${attempt} attempts: ${errorMessage}`);
336
+ // Don't throw - CORS failure shouldn't prevent container startup
337
+ return;
338
+ }
294
339
  }
295
- this.log('CORS configuration completed');
296
- }
297
- catch (error) {
298
- this.log(`Warning: CORS configuration failed: ${error instanceof Error ? error.message : String(error)}`);
299
- // Don't throw - CORS failure shouldn't prevent container startup
300
340
  }
301
341
  }
302
342
  }
@@ -127,7 +127,21 @@ export interface AddCourseData extends IServerRequest {
127
127
  ok: boolean;
128
128
  };
129
129
  }
130
- export type ServerRequest = CreateClassroom | DeleteClassroom | JoinClassroom | LeaveClassroom | CreateCourse | DeleteCourse | AddCourseData;
130
+ export interface PackCourse extends IServerRequest {
131
+ type: ServerRequestType.PACK_COURSE;
132
+ courseId: string;
133
+ outputPath?: string;
134
+ response: {
135
+ status: Status;
136
+ ok: boolean;
137
+ errorText?: string;
138
+ packedFiles?: string[];
139
+ outputPath?: string;
140
+ totalFiles?: number;
141
+ duration?: number;
142
+ } | null;
143
+ }
144
+ export type ServerRequest = CreateClassroom | DeleteClassroom | JoinClassroom | LeaveClassroom | CreateCourse | DeleteCourse | AddCourseData | PackCourse;
131
145
  export declare enum ServerRequestType {
132
146
  CREATE_CLASSROOM = "CREATE_CLASSROOM",
133
147
  DELETE_CLASSROOM = "DELETE_CLASSROOM",
@@ -135,7 +149,8 @@ export declare enum ServerRequestType {
135
149
  LEAVE_CLASSROOM = "LEAVE_CLASSROOM",
136
150
  CREATE_COURSE = "CREATE_COURSE",
137
151
  DELETE_COURSE = "DELETE_COURSE",
138
- ADD_COURSE_DATA = "ADD_COURSE_DATA"
152
+ ADD_COURSE_DATA = "ADD_COURSE_DATA",
153
+ PACK_COURSE = "PACK_COURSE"
139
154
  }
140
155
  export {};
141
156
  //# sourceMappingURL=wire-format.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wire-format.d.ts","sourceRoot":"","sources":["../src/wire-format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,oBAAY,MAAM;IAChB,gBAAgB,aAAa;IAC7B,EAAE,OAAO;IACT,OAAO,YAAY;IACnB,KAAK,UAAU;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,OAAO,CAAC;CACb;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,iBAAiB,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,eAAe,GAAG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IACjC,eAAe,oBAAoB;IACnC,aAAa,kBAAkB;IAC/B,aAAa,kBAAkB;IAC/B,eAAe,oBAAoB;IACnC,WAAW,gBAAgB;CAC5B"}
@@ -17,5 +17,6 @@ var ServerRequestType;
17
17
  ServerRequestType["CREATE_COURSE"] = "CREATE_COURSE";
18
18
  ServerRequestType["DELETE_COURSE"] = "DELETE_COURSE";
19
19
  ServerRequestType["ADD_COURSE_DATA"] = "ADD_COURSE_DATA";
20
+ ServerRequestType["PACK_COURSE"] = "PACK_COURSE";
20
21
  })(ServerRequestType || (exports.ServerRequestType = ServerRequestType = {}));
21
22
  //# sourceMappingURL=wire-format.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wire-format.js","sourceRoot":"","sources":["../src/wire-format.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,MAKX;AALD,WAAY,MAAM;IAChB,uCAA6B,CAAA;IAC7B,mBAAS,CAAA;IACT,6BAAmB,CAAA;IACnB,yBAAe,CAAA;AACjB,CAAC,EALW,MAAM,KAAN,MAAM,QAKjB;AA+ID,MAAM,CAAN,IAAY,iBAQX;AARD,WAAY,iBAAiB;IAC3B,0DAAqC,CAAA;IACrC,0DAAqC,CAAA;IACrC,sDAAiC,CAAA;IACjC,wDAAmC,CAAA;IACnC,oDAA+B,CAAA;IAC/B,oDAA+B,CAAA;IAC/B,wDAAmC,CAAA;AACrC,CAAC,EARW,iBAAiB,KAAjB,iBAAiB,QAQ5B"}
1
+ {"version":3,"file":"wire-format.js","sourceRoot":"","sources":["../src/wire-format.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,MAKX;AALD,WAAY,MAAM;IAChB,uCAA6B,CAAA;IAC7B,mBAAS,CAAA;IACT,6BAAmB,CAAA;IACnB,yBAAe,CAAA;AACjB,CAAC,EALW,MAAM,KAAN,MAAM,QAKjB;AA+JD,MAAM,CAAN,IAAY,iBASX;AATD,WAAY,iBAAiB;IAC3B,0DAAqC,CAAA;IACrC,0DAAqC,CAAA;IACrC,sDAAiC,CAAA;IACjC,wDAAmC,CAAA;IACnC,oDAA+B,CAAA;IAC/B,oDAA+B,CAAA;IAC/B,wDAAmC,CAAA;IACnC,gDAA2B,CAAA;AAC7B,CAAC,EATW,iBAAiB,KAAjB,iBAAiB,QAS5B"}
@@ -14,5 +14,6 @@ export var ServerRequestType;
14
14
  ServerRequestType["CREATE_COURSE"] = "CREATE_COURSE";
15
15
  ServerRequestType["DELETE_COURSE"] = "DELETE_COURSE";
16
16
  ServerRequestType["ADD_COURSE_DATA"] = "ADD_COURSE_DATA";
17
+ ServerRequestType["PACK_COURSE"] = "PACK_COURSE";
17
18
  })(ServerRequestType || (ServerRequestType = {}));
18
19
  //# sourceMappingURL=wire-format.js.map
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.1.7",
6
+ "version": "0.1.8-1",
7
7
  "type": "module",
8
8
  "main": "dist/index.js",
9
9
  "module": "dist/index.mjs",
@@ -33,5 +33,6 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "moment": "^2.30.1"
36
- }
36
+ },
37
+ "stableVersion": "0.1.7"
37
38
  }
@@ -159,7 +159,7 @@ export class CouchDBManager extends EventEmitter {
159
159
  }
160
160
 
161
161
  /**
162
- * Wait for CouchDB to be ready
162
+ * Wait for CouchDB to be ready with admin credentials working
163
163
  */
164
164
  private async waitForReady(): Promise<void> {
165
165
  const maxAttempts = Math.floor(this.config.maxStartupWaitMs / 1000);
@@ -169,10 +169,26 @@ export class CouchDBManager extends EventEmitter {
169
169
  const checkInterval = setInterval(() => {
170
170
  attempts++;
171
171
  try {
172
+ // First check basic connectivity
172
173
  execSync(`curl -s http://localhost:${this.config.port}/`, { stdio: 'pipe' });
173
- clearInterval(checkInterval);
174
- this.log('CouchDB is ready!');
175
- resolve();
174
+
175
+ // Then verify admin credentials work by checking _up endpoint
176
+ const auth = `${this.config.username}:${this.config.password}`;
177
+ const result = execSync(`curl -s http://${auth}@localhost:${this.config.port}/_up`, { stdio: 'pipe' }).toString();
178
+
179
+ // _up endpoint should return {"status":"ok"} when admin is ready
180
+ if (result.includes('"status":"ok"')) {
181
+ clearInterval(checkInterval);
182
+ this.log('CouchDB is ready with admin credentials!');
183
+ resolve();
184
+ } else {
185
+ // CouchDB responds but admin not ready yet
186
+ this.log(`CouchDB responding but admin not ready (attempt ${attempts}/${maxAttempts})`);
187
+ if (attempts >= maxAttempts) {
188
+ clearInterval(checkInterval);
189
+ reject(new Error('CouchDB admin credentials failed to become ready within timeout period'));
190
+ }
191
+ }
176
192
  } catch {
177
193
  if (attempts >= maxAttempts) {
178
194
  clearInterval(checkInterval);
@@ -301,52 +317,79 @@ export class CouchDBManager extends EventEmitter {
301
317
  }
302
318
 
303
319
  /**
304
- * Configure CORS settings for browser access
320
+ * Configure CORS settings for browser access with retry logic
305
321
  */
306
322
  private async configureCORS(): Promise<void> {
307
- try {
308
- this.log('Configuring CORS for browser access...');
309
-
310
- const baseUrl = `http://localhost:${this.config.port}`;
311
- const auth = `${this.config.username}:${this.config.password}`;
312
-
313
- // Enable CORS with comprehensive PouchDB-compatible headers
314
- // Note: CouchDB requires BOTH chttpd/enable_cors AND cors section settings
315
- const corsCommands = [
316
- // First: Enable CORS globally in chttpd section (CRITICAL!)
317
- `curl -X PUT "${baseUrl}/_node/_local/_config/chttpd/enable_cors" -d '"true"' -H "Content-Type: application/json" -u "${auth}"`,
318
- // Then: Configure CORS settings in cors section
319
- `curl -X PUT "${baseUrl}/_node/_local/_config/cors/enable" -d '"true"' -H "Content-Type: application/json" -u "${auth}"`,
320
- `curl -X PUT "${baseUrl}/_node/_local/_config/cors/origins" -d '"*"' -H "Content-Type: application/json" -u "${auth}"`,
321
- `curl -X PUT "${baseUrl}/_node/_local/_config/cors/methods" -d '"GET,POST,PUT,DELETE,OPTIONS,HEAD"' -H "Content-Type: application/json" -u "${auth}"`,
322
- `curl -X PUT "${baseUrl}/_node/_local/_config/cors/headers" -d '"accept,authorization,content-type,origin,referer,x-csrf-token,cache-control,if-none-match,x-requested-with,pragma,expires,x-couch-request-id,x-couch-update-newrev"' -H "Content-Type: application/json" -u "${auth}"`,
323
- `curl -X PUT "${baseUrl}/_node/_local/_config/cors/credentials" -d '"true"' -H "Content-Type: application/json" -u "${auth}"`,
324
- ];
323
+ const maxRetries = 3;
324
+ let attempt = 0;
325
+
326
+ while (attempt < maxRetries) {
327
+ try {
328
+ attempt++;
329
+ this.log(`Configuring CORS for browser access (attempt ${attempt}/${maxRetries})...`);
330
+
331
+ const baseUrl = `http://localhost:${this.config.port}`;
332
+ const auth = `${this.config.username}:${this.config.password}`;
333
+
334
+ // Enable CORS with comprehensive PouchDB-compatible headers
335
+ // Note: CouchDB requires BOTH chttpd/enable_cors AND cors section settings
336
+ const corsCommands = [
337
+ // First: Enable CORS globally in chttpd section (CRITICAL!)
338
+ `curl -X PUT "${baseUrl}/_node/_local/_config/chttpd/enable_cors" -d '"true"' -H "Content-Type: application/json" -u "${auth}"`,
339
+ // Then: Configure CORS settings in cors section
340
+ `curl -X PUT "${baseUrl}/_node/_local/_config/cors/enable" -d '"true"' -H "Content-Type: application/json" -u "${auth}"`,
341
+ `curl -X PUT "${baseUrl}/_node/_local/_config/cors/origins" -d '"*"' -H "Content-Type: application/json" -u "${auth}"`,
342
+ `curl -X PUT "${baseUrl}/_node/_local/_config/cors/methods" -d '"GET,POST,PUT,DELETE,OPTIONS,HEAD"' -H "Content-Type: application/json" -u "${auth}"`,
343
+ `curl -X PUT "${baseUrl}/_node/_local/_config/cors/headers" -d '"accept,authorization,content-type,origin,referer,x-csrf-token,cache-control,if-none-match,x-requested-with,pragma,expires,x-couch-request-id,x-couch-update-newrev"' -H "Content-Type: application/json" -u "${auth}"`,
344
+ `curl -X PUT "${baseUrl}/_node/_local/_config/cors/credentials" -d '"true"' -H "Content-Type: application/json" -u "${auth}"`,
345
+ ];
325
346
 
326
- for (const cmd of corsCommands) {
347
+ for (const cmd of corsCommands) {
348
+ const result = execSync(cmd, { stdio: 'pipe' }).toString().trim();
349
+
350
+ // Check for CouchDB error responses
351
+ if (result.includes('"error":"unauthorized"')) {
352
+ this.error(`CORS command failed with unauthorized: ${cmd}`);
353
+ this.error(`Response: ${result}`);
354
+ throw new Error(`CORS configuration failed: unauthorized access. Admin credentials may not be ready.`);
355
+ } else if (result.includes('"error":')) {
356
+ this.error(`CORS command failed with error: ${cmd}`);
357
+ this.error(`Response: ${result}`);
358
+ throw new Error(`CORS configuration failed: ${result}`);
359
+ } else {
360
+ this.log(`CORS command success: ${result || 'OK'}`);
361
+ }
362
+ }
363
+
364
+ // Verify CORS configuration took effect
327
365
  try {
328
- const result = execSync(cmd, { stdio: 'pipe' }).toString();
329
- this.log(`CORS command success: ${result.trim()}`);
366
+ this.log('Verifying CORS configuration...');
367
+ const verifyCmd = `curl -s "${baseUrl}/_node/_local/_config/cors" -u "${auth}"`;
368
+ const corsSettings = execSync(verifyCmd, { stdio: 'pipe' }).toString();
369
+ this.log(`CORS verification result: ${corsSettings.trim()}`);
330
370
  } catch (error: unknown) {
331
- this.error(`CORS command failed: ${cmd} - ${error instanceof Error ? error.message : String(error)}`);
332
- throw error;
371
+ this.log(`Warning: CORS verification failed: ${error instanceof Error ? error.message : String(error)}`);
333
372
  }
334
- }
335
-
336
- // Verify CORS configuration took effect
337
- try {
338
- this.log('Verifying CORS configuration...');
339
- const verifyCmd = `curl -s "${baseUrl}/_node/_local/_config/cors" -u "${auth}"`;
340
- const corsSettings = execSync(verifyCmd, { stdio: 'pipe' }).toString();
341
- this.log(`CORS verification result: ${corsSettings.trim()}`);
373
+
374
+ this.log('CORS configuration completed successfully');
375
+ return; // Success - exit retry loop
376
+
342
377
  } catch (error: unknown) {
343
- this.log(`Warning: CORS verification failed: ${error instanceof Error ? error.message : String(error)}`);
378
+ const errorMessage = error instanceof Error ? error.message : String(error);
379
+
380
+ if (attempt < maxRetries && errorMessage.includes('unauthorized')) {
381
+ // Retry with exponential backoff for auth issues
382
+ const delay = Math.pow(2, attempt - 1) * 1000; // 1s, 2s, 4s
383
+ this.log(`CORS configuration failed (attempt ${attempt}/${maxRetries}), retrying in ${delay}ms...`);
384
+ await new Promise(resolve => setTimeout(resolve, delay));
385
+ continue;
386
+ } else {
387
+ // Final attempt failed or non-auth error
388
+ this.error(`CORS configuration failed after ${attempt} attempts: ${errorMessage}`);
389
+ // Don't throw - CORS failure shouldn't prevent container startup
390
+ return;
391
+ }
344
392
  }
345
-
346
- this.log('CORS configuration completed');
347
- } catch (error: unknown) {
348
- this.log(`Warning: CORS configuration failed: ${error instanceof Error ? error.message : String(error)}`);
349
- // Don't throw - CORS failure shouldn't prevent container startup
350
393
  }
351
394
  }
352
395
  }
@@ -139,6 +139,21 @@ export interface AddCourseData extends IServerRequest {
139
139
  };
140
140
  }
141
141
 
142
+ export interface PackCourse extends IServerRequest {
143
+ type: ServerRequestType.PACK_COURSE;
144
+ courseId: string;
145
+ outputPath?: string;
146
+ response: {
147
+ status: Status;
148
+ ok: boolean;
149
+ errorText?: string;
150
+ packedFiles?: string[];
151
+ outputPath?: string;
152
+ totalFiles?: number;
153
+ duration?: number;
154
+ } | null;
155
+ }
156
+
142
157
  export type ServerRequest =
143
158
  | CreateClassroom
144
159
  | DeleteClassroom
@@ -146,7 +161,8 @@ export type ServerRequest =
146
161
  | LeaveClassroom
147
162
  | CreateCourse
148
163
  | DeleteCourse
149
- | AddCourseData;
164
+ | AddCourseData
165
+ | PackCourse;
150
166
 
151
167
  export enum ServerRequestType {
152
168
  CREATE_CLASSROOM = 'CREATE_CLASSROOM',
@@ -156,4 +172,5 @@ export enum ServerRequestType {
156
172
  CREATE_COURSE = 'CREATE_COURSE',
157
173
  DELETE_COURSE = 'DELETE_COURSE',
158
174
  ADD_COURSE_DATA = 'ADD_COURSE_DATA',
175
+ PACK_COURSE = 'PACK_COURSE',
159
176
  }