@pikku/mongodb 0.12.1 → 0.12.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,41 @@
1
1
  # @pikku/mongodb
2
2
 
3
+ ## 0.12.3
4
+
5
+ ### Patch Changes
6
+
7
+ - a2ee6d0: Replace process.exit(1) with thrown error on MongoDB connection failure to allow graceful error handling.
8
+ - 87433f0: Validate state key names in updateRunState to prevent MongoDB operator injection.
9
+ - Updated dependencies [e412b4d]
10
+ - Updated dependencies [53dc8c8]
11
+ - Updated dependencies [0a1cc51]
12
+ - Updated dependencies [0a1cc51]
13
+ - Updated dependencies [0a1cc51]
14
+ - Updated dependencies [0a1cc51]
15
+ - Updated dependencies [0a1cc51]
16
+ - Updated dependencies [0a1cc51]
17
+ - Updated dependencies [0a1cc51]
18
+ - Updated dependencies [0a1cc51]
19
+ - Updated dependencies [0a1cc51]
20
+ - Updated dependencies [8b9b2e9]
21
+ - Updated dependencies [8b9b2e9]
22
+ - Updated dependencies [b973d44]
23
+ - Updated dependencies [8b9b2e9]
24
+ - Updated dependencies [8b9b2e9]
25
+ - @pikku/core@0.12.9
26
+
27
+ ## 0.12.2
28
+
29
+ ### Patch Changes
30
+
31
+ - 3e79248: Add setStepChildRunId to workflow service implementations and auto-bootstrap in pikku all
32
+ - Updated dependencies [bb27710]
33
+ - Updated dependencies [a31bc63]
34
+ - Updated dependencies [3e79248]
35
+ - Updated dependencies [b0a81cc]
36
+ - Updated dependencies [6413df7]
37
+ - @pikku/core@0.12.6
38
+
3
39
  ## 0.12.1
4
40
 
5
41
  ### Patch Changes
@@ -50,7 +50,7 @@ export class MongoDBSecretService {
50
50
  async getSecret(key) {
51
51
  const row = await this.secrets.findOne({ _id: key });
52
52
  if (!row)
53
- throw new Error(`Secret not found: ${key}`);
53
+ throw new Error('Requested secret not found');
54
54
  const kek = this.getKEK(row.keyVersion);
55
55
  const result = await envelopeDecrypt(kek, row.ciphertext, row.wrappedDek);
56
56
  await this.logAudit(key, 'read');
@@ -25,6 +25,7 @@ export declare class MongoDBWorkflowService extends PikkuWorkflowService {
25
25
  setStepScheduled(stepId: string): Promise<void>;
26
26
  private insertHistoryRecord;
27
27
  private getTimestampFieldForStatus;
28
+ setStepChildRunId(stepId: string, childRunId: string): Promise<void>;
28
29
  setStepResult(stepId: string, result: any): Promise<void>;
29
30
  setStepError(stepId: string, error: Error): Promise<void>;
30
31
  createRetryAttempt(stepId: string, status: 'pending' | 'running'): Promise<StepState>;
@@ -165,6 +165,14 @@ export class MongoDBWorkflowService extends PikkuWorkflowService {
165
165
  return 'createdAt';
166
166
  }
167
167
  }
168
+ async setStepChildRunId(stepId, childRunId) {
169
+ await this.steps.updateOne({ _id: stepId }, {
170
+ $set: {
171
+ childRunId,
172
+ updatedAt: new Date(),
173
+ },
174
+ });
175
+ }
168
176
  async setStepResult(stepId, result) {
169
177
  await this.steps.updateOne({ _id: stepId }, {
170
178
  $set: {
@@ -303,6 +311,9 @@ export class MongoDBWorkflowService extends PikkuWorkflowService {
303
311
  await this.steps.updateOne({ _id: stepId }, { $set: { branchTaken: branchKey, updatedAt: new Date() } });
304
312
  }
305
313
  async updateRunState(runId, name, value) {
314
+ if (!/^[a-zA-Z0-9_]+$/.test(name)) {
315
+ throw new Error('Invalid state key name');
316
+ }
306
317
  await this.runs.updateOne({ _id: runId }, {
307
318
  $set: {
308
319
  [`state.${name}`]: value,
@@ -26,7 +26,7 @@ export class PikkuMongoDB {
26
26
  }
27
27
  catch (error) {
28
28
  this.logger.error('Error connecting to MongoDB', error);
29
- process.exit(1);
29
+ throw error;
30
30
  }
31
31
  }
32
32
  async close() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikku/mongodb",
3
- "version": "0.12.1",
3
+ "version": "0.12.3",
4
4
  "author": "yasser.fadl@gmail.com",
5
5
  "license": "MIT",
6
6
  "module": "dist/src/index.js",
@@ -13,10 +13,11 @@
13
13
  "test": "bash run-tests.sh",
14
14
  "test:watch": "bash run-tests.sh --watch",
15
15
  "test:coverage": "bash run-tests.sh --coverage",
16
- "release": "npm run build && npm test"
16
+ "release": "npm run build && npm test",
17
+ "prepublishOnly": "yarn build"
17
18
  },
18
19
  "peerDependencies": {
19
- "@pikku/core": "^0.12.3"
20
+ "@pikku/core": "^0.12.9"
20
21
  },
21
22
  "dependencies": {
22
23
  "mongodb": "^6.12.0"
@@ -89,7 +89,7 @@ export class MongoDBSecretService implements SecretService {
89
89
 
90
90
  async getSecret(key: string): Promise<string> {
91
91
  const row = await this.secrets.findOne({ _id: key })
92
- if (!row) throw new Error(`Secret not found: ${key}`)
92
+ if (!row) throw new Error('Requested secret not found')
93
93
 
94
94
  const kek = this.getKEK(row.keyVersion)
95
95
  const result = await envelopeDecrypt<string>(
@@ -34,6 +34,7 @@ interface WorkflowStepDoc {
34
34
  status: string
35
35
  result: any | null
36
36
  error: any | null
37
+ childRunId?: string
37
38
  branchTaken: string | null
38
39
  retries: number | null
39
40
  retryDelay: string | null
@@ -303,6 +304,18 @@ export class MongoDBWorkflowService extends PikkuWorkflowService {
303
304
  }
304
305
  }
305
306
 
307
+ async setStepChildRunId(stepId: string, childRunId: string): Promise<void> {
308
+ await this.steps.updateOne(
309
+ { _id: stepId },
310
+ {
311
+ $set: {
312
+ childRunId,
313
+ updatedAt: new Date(),
314
+ },
315
+ }
316
+ )
317
+ }
318
+
306
319
  async setStepResult(stepId: string, result: any): Promise<void> {
307
320
  await this.steps.updateOne(
308
321
  { _id: stepId },
@@ -502,6 +515,9 @@ export class MongoDBWorkflowService extends PikkuWorkflowService {
502
515
  name: string,
503
516
  value: unknown
504
517
  ): Promise<void> {
518
+ if (!/^[a-zA-Z0-9_]+$/.test(name)) {
519
+ throw new Error('Invalid state key name')
520
+ }
505
521
  await this.runs.updateOne(
506
522
  { _id: runId },
507
523
  {
@@ -29,7 +29,7 @@ export class PikkuMongoDB {
29
29
  this.logger.info('MongoDB connection successful')
30
30
  } catch (error) {
31
31
  this.logger.error('Error connecting to MongoDB', error)
32
- process.exit(1)
32
+ throw error
33
33
  }
34
34
  }
35
35