@punks/backend-entity-manager 0.0.321 → 0.0.322

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.
@@ -1,5 +1,8 @@
1
1
  import { PipelineCompletedStepState } from "../../../../types";
2
2
  export declare class PipelineUtils<TPipelineInput, TPipelineOutput, TContext> {
3
+ getStepByKey: (step: PipelineCompletedStepState<TPipelineInput, TContext, unknown, unknown>, key: string) => PipelineCompletedStepState<TPipelineInput, TContext, unknown, unknown>;
4
+ getStepInputByKey: <TStepInput>(step: PipelineCompletedStepState<TPipelineInput, TContext, unknown, unknown>, key: string) => TStepInput;
5
+ getStepOutputByKey: <TStepOutput>(step: PipelineCompletedStepState<TPipelineInput, TContext, unknown, unknown>, key: string) => TStepOutput;
3
6
  getStep: (step: PipelineCompletedStepState<TPipelineInput, TContext, unknown, unknown>, index: number) => PipelineCompletedStepState<TPipelineInput, TContext, unknown, unknown>;
4
7
  getStepInput: <TStepInput>(step: PipelineCompletedStepState<TPipelineInput, TContext, unknown, unknown>, index: number) => TStepInput;
5
8
  getStepOutput: <TStepOutput>(step: PipelineCompletedStepState<TPipelineInput, TContext, unknown, unknown>, index: number) => TStepOutput;
@@ -1,4 +1,10 @@
1
+ export type PipelineStepReference = {
2
+ index: number;
3
+ key?: string;
4
+ name: string;
5
+ };
1
6
  export type PipelineStepState<TPipelineInput, TContext, TStepInput> = {
7
+ reference: PipelineStepReference;
2
8
  context: TContext;
3
9
  stepInput: TStepInput;
4
10
  pipelineInput: TPipelineInput;
@@ -9,6 +15,7 @@ export type PipelineCompletedStepState<TPipelineInput, TContext, TStepInput, TSt
9
15
  };
10
16
  export type PipelineCurrentStepState<TPipelineInput, TContext, TStepInput> = PipelineStepState<TPipelineInput, TContext, TStepInput> & {};
11
17
  export type OperationDefinition<TOperationInput, TOperationOutput, TCurrentStepInput, TPipelineInput, TContext> = {
18
+ key?: string;
12
19
  name: string;
13
20
  action: (input: TOperationInput, state: PipelineCurrentStepState<TPipelineInput, TContext, TCurrentStepInput>) => Promise<TOperationOutput> | TOperationOutput;
14
21
  precondition?: (input: TOperationInput, state: PipelineCurrentStepState<TPipelineInput, TContext, TCurrentStepInput>) => Promise<boolean> | boolean;
@@ -19,6 +26,7 @@ export type RollbackOperationDefinition<TOperationInput, TOperationOutput, TCurr
19
26
  action: (input: TOperationInput, output: TOperationOutput, state: PipelineCurrentStepState<TPipelineInput, TContext, TCurrentStepInput>) => Promise<void> | void;
20
27
  };
21
28
  export type PipelineStepOperation<TOperationInput, TOperationOutput, TCurrentStepInput, TPipelineInput, TContext> = {
29
+ key?: string;
22
30
  name: string;
23
31
  operation: OperationDefinition<TOperationInput, TOperationOutput, TCurrentStepInput, TPipelineInput, TContext>;
24
32
  rollbackOperations?: RollbackOperationDefinition<TOperationInput, TOperationOutput, TCurrentStepInput, TPipelineInput, TContext>[];
package/dist/esm/index.js CHANGED
@@ -2754,6 +2754,11 @@ class PipelineInstance {
2754
2754
  }
2755
2755
  buildInitialStepState() {
2756
2756
  return {
2757
+ reference: {
2758
+ index: 0,
2759
+ key: this.definition.steps[0].operations[0].key,
2760
+ name: this.definition.steps[0].operations[0].name,
2761
+ },
2757
2762
  stepInput: this.input,
2758
2763
  context: this.context,
2759
2764
  pipelineInput: this.input,
@@ -2761,10 +2766,22 @@ class PipelineInstance {
2761
2766
  }
2762
2767
  buildNextStepState(state, stepResult) {
2763
2768
  return {
2769
+ reference: {
2770
+ index: state.reference.index + 1,
2771
+ name: this.definition.steps[state.reference.index + 1]?.operations[0]
2772
+ .name,
2773
+ key: this.definition.steps[state.reference.index + 1]?.operations[0]
2774
+ .key,
2775
+ },
2764
2776
  stepInput: getStepOutput(stepResult),
2765
2777
  context: this.context,
2766
2778
  pipelineInput: this.input,
2767
2779
  previousStep: {
2780
+ reference: {
2781
+ index: state.reference.index,
2782
+ key: state.reference.key,
2783
+ name: state.reference.name,
2784
+ },
2768
2785
  stepInput: state.stepInput,
2769
2786
  stepOutput: getStepOutput(stepResult),
2770
2787
  context: this.context,
@@ -21712,24 +21729,17 @@ MediaLibraryService = __decorate([
21712
21729
  __metadata("design:paramtypes", [EntityManagerRegistry])
21713
21730
  ], MediaLibraryService);
21714
21731
 
21715
- function _typeof(obj) {
21716
- "@babel/helpers - typeof";
21717
-
21718
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
21719
- return typeof obj;
21720
- } : function (obj) {
21721
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
21722
- }, _typeof(obj);
21723
- }
21724
-
21725
21732
  function toInteger(dirtyNumber) {
21726
21733
  if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
21727
21734
  return NaN;
21728
21735
  }
21736
+
21729
21737
  var number = Number(dirtyNumber);
21738
+
21730
21739
  if (isNaN(number)) {
21731
21740
  return number;
21732
21741
  }
21742
+
21733
21743
  return number < 0 ? Math.ceil(number) : Math.floor(number);
21734
21744
  }
21735
21745
 
@@ -21769,12 +21779,12 @@ function requiredArgs(required, args) {
21769
21779
  * const result = toDate(1392098430000)
21770
21780
  * //=> Tue Feb 11 2014 11:30:30
21771
21781
  */
21782
+
21772
21783
  function toDate(argument) {
21773
21784
  requiredArgs(1, arguments);
21774
- var argStr = Object.prototype.toString.call(argument);
21785
+ var argStr = Object.prototype.toString.call(argument); // Clone the date
21775
21786
 
21776
- // Clone the date
21777
- if (argument instanceof Date || _typeof(argument) === 'object' && argStr === '[object Date]') {
21787
+ if (argument instanceof Date || typeof argument === 'object' && argStr === '[object Date]') {
21778
21788
  // Prevent the date to lose the milliseconds when passed to new Date() in IE10
21779
21789
  return new Date(argument.getTime());
21780
21790
  } else if (typeof argument === 'number' || argStr === '[object Number]') {
@@ -21782,10 +21792,11 @@ function toDate(argument) {
21782
21792
  } else {
21783
21793
  if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
21784
21794
  // eslint-disable-next-line no-console
21785
- console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments");
21786
- // eslint-disable-next-line no-console
21795
+ console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"); // eslint-disable-next-line no-console
21796
+
21787
21797
  console.warn(new Error().stack);
21788
21798
  }
21799
+
21789
21800
  return new Date(NaN);
21790
21801
  }
21791
21802
  }
@@ -21798,50 +21809,39 @@ function toDate(argument) {
21798
21809
  * @description
21799
21810
  * Add the specified number of days to the given date.
21800
21811
  *
21812
+ * ### v2.0.0 breaking changes:
21813
+ *
21814
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
21815
+ *
21801
21816
  * @param {Date|Number} date - the date to be changed
21802
21817
  * @param {Number} amount - the amount of days to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
21803
- * @returns {Date} - the new date with the days added
21804
- * @throws {TypeError} - 2 arguments required
21818
+ * @returns {Date} the new date with the days added
21819
+ * @throws {TypeError} 2 arguments required
21805
21820
  *
21806
21821
  * @example
21807
21822
  * // Add 10 days to 1 September 2014:
21808
- * const result = addDays(new Date(2014, 8, 1), 10)
21823
+ * var result = addDays(new Date(2014, 8, 1), 10)
21809
21824
  * //=> Thu Sep 11 2014 00:00:00
21810
21825
  */
21826
+
21811
21827
  function addDays(dirtyDate, dirtyAmount) {
21812
21828
  requiredArgs(2, arguments);
21813
21829
  var date = toDate(dirtyDate);
21814
21830
  var amount = toInteger(dirtyAmount);
21831
+
21815
21832
  if (isNaN(amount)) {
21816
21833
  return new Date(NaN);
21817
21834
  }
21835
+
21818
21836
  if (!amount) {
21819
21837
  // If 0 days, no-op to avoid changing times in the hour before end of DST
21820
21838
  return date;
21821
21839
  }
21840
+
21822
21841
  date.setDate(date.getDate() + amount);
21823
21842
  return date;
21824
21843
  }
21825
21844
 
21826
- /**
21827
- * Days in 1 week.
21828
- *
21829
- * @name daysInWeek
21830
- * @constant
21831
- * @type {number}
21832
- * @default
21833
- */
21834
-
21835
- /**
21836
- * Milliseconds in 1 minute
21837
- *
21838
- * @name millisecondsInMinute
21839
- * @constant
21840
- * @type {number}
21841
- * @default
21842
- */
21843
- var millisecondsInMinute = 60000;
21844
-
21845
21845
  /**
21846
21846
  * @name differenceInMilliseconds
21847
21847
  * @category Millisecond Helpers
@@ -21850,6 +21850,10 @@ var millisecondsInMinute = 60000;
21850
21850
  * @description
21851
21851
  * Get the number of milliseconds between the given dates.
21852
21852
  *
21853
+ * ### v2.0.0 breaking changes:
21854
+ *
21855
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
21856
+ *
21853
21857
  * @param {Date|Number} dateLeft - the later date
21854
21858
  * @param {Date|Number} dateRight - the earlier date
21855
21859
  * @returns {Number} the number of milliseconds
@@ -21858,31 +21862,21 @@ var millisecondsInMinute = 60000;
21858
21862
  * @example
21859
21863
  * // How many milliseconds are between
21860
21864
  * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?
21861
- * const result = differenceInMilliseconds(
21865
+ * var result = differenceInMilliseconds(
21862
21866
  * new Date(2014, 6, 2, 12, 30, 21, 700),
21863
21867
  * new Date(2014, 6, 2, 12, 30, 20, 600)
21864
21868
  * )
21865
21869
  * //=> 1100
21866
21870
  */
21867
- function differenceInMilliseconds(dateLeft, dateRight) {
21868
- requiredArgs(2, arguments);
21869
- return toDate(dateLeft).getTime() - toDate(dateRight).getTime();
21870
- }
21871
21871
 
21872
- var roundingMap = {
21873
- ceil: Math.ceil,
21874
- round: Math.round,
21875
- floor: Math.floor,
21876
- trunc: function trunc(value) {
21877
- return value < 0 ? Math.ceil(value) : Math.floor(value);
21878
- } // Math.trunc is not supported by IE
21879
- };
21880
-
21881
- var defaultRoundingMethod = 'trunc';
21882
- function getRoundingMethod(method) {
21883
- return method ? roundingMap[method] : roundingMap[defaultRoundingMethod];
21872
+ function differenceInMilliseconds(dirtyDateLeft, dirtyDateRight) {
21873
+ requiredArgs(2, arguments);
21874
+ var dateLeft = toDate(dirtyDateLeft);
21875
+ var dateRight = toDate(dirtyDateRight);
21876
+ return dateLeft.getTime() - dateRight.getTime();
21884
21877
  }
21885
21878
 
21879
+ var MILLISECONDS_IN_MINUTE = 60000;
21886
21880
  /**
21887
21881
  * @name differenceInMinutes
21888
21882
  * @category Minute Helpers
@@ -21891,33 +21885,36 @@ function getRoundingMethod(method) {
21891
21885
  * @description
21892
21886
  * Get the signed number of full (rounded towards 0) minutes between the given dates.
21893
21887
  *
21888
+ * ### v2.0.0 breaking changes:
21889
+ *
21890
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
21891
+ *
21894
21892
  * @param {Date|Number} dateLeft - the later date
21895
21893
  * @param {Date|Number} dateRight - the earlier date
21896
- * @param {Object} [options] - an object with options.
21897
- * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)
21898
21894
  * @returns {Number} the number of minutes
21899
21895
  * @throws {TypeError} 2 arguments required
21900
21896
  *
21901
21897
  * @example
21902
21898
  * // How many minutes are between 2 July 2014 12:07:59 and 2 July 2014 12:20:00?
21903
- * const result = differenceInMinutes(
21899
+ * var result = differenceInMinutes(
21904
21900
  * new Date(2014, 6, 2, 12, 20, 0),
21905
21901
  * new Date(2014, 6, 2, 12, 7, 59)
21906
21902
  * )
21907
21903
  * //=> 12
21908
21904
  *
21909
21905
  * @example
21910
- * // How many minutes are between 10:01:59 and 10:00:00
21911
- * const result = differenceInMinutes(
21906
+ * // How many minutes are from 10:01:59 to 10:00:00
21907
+ * var result = differenceInMinutes(
21912
21908
  * new Date(2000, 0, 1, 10, 0, 0),
21913
21909
  * new Date(2000, 0, 1, 10, 1, 59)
21914
21910
  * )
21915
21911
  * //=> -1
21916
21912
  */
21917
- function differenceInMinutes(dateLeft, dateRight, options) {
21913
+
21914
+ function differenceInMinutes(dirtyDateLeft, dirtyDateRight) {
21918
21915
  requiredArgs(2, arguments);
21919
- var diff = differenceInMilliseconds(dateLeft, dateRight) / millisecondsInMinute;
21920
- return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);
21916
+ var diff = differenceInMilliseconds(dirtyDateLeft, dirtyDateRight) / MILLISECONDS_IN_MINUTE;
21917
+ return diff > 0 ? Math.floor(diff) : Math.ceil(diff);
21921
21918
  }
21922
21919
 
21923
21920
  /**
@@ -21928,6 +21925,10 @@ function differenceInMinutes(dateLeft, dateRight, options) {
21928
21925
  * @description
21929
21926
  * Subtract the specified number of days from the given date.
21930
21927
  *
21928
+ * ### v2.0.0 breaking changes:
21929
+ *
21930
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
21931
+ *
21931
21932
  * @param {Date|Number} date - the date to be changed
21932
21933
  * @param {Number} amount - the amount of days to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
21933
21934
  * @returns {Date} the new date with the days subtracted
@@ -21935,9 +21936,10 @@ function differenceInMinutes(dateLeft, dateRight, options) {
21935
21936
  *
21936
21937
  * @example
21937
21938
  * // Subtract 10 days from 1 September 2014:
21938
- * const result = subDays(new Date(2014, 8, 1), 10)
21939
+ * var result = subDays(new Date(2014, 8, 1), 10)
21939
21940
  * //=> Fri Aug 22 2014 00:00:00
21940
21941
  */
21942
+
21941
21943
  function subDays(dirtyDate, dirtyAmount) {
21942
21944
  requiredArgs(2, arguments);
21943
21945
  var amount = toInteger(dirtyAmount);
@@ -34302,6 +34304,20 @@ const buildCompletedStepsSequence = (step) => {
34302
34304
  };
34303
34305
  class PipelineUtils {
34304
34306
  constructor() {
34307
+ this.getStepByKey = (step, key) => {
34308
+ const sequence = buildCompletedStepsSequence(step);
34309
+ const matchingStep = sequence.find((x) => x.reference.key === key);
34310
+ if (!matchingStep) {
34311
+ throw new Error(`Step key ${key} not found`);
34312
+ }
34313
+ return matchingStep;
34314
+ };
34315
+ this.getStepInputByKey = (step, key) => {
34316
+ return this.getStepByKey(step, key).stepInput;
34317
+ };
34318
+ this.getStepOutputByKey = (step, key) => {
34319
+ return this.getStepByKey(step, key).stepOutput;
34320
+ };
34305
34321
  this.getStep = (step, index) => {
34306
34322
  const sequence = buildCompletedStepsSequence(step);
34307
34323
  if (index >= sequence.length) {