@punks/backend-entity-manager 0.0.310 → 0.0.311

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.
@@ -4,6 +4,7 @@ export interface JobDispatchInput {
4
4
  schedule?: JobSchedule<unknown>;
5
5
  instanceId: string;
6
6
  payload?: unknown;
7
+ commandPlaceholders?: Record<string, string>;
7
8
  }
8
9
  export declare enum JobProviderState {
9
10
  Initializing = "initializing",
package/dist/esm/index.js CHANGED
@@ -40231,18 +40231,20 @@ const mapJobStatus = (awsJobStatus) => {
40231
40231
  return JobProviderState.Completed;
40232
40232
  }
40233
40233
  };
40234
+ const replacePayload = (command, payload) => command.replaceAll("$(payload)", JSON.stringify(payload ?? {}));
40235
+ const replacePlaceholders = (command, placeholders) => Object.entries(placeholders ?? {}).reduce((acc, [key, value]) => acc.replaceAll(`$(${key})`, value), command);
40234
40236
  let AwsJobsProvider = class AwsJobsProvider {
40235
40237
  constructor(awsBatchService) {
40236
40238
  this.awsBatchService = awsBatchService;
40237
40239
  }
40238
40240
  async dispatch(input) {
40239
- const { definition, schedule, instanceId, payload } = input;
40241
+ const { definition, schedule, instanceId, payload, commandPlaceholders } = input;
40240
40242
  const awsInvocationParams = schedule?.invocationOverrides;
40241
40243
  await this.awsBatchService.submitJob({
40242
40244
  instanceId,
40243
40245
  jobUid: definition.uid,
40244
40246
  overrides: {
40245
- command: awsInvocationParams?.startCommand?.map((x) => x.replace("{payload}", JSON.stringify(payload ?? {}))),
40247
+ command: awsInvocationParams?.startCommand?.map((x) => replacePlaceholders(replacePayload(x, payload), commandPlaceholders)),
40246
40248
  },
40247
40249
  });
40248
40250
  }