@expo/steps 0.0.9 → 0.0.10

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.
Files changed (87) hide show
  1. package/dist_commonjs/BuildConfig.cjs +3 -3
  2. package/dist_commonjs/BuildConfig.js.map +1 -1
  3. package/dist_commonjs/BuildConfigParser.cjs +55 -42
  4. package/dist_commonjs/BuildConfigParser.d.ts +5 -1
  5. package/dist_commonjs/BuildConfigParser.js.map +1 -1
  6. package/dist_commonjs/BuildFunction.cjs +9 -3
  7. package/dist_commonjs/BuildFunction.js.map +1 -1
  8. package/dist_commonjs/BuildStep.cjs +32 -24
  9. package/dist_commonjs/BuildStep.d.ts +9 -3
  10. package/dist_commonjs/BuildStep.js.map +1 -1
  11. package/dist_commonjs/BuildStepContext.cjs +2 -2
  12. package/dist_commonjs/BuildStepContext.js.map +1 -1
  13. package/dist_commonjs/BuildStepInput.cjs +6 -6
  14. package/dist_commonjs/BuildStepInput.d.ts +3 -3
  15. package/dist_commonjs/BuildStepInput.js.map +1 -1
  16. package/dist_commonjs/BuildStepOutput.cjs +6 -6
  17. package/dist_commonjs/BuildStepOutput.d.ts +4 -4
  18. package/dist_commonjs/BuildStepOutput.js.map +1 -1
  19. package/dist_commonjs/BuildWorkflowValidator.cjs +16 -17
  20. package/dist_commonjs/BuildWorkflowValidator.js.map +1 -1
  21. package/dist_commonjs/errors.cjs +30 -0
  22. package/dist_commonjs/errors.d.ts +24 -0
  23. package/dist_commonjs/errors.js.map +1 -0
  24. package/dist_commonjs/index.cjs +27 -1
  25. package/dist_commonjs/index.d.ts +2 -0
  26. package/dist_commonjs/index.js.map +1 -1
  27. package/dist_commonjs/utils/template.cjs +2 -2
  28. package/dist_commonjs/utils/template.js.map +1 -1
  29. package/dist_esm/BuildConfig.js +1 -1
  30. package/dist_esm/BuildConfig.js.map +1 -1
  31. package/dist_esm/BuildConfigParser.d.ts +5 -1
  32. package/dist_esm/BuildConfigParser.js +54 -41
  33. package/dist_esm/BuildConfigParser.js.map +1 -1
  34. package/dist_esm/BuildFunction.js +9 -3
  35. package/dist_esm/BuildFunction.js.map +1 -1
  36. package/dist_esm/BuildStep.d.ts +9 -3
  37. package/dist_esm/BuildStep.js +31 -23
  38. package/dist_esm/BuildStep.js.map +1 -1
  39. package/dist_esm/BuildStepContext.js +1 -1
  40. package/dist_esm/BuildStepContext.js.map +1 -1
  41. package/dist_esm/BuildStepInput.d.ts +3 -3
  42. package/dist_esm/BuildStepInput.js +6 -6
  43. package/dist_esm/BuildStepInput.js.map +1 -1
  44. package/dist_esm/BuildStepOutput.d.ts +4 -4
  45. package/dist_esm/BuildStepOutput.js +6 -6
  46. package/dist_esm/BuildStepOutput.js.map +1 -1
  47. package/dist_esm/BuildWorkflowValidator.js +15 -16
  48. package/dist_esm/BuildWorkflowValidator.js.map +1 -1
  49. package/dist_esm/errors.d.ts +24 -0
  50. package/dist_esm/errors.js +23 -0
  51. package/dist_esm/errors.js.map +1 -0
  52. package/dist_esm/index.d.ts +2 -0
  53. package/dist_esm/index.js +2 -0
  54. package/dist_esm/index.js.map +1 -1
  55. package/dist_esm/utils/template.js +1 -1
  56. package/dist_esm/utils/template.js.map +1 -1
  57. package/package.json +1 -1
  58. package/dist_commonjs/errors/BuildConfigError.cjs +0 -8
  59. package/dist_commonjs/errors/BuildConfigError.d.ts +0 -3
  60. package/dist_commonjs/errors/BuildConfigError.js.map +0 -1
  61. package/dist_commonjs/errors/BuildInternalError.cjs +0 -7
  62. package/dist_commonjs/errors/BuildInternalError.d.ts +0 -2
  63. package/dist_commonjs/errors/BuildInternalError.js.map +0 -1
  64. package/dist_commonjs/errors/BuildStepRuntimeError.cjs +0 -8
  65. package/dist_commonjs/errors/BuildStepRuntimeError.d.ts +0 -3
  66. package/dist_commonjs/errors/BuildStepRuntimeError.js.map +0 -1
  67. package/dist_commonjs/errors/BuildWorkflowError.cjs +0 -13
  68. package/dist_commonjs/errors/BuildWorkflowError.d.ts +0 -10
  69. package/dist_commonjs/errors/BuildWorkflowError.js.map +0 -1
  70. package/dist_commonjs/errors/UserError.cjs +0 -14
  71. package/dist_commonjs/errors/UserError.d.ts +0 -9
  72. package/dist_commonjs/errors/UserError.js.map +0 -1
  73. package/dist_esm/errors/BuildConfigError.d.ts +0 -3
  74. package/dist_esm/errors/BuildConfigError.js +0 -4
  75. package/dist_esm/errors/BuildConfigError.js.map +0 -1
  76. package/dist_esm/errors/BuildInternalError.d.ts +0 -2
  77. package/dist_esm/errors/BuildInternalError.js +0 -3
  78. package/dist_esm/errors/BuildInternalError.js.map +0 -1
  79. package/dist_esm/errors/BuildStepRuntimeError.d.ts +0 -3
  80. package/dist_esm/errors/BuildStepRuntimeError.js +0 -4
  81. package/dist_esm/errors/BuildStepRuntimeError.js.map +0 -1
  82. package/dist_esm/errors/BuildWorkflowError.d.ts +0 -10
  83. package/dist_esm/errors/BuildWorkflowError.js +0 -9
  84. package/dist_esm/errors/BuildWorkflowError.js.map +0 -1
  85. package/dist_esm/errors/UserError.d.ts +0 -9
  86. package/dist_esm/errors/UserError.js +0 -10
  87. package/dist_esm/errors/UserError.js.map +0 -1
@@ -1,19 +1,19 @@
1
1
  import { BuildStepContext } from './BuildStepContext.js';
2
2
  export type BuildStepOutputById = Record<string, BuildStepOutput>;
3
- export type BuildStepOutputProvider = (ctx: BuildStepContext, stepId: string) => BuildStepOutput;
3
+ export type BuildStepOutputProvider = (ctx: BuildStepContext, stepDisplayName: string) => BuildStepOutput;
4
4
  export declare class BuildStepOutput {
5
5
  private readonly ctx;
6
6
  readonly id: string;
7
- readonly stepId: string;
7
+ readonly stepDisplayName: string;
8
8
  readonly required: boolean;
9
9
  private _value?;
10
10
  static createProvider(params: {
11
11
  id: string;
12
12
  required?: boolean;
13
13
  }): BuildStepOutputProvider;
14
- constructor(ctx: BuildStepContext, { id, stepId, required }: {
14
+ constructor(ctx: BuildStepContext, { id, stepDisplayName, required, }: {
15
15
  id: string;
16
- stepId: string;
16
+ stepDisplayName: string;
17
17
  required?: boolean;
18
18
  });
19
19
  get value(): string | undefined;
@@ -1,25 +1,25 @@
1
- import { BuildStepRuntimeError } from './errors/BuildStepRuntimeError.js';
1
+ import { BuildStepRuntimeError } from './errors.js';
2
2
  export class BuildStepOutput {
3
3
  static createProvider(params) {
4
- return (ctx, stepId) => new BuildStepOutput(ctx, { ...params, stepId });
4
+ return (ctx, stepDisplayName) => new BuildStepOutput(ctx, { ...params, stepDisplayName });
5
5
  }
6
6
  constructor(
7
7
  // @ts-expect-error ctx is not used in this class but let's keep it here for consistency
8
- ctx, { id, stepId, required = true }) {
8
+ ctx, { id, stepDisplayName, required = true, }) {
9
9
  this.ctx = ctx;
10
10
  this.id = id;
11
- this.stepId = stepId;
11
+ this.stepDisplayName = stepDisplayName;
12
12
  this.required = required;
13
13
  }
14
14
  get value() {
15
15
  if (this.required && this._value === undefined) {
16
- throw new BuildStepRuntimeError(`Output parameter "${this.id}" for step "${this.stepId}" is required but it was not set.`);
16
+ throw new BuildStepRuntimeError(`Output parameter "${this.id}" for step "${this.stepDisplayName}" is required but it was not set.`);
17
17
  }
18
18
  return this._value;
19
19
  }
20
20
  set(value) {
21
21
  if (this.required && value === undefined) {
22
- throw new BuildStepRuntimeError(`Output parameter "${this.id}" for step "${this.stepId}" is required.`);
22
+ throw new BuildStepRuntimeError(`Output parameter "${this.id}" for step "${this.stepDisplayName}" is required.`);
23
23
  }
24
24
  this._value = value;
25
25
  return this;
@@ -1 +1 @@
1
- {"version":3,"file":"BuildStepOutput.js","sourceRoot":"","sources":["../src/BuildStepOutput.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAK1E,MAAM,OAAO,eAAe;IAOnB,MAAM,CAAC,cAAc,CAAC,MAG5B;QACC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,GAAG,EAAE,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED;IACE,wFAAwF;IACvE,GAAqB,EACtC,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI,EAAsD;QADlE,QAAG,GAAH,GAAG,CAAkB;QAGtC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,IAAI,KAAK;QACP,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;YAC9C,MAAM,IAAI,qBAAqB,CAC7B,qBAAqB,IAAI,CAAC,EAAE,eAAe,IAAI,CAAC,MAAM,mCAAmC,CAC1F,CAAC;SACH;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,GAAG,CAAC,KAAyB;QAC3B,IAAI,IAAI,CAAC,QAAQ,IAAI,KAAK,KAAK,SAAS,EAAE;YACxC,MAAM,IAAI,qBAAqB,CAC7B,qBAAqB,IAAI,CAAC,EAAE,eAAe,IAAI,CAAC,MAAM,gBAAgB,CACvE,CAAC;SACH;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED,MAAM,UAAU,0BAA0B,CAAC,OAA2B;IACpE,IAAI,OAAO,KAAK,SAAS,EAAE;QACzB,OAAO,EAAE,CAAC;KACX;IACD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;QACpC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC;QACxB,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAyB,CAAC,CAAC;AAChC,CAAC","sourcesContent":["import { BuildStepContext } from './BuildStepContext.js';\nimport { BuildStepRuntimeError } from './errors/BuildStepRuntimeError.js';\n\nexport type BuildStepOutputById = Record<string, BuildStepOutput>;\nexport type BuildStepOutputProvider = (ctx: BuildStepContext, stepId: string) => BuildStepOutput;\n\nexport class BuildStepOutput {\n public readonly id: string;\n public readonly stepId: string;\n public readonly required: boolean;\n\n private _value?: string;\n\n public static createProvider(params: {\n id: string;\n required?: boolean;\n }): BuildStepOutputProvider {\n return (ctx, stepId) => new BuildStepOutput(ctx, { ...params, stepId });\n }\n\n constructor(\n // @ts-expect-error ctx is not used in this class but let's keep it here for consistency\n private readonly ctx: BuildStepContext,\n { id, stepId, required = true }: { id: string; stepId: string; required?: boolean }\n ) {\n this.id = id;\n this.stepId = stepId;\n this.required = required;\n }\n\n get value(): string | undefined {\n if (this.required && this._value === undefined) {\n throw new BuildStepRuntimeError(\n `Output parameter \"${this.id}\" for step \"${this.stepId}\" is required but it was not set.`\n );\n }\n return this._value;\n }\n\n set(value: string | undefined): BuildStepOutput {\n if (this.required && value === undefined) {\n throw new BuildStepRuntimeError(\n `Output parameter \"${this.id}\" for step \"${this.stepId}\" is required.`\n );\n }\n this._value = value;\n return this;\n }\n}\n\nexport function makeBuildStepOutputByIdMap(outputs?: BuildStepOutput[]): BuildStepOutputById {\n if (outputs === undefined) {\n return {};\n }\n return outputs.reduce((acc, output) => {\n acc[output.id] = output;\n return acc;\n }, {} as BuildStepOutputById);\n}\n"]}
1
+ {"version":3,"file":"BuildStepOutput.js","sourceRoot":"","sources":["../src/BuildStepOutput.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAQpD,MAAM,OAAO,eAAe;IAOnB,MAAM,CAAC,cAAc,CAAC,MAG5B;QACC,OAAO,CAAC,GAAG,EAAE,eAAe,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,GAAG,EAAE,EAAE,GAAG,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC;IAC5F,CAAC;IAED;IACE,wFAAwF;IACvE,GAAqB,EACtC,EACE,EAAE,EACF,eAAe,EACf,QAAQ,GAAG,IAAI,GAC6C;QAL7C,QAAG,GAAH,GAAG,CAAkB;QAOtC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,IAAI,KAAK;QACP,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;YAC9C,MAAM,IAAI,qBAAqB,CAC7B,qBAAqB,IAAI,CAAC,EAAE,eAAe,IAAI,CAAC,eAAe,mCAAmC,CACnG,CAAC;SACH;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,GAAG,CAAC,KAAyB;QAC3B,IAAI,IAAI,CAAC,QAAQ,IAAI,KAAK,KAAK,SAAS,EAAE;YACxC,MAAM,IAAI,qBAAqB,CAC7B,qBAAqB,IAAI,CAAC,EAAE,eAAe,IAAI,CAAC,eAAe,gBAAgB,CAChF,CAAC;SACH;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED,MAAM,UAAU,0BAA0B,CAAC,OAA2B;IACpE,IAAI,OAAO,KAAK,SAAS,EAAE;QACzB,OAAO,EAAE,CAAC;KACX;IACD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;QACpC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC;QACxB,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAyB,CAAC,CAAC;AAChC,CAAC","sourcesContent":["import { BuildStepContext } from './BuildStepContext.js';\nimport { BuildStepRuntimeError } from './errors.js';\n\nexport type BuildStepOutputById = Record<string, BuildStepOutput>;\nexport type BuildStepOutputProvider = (\n ctx: BuildStepContext,\n stepDisplayName: string\n) => BuildStepOutput;\n\nexport class BuildStepOutput {\n public readonly id: string;\n public readonly stepDisplayName: string;\n public readonly required: boolean;\n\n private _value?: string;\n\n public static createProvider(params: {\n id: string;\n required?: boolean;\n }): BuildStepOutputProvider {\n return (ctx, stepDisplayName) => new BuildStepOutput(ctx, { ...params, stepDisplayName });\n }\n\n constructor(\n // @ts-expect-error ctx is not used in this class but let's keep it here for consistency\n private readonly ctx: BuildStepContext,\n {\n id,\n stepDisplayName,\n required = true,\n }: { id: string; stepDisplayName: string; required?: boolean }\n ) {\n this.id = id;\n this.stepDisplayName = stepDisplayName;\n this.required = required;\n }\n\n get value(): string | undefined {\n if (this.required && this._value === undefined) {\n throw new BuildStepRuntimeError(\n `Output parameter \"${this.id}\" for step \"${this.stepDisplayName}\" is required but it was not set.`\n );\n }\n return this._value;\n }\n\n set(value: string | undefined): BuildStepOutput {\n if (this.required && value === undefined) {\n throw new BuildStepRuntimeError(\n `Output parameter \"${this.id}\" for step \"${this.stepDisplayName}\" is required.`\n );\n }\n this._value = value;\n return this;\n }\n}\n\nexport function makeBuildStepOutputByIdMap(outputs?: BuildStepOutput[]): BuildStepOutputById {\n if (outputs === undefined) {\n return {};\n }\n return outputs.reduce((acc, output) => {\n acc[output.id] = output;\n return acc;\n }, {} as BuildStepOutputById);\n}\n"]}
@@ -1,5 +1,4 @@
1
- import { BuildConfigError } from './errors/BuildConfigError.js';
2
- import { BuildWorkflowError } from './errors/BuildWorkflowError.js';
1
+ import { BuildConfigError, BuildWorkflowError } from './errors.js';
3
2
  import { duplicates } from './utils/expodash/duplicates.js';
4
3
  import { findOutputPaths } from './utils/template.js';
5
4
  export class BuildWorkflowValidator {
@@ -11,7 +10,7 @@ export class BuildWorkflowValidator {
11
10
  errors.push(...this.validateUniqueStepIds());
12
11
  errors.push(...this.validateInputs());
13
12
  if (errors.length !== 0) {
14
- throw new BuildWorkflowError('Build workflow is invalid', errors);
13
+ throw new BuildWorkflowError('Build workflow is invalid.', errors);
15
14
  }
16
15
  }
17
16
  validateUniqueStepIds() {
@@ -29,33 +28,33 @@ export class BuildWorkflowValidator {
29
28
  var _a;
30
29
  const errors = [];
31
30
  const allStepIds = new Set(this.workflow.buildSteps.map((s) => s.id));
32
- const stepByStepId = {};
33
- for (const step of this.workflow.buildSteps) {
34
- for (const input of (_a = step.inputs) !== null && _a !== void 0 ? _a : []) {
35
- if (input.defaultValue === undefined) {
31
+ const visitedStepByStepId = {};
32
+ for (const currentStep of this.workflow.buildSteps) {
33
+ for (const currentStepInput of (_a = currentStep.inputs) !== null && _a !== void 0 ? _a : []) {
34
+ if (currentStepInput.defaultValue === undefined) {
36
35
  continue;
37
36
  }
38
- const paths = findOutputPaths(input.defaultValue);
39
- for (const { stepId, outputId } of paths) {
40
- if (!(stepId in stepByStepId)) {
41
- if (allStepIds.has(stepId)) {
42
- const error = new BuildConfigError(`Input parameter "${input.id}" for step "${step.id}" uses an expression that references an output parameter from the future step "${stepId}".`);
37
+ const paths = findOutputPaths(currentStepInput.defaultValue);
38
+ for (const { stepId: referencedStepId, outputId: referencedStepOutputId } of paths) {
39
+ if (!(referencedStepId in visitedStepByStepId)) {
40
+ if (allStepIds.has(referencedStepId)) {
41
+ const error = new BuildConfigError(`Input parameter "${currentStepInput.id}" for step "${currentStep.displayName}" uses an expression that references an output parameter from the future step "${referencedStepId}".`);
43
42
  errors.push(error);
44
43
  }
45
44
  else {
46
- const error = new BuildConfigError(`Input parameter "${input.id}" for step "${step.id}" uses an expression that references an output parameter from a non-existent step "${stepId}".`);
45
+ const error = new BuildConfigError(`Input parameter "${currentStepInput.id}" for step "${currentStep.displayName}" uses an expression that references an output parameter from a non-existent step "${referencedStepId}".`);
47
46
  errors.push(error);
48
47
  }
49
48
  }
50
49
  else {
51
- if (!stepByStepId[stepId].hasOutputParameter(outputId)) {
52
- const error = new BuildConfigError(`Input parameter "${input.id}" for step "${step.id}" uses an expression that references an undefined output parameter "${outputId}" from step "${stepId}".`);
50
+ if (!visitedStepByStepId[referencedStepId].hasOutputParameter(referencedStepOutputId)) {
51
+ const error = new BuildConfigError(`Input parameter "${currentStepInput.id}" for step "${currentStep.displayName}" uses an expression that references an undefined output parameter "${referencedStepOutputId}" from step "${referencedStepId}".`);
53
52
  errors.push(error);
54
53
  }
55
54
  }
56
55
  }
57
56
  }
58
- stepByStepId[step.id] = step;
57
+ visitedStepByStepId[currentStep.id] = currentStep;
59
58
  }
60
59
  return errors;
61
60
  }
@@ -1 +1 @@
1
- {"version":3,"file":"BuildWorkflowValidator.js","sourceRoot":"","sources":["../src/BuildWorkflowValidator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,OAAO,sBAAsB;IACjC,YAA6B,QAAuB;QAAvB,aAAQ,GAAR,QAAQ,CAAe;IAAG,CAAC;IAEjD,QAAQ;QACb,MAAM,MAAM,GAAuB,EAAE,CAAC;QACtC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAC;QAC7C,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;QACtC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACvB,MAAM,IAAI,kBAAkB,CAAC,2BAA2B,EAAE,MAAM,CAAC,CAAC;SACnE;IACH,CAAC;IAEO,qBAAqB;QAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;QAC7D,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;QAC9C,IAAI,iBAAiB,CAAC,MAAM,KAAK,CAAC,EAAE;YAClC,OAAO,EAAE,CAAC;SACX;aAAM;YACL,MAAM,KAAK,GA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,CAAC;4BACF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;yBACpB;qBACF;yBAAM;wBACL,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,EAAE;4BACtD,MAAM,KAAK,GAAG,IAAI,gBAAgB,CAChC,oBAAoB,KAAK,CAAC,EAAE,eAAe,IAAI,CAAC,EAAE,uEAAuE,QAAQ,gBAAgB,MAAM,IAAI,CAC5J,CAAC;4BACF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;yBACpB;qBACF;iBACF;aACF;YACD,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;SAC9B;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { BuildStep } from './BuildStep.js';\nimport { BuildWorkflow } from './BuildWorkflow.js';\nimport { BuildConfigError } from './errors/BuildConfigError.js';\nimport { BuildWorkflowError } from './errors/BuildWorkflowError.js';\nimport { duplicates } from './utils/expodash/duplicates.js';\nimport { findOutputPaths } from './utils/template.js';\n\nexport class BuildWorkflowValidator {\n constructor(private readonly workflow: BuildWorkflow) {}\n\n public validate(): void {\n const errors: BuildConfigError[] = [];\n errors.push(...this.validateUniqueStepIds());\n errors.push(...this.validateInputs());\n if (errors.length !== 0) {\n throw new BuildWorkflowError('Build workflow is invalid', errors);\n }\n }\n\n private validateUniqueStepIds(): BuildConfigError[] {\n const stepIds = this.workflow.buildSteps.map(({ id }) => id);\n const duplicatedStepIds = duplicates(stepIds);\n if (duplicatedStepIds.length === 0) {\n return [];\n } else {\n const error = new BuildConfigError(\n `Duplicated step IDs: ${duplicatedStepIds.map((i) => `\"${i}\"`).join(', ')}`\n );\n return [error];\n }\n }\n\n private validateInputs(): BuildConfigError[] {\n const errors: BuildConfigError[] = [];\n\n const allStepIds = new Set(this.workflow.buildSteps.map((s) => s.id));\n const stepByStepId: Record<string, BuildStep> = {};\n for (const step of this.workflow.buildSteps) {\n for (const input of step.inputs ?? []) {\n if (input.defaultValue === undefined) {\n continue;\n }\n const paths = findOutputPaths(input.defaultValue);\n for (const { stepId, outputId } of paths) {\n if (!(stepId in stepByStepId)) {\n if (allStepIds.has(stepId)) {\n const error = new BuildConfigError(\n `Input parameter \"${input.id}\" for step \"${step.id}\" uses an expression that references an output parameter from the future step \"${stepId}\".`\n );\n errors.push(error);\n } else {\n const error = new BuildConfigError(\n `Input parameter \"${input.id}\" for step \"${step.id}\" uses an expression that references an output parameter from a non-existent step \"${stepId}\".`\n );\n errors.push(error);\n }\n } else {\n if (!stepByStepId[stepId].hasOutputParameter(outputId)) {\n const error = new BuildConfigError(\n `Input parameter \"${input.id}\" for step \"${step.id}\" uses an expression that references an undefined output parameter \"${outputId}\" from step \"${stepId}\".`\n );\n errors.push(error);\n }\n }\n }\n }\n stepByStepId[step.id] = step;\n }\n\n return errors;\n }\n}\n"]}
1
+ {"version":3,"file":"BuildWorkflowValidator.js","sourceRoot":"","sources":["../src/BuildWorkflowValidator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,OAAO,sBAAsB;IACjC,YAA6B,QAAuB;QAAvB,aAAQ,GAAR,QAAQ,CAAe;IAAG,CAAC;IAEjD,QAAQ;QACb,MAAM,MAAM,GAAuB,EAAE,CAAC;QACtC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAC;QAC7C,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;QACtC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACvB,MAAM,IAAI,kBAAkB,CAAC,4BAA4B,EAAE,MAAM,CAAC,CAAC;SACpE;I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AC9C,IAAI,UAAU,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE;4BACpC,MAAM,KAAK,GAAG,IAAI,gBAAgB,CAChC,oBAAoB,gBAAgB,CAAC,EAAE,eAAe,WAAW,CAAC,WAAW,kFAAkF,gBAAgB,IAAI,CACpL,CAAC;4BACF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;yBACpB;6BAAM;4BACL,MAAM,KAAK,GAAG,IAAI,gBAAgB,CAChC,oBAAoB,gBAAgB,CAAC,EAAE,eAAe,WAAW,CAAC,WAAW,sFAAsF,gBAAgB,IAAI,CACxL,CAAC;4BACF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;yBACpB;qBACF;yBAAM;wBACL,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC,kBAAkB,CAAC,sBAAsB,CAAC,EAAE;4BACrF,MAAM,KAAK,GAAG,IAAI,gBAAgB,CAChC,oBAAoB,gBAAgB,CAAC,EAAE,eAAe,WAAW,CAAC,WAAW,uEAAuE,sBAAsB,gBAAgB,gBAAgB,IAAI,CAC/M,CAAC;4BACF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;yBACpB;qBACF;iBACF;aACF;YACD,mBAAmB,CAAC,WAAW,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC;SACnD;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { BuildStep } from './BuildStep.js';\nimport { BuildWorkflow } from './BuildWorkflow.js';\nimport { BuildConfigError, BuildWorkflowError } from './errors.js';\nimport { duplicates } from './utils/expodash/duplicates.js';\nimport { findOutputPaths } from './utils/template.js';\n\nexport class BuildWorkflowValidator {\n constructor(private readonly workflow: BuildWorkflow) {}\n\n public validate(): void {\n const errors: BuildConfigError[] = [];\n errors.push(...this.validateUniqueStepIds());\n errors.push(...this.validateInputs());\n if (errors.length !== 0) {\n throw new BuildWorkflowError('Build workflow is invalid.', errors);\n }\n }\n\n private validateUniqueStepIds(): BuildConfigError[] {\n const stepIds = this.workflow.buildSteps.map(({ id }) => id);\n const duplicatedStepIds = duplicates(stepIds);\n if (duplicatedStepIds.length === 0) {\n return [];\n } else {\n const error = new BuildConfigError(\n `Duplicated step IDs: ${duplicatedStepIds.map((i) => `\"${i}\"`).join(', ')}`\n );\n return [error];\n }\n }\n\n private validateInputs(): BuildConfigError[] {\n const errors: BuildConfigError[] = [];\n\n const allStepIds = new Set(this.workflow.buildSteps.map((s) => s.id));\n const visitedStepByStepId: Record<string, BuildStep> = {};\n for (const currentStep of this.workflow.buildSteps) {\n for (const currentStepInput of currentStep.inputs ?? []) {\n if (currentStepInput.defaultValue === undefined) {\n continue;\n }\n const paths = findOutputPaths(currentStepInput.defaultValue);\n for (const { stepId: referencedStepId, outputId: referencedStepOutputId } of paths) {\n if (!(referencedStepId in visitedStepByStepId)) {\n if (allStepIds.has(referencedStepId)) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" uses an expression that references an output parameter from the future step \"${referencedStepId}\".`\n );\n errors.push(error);\n } else {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" uses an expression that references an output parameter from a non-existent step \"${referencedStepId}\".`\n );\n errors.push(error);\n }\n } else {\n if (!visitedStepByStepId[referencedStepId].hasOutputParameter(referencedStepOutputId)) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" uses an expression that references an undefined output parameter \"${referencedStepOutputId}\" from step \"${referencedStepId}\".`\n );\n errors.push(error);\n }\n }\n }\n }\n visitedStepByStepId[currentStep.id] = currentStep;\n }\n\n return errors;\n }\n}\n"]}
@@ -0,0 +1,24 @@
1
+ declare abstract class UserError extends Error {
2
+ readonly message: string;
3
+ readonly cause?: Error;
4
+ readonly metadata: object;
5
+ constructor(message: string, extra?: {
6
+ metadata?: object;
7
+ cause?: Error;
8
+ });
9
+ }
10
+ export declare class BuildConfigError extends UserError {
11
+ }
12
+ export declare class BuildInternalError extends Error {
13
+ }
14
+ export declare class BuildStepRuntimeError extends UserError {
15
+ }
16
+ export declare class BuildWorkflowError extends UserError {
17
+ readonly message: string;
18
+ readonly errors: BuildConfigError[];
19
+ constructor(message: string, errors: BuildConfigError[], extra?: {
20
+ metadata?: object;
21
+ cause?: Error;
22
+ });
23
+ }
24
+ export {};
@@ -0,0 +1,23 @@
1
+ class UserError extends Error {
2
+ constructor(message, extra) {
3
+ var _a;
4
+ super(message);
5
+ this.message = message;
6
+ this.metadata = (_a = extra === null || extra === void 0 ? void 0 : extra.cause) !== null && _a !== void 0 ? _a : {};
7
+ this.cause = extra === null || extra === void 0 ? void 0 : extra.cause;
8
+ }
9
+ }
10
+ export class BuildConfigError extends UserError {
11
+ }
12
+ export class BuildInternalError extends Error {
13
+ }
14
+ export class BuildStepRuntimeError extends UserError {
15
+ }
16
+ export class BuildWorkflowError extends UserError {
17
+ constructor(message, errors, extra) {
18
+ super(message, extra);
19
+ this.message = message;
20
+ this.errors = errors;
21
+ }
22
+ }
23
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAe,SAAU,SAAQ,KAAK;IAIpC,YAC2B,OAAe,EACxC,KAGC;;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QANU,YAAO,GAAP,OAAO,CAAQ;QAOxC,IAAI,CAAC,QAAQ,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,mCAAI,EAAE,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CAAC;IAC5B,CAAC;CACF;AAED,MAAM,OAAO,gBAAiB,SAAQ,SAAS;CAAG;AAElD,MAAM,OAAO,kBAAmB,SAAQ,KAAK;CAAG;AAEhD,MAAM,OAAO,qBAAsB,SAAQ,SAAS;CAAG;AAEvD,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAC/C,YAC2B,OAAe,EACxB,MAA0B,EAC1C,KAGC;QAED,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAPG,YAAO,GAAP,OAAO,CAAQ;QACxB,WAAM,GAAN,MAAM,CAAoB;IAO5C,CAAC;CACF","sourcesContent":["abstract class UserError extends Error {\n public readonly cause?: Error;\n public readonly metadata: object;\n\n constructor(\n public override readonly message: string,\n extra?: {\n metadata?: object;\n cause?: Error;\n }\n ) {\n super(message);\n this.metadata = extra?.cause ?? {};\n this.cause = extra?.cause;\n }\n}\n\nexport class BuildConfigError extends UserError {}\n\nexport class BuildInternalError extends Error {}\n\nexport class BuildStepRuntimeError extends UserError {}\n\nexport class BuildWorkflowError extends UserError {\n constructor(\n public override readonly message: string,\n public readonly errors: BuildConfigError[],\n extra?: {\n metadata?: object;\n cause?: Error;\n }\n ) {\n super(message, extra);\n }\n}\n"]}
@@ -3,3 +3,5 @@ export { BuildFunction } from './BuildFunction.js';
3
3
  export { BuildStepInput } from './BuildStepInput.js';
4
4
  export { BuildStepOutput } from './BuildStepOutput.js';
5
5
  export { BuildStepContext } from './BuildStepContext.js';
6
+ export { BuildWorkflow } from './BuildWorkflow.js';
7
+ export * as errors from './errors.js';
package/dist_esm/index.js CHANGED
@@ -3,4 +3,6 @@ export { BuildFunction } from './BuildFunction.js';
3
3
  export { BuildStepInput } from './BuildStepInput.js';
4
4
  export { BuildStepOutput } from './BuildStepOutput.js';
5
5
  export { BuildStepContext } from './BuildStepContext.js';
6
+ export { BuildWorkflow } from './BuildWorkflow.js';
7
+ export * as errors from './errors.js';
6
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC","sourcesContent":["export { BuildConfigParser } from './BuildConfigParser.js';\nexport { BuildFunction } from './BuildFunction.js';\nexport { BuildStepInput } from './BuildStepInput.js';\nexport { BuildStepOutput } from './BuildStepOutput.js';\nexport { BuildStepContext } from './BuildStepContext.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC","sourcesContent":["export { BuildConfigParser } from './BuildConfigParser.js';\nexport { BuildFunction } from './BuildFunction.js';\nexport { BuildStepInput } from './BuildStepInput.js';\nexport { BuildStepOutput } from './BuildStepOutput.js';\nexport { BuildStepContext } from './BuildStepContext.js';\nexport { BuildWorkflow } from './BuildWorkflow.js';\nexport * as errors from './errors.js';\n"]}
@@ -1,4 +1,4 @@
1
- import { BuildConfigError } from '../errors/BuildConfigError.js';
1
+ import { BuildConfigError } from '../errors.js';
2
2
  import { nullthrows } from './nullthrows.js';
3
3
  export const BUILD_STEP_INPUT_EXPRESSION_REGEXP = /\${\s*inputs\.([\S]+)\s*}/;
4
4
  export const BUILD_STEP_OUTPUT_EXPRESSION_REGEXP = /\${\s*steps\.([\S]+)\s*}/;
@@ -1 +1 @@
1
- {"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AAsB;IACpD,MAAM,MAAM,GAAsB,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,cAAc,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,mCAAmC,EAAE,GAAG,CAAC,CAAC,CAAC;IAC9F,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;QAC3B,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KACxC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,UAAkB;IAChD,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;QACvB,MAAM,IAAI,gBAAgB,CACxB,gKAAgK,UAAU,GAAG,CAC9K,CAAC;KACH;IACD,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,MAAM,CAAC;IAClC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["import { BuildConfigError } from '../errors/BuildConfigError.js';\n\nimport { nullthrows } from './nullthrows.js';\n\nexport const BUILD_STEP_INPUT_EXPRESSION_REGEXP = /\\${\\s*inputs\\.([\\S]+)\\s*}/;\nexport const BUILD_STEP_OUTPUT_EXPRESSION_REGEXP = /\\${\\s*steps\\.([\\S]+)\\s*}/;\n\nexport function interpolateWithInputs(\n templateString: string,\n inputs: Record<string, string>\n): string {\n return interpolate(templateString, BUILD_STEP_INPUT_EXPRESSION_REGEXP, inputs);\n}\n\nexport function interpolateWithOutputs(\n templateString: string,\n fn: (path: string) => string\n): string {\n return interpolate(templateString, BUILD_STEP_OUTPUT_EXPRESSION_REGEXP, fn);\n}\n\nfunction interpolate(\n templateString: string,\n regex: RegExp,\n varsOrFn: Record<string, string> | ((key: string) => string)\n): string {\n const matched = templateString.match(new RegExp(regex, 'g'));\n if (!matched) {\n return templateString;\n }\n let result = templateString;\n for (const match of matched) {\n const [, key] = nullthrows(match.match(regex));\n const value = typeof varsOrFn === 'function' ? varsOrFn(key) : varsOrFn[key];\n result = result.replace(match, value);\n }\n return result;\n}\n\ninterface BuildOutputPath {\n stepId: string;\n outputId: string;\n}\n\nexport function findOutputPaths(templateString: string): BuildOutputPath[] {\n const result: BuildOutputPath[] = [];\n const matches = templateString.matchAll(new RegExp(BUILD_STEP_OUTPUT_EXPRESSION_REGEXP, 'g'));\n for (const match of matches) {\n result.push(parseOutputPath(match[1]));\n }\n return result;\n}\n\nexport function parseOutputPath(outputPath: string): BuildOutputPath {\n const splits = outputPath.split('.');\n if (splits.length !== 2) {\n throw new BuildConfigError(\n `Step output path must consist of two components joined with a dot, where first is the step ID, and second is the output name, e.g. \"step3.output1\". Passed: \"${outputPath}\"`\n );\n }\n const [stepId, outputId] = splits;\n return { stepId, outputId };\n}\n"]}
1
+ {"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/utils/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,CAAC,MAAM,kCAAkC,GAAG,2BAA2B,CAAC;AAC9E,MAAM,CAAC,MAAM,mCAAmC,GAAG,0BAA0B,CAAC;AAE9E,MAAM,UAAU,qBAAqB,CACnC,cAAsB,EACtB,MAA8B;IAE9B,OAAO,WAAW,CAAC,cAAc,EAAE,kCAAkC,EAAE,MAAM,CAAC,CAAC;AACjF,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,cAAsB,EACtB,EAA4B;IAE5B,OAAO,WAAW,CAAC,cAAc,EAAE,mCAAmC,EAAE,EAAE,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,WAAW,CAClB,cAAsB,EACtB,KAAa,EACb,QAA4D;IAE5D,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,E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["import { BuildConfigError } from '../errors.js';\n\nimport { nullthrows } from './nullthrows.js';\n\nexport const BUILD_STEP_INPUT_EXPRESSION_REGEXP = /\\${\\s*inputs\\.([\\S]+)\\s*}/;\nexport const BUILD_STEP_OUTPUT_EXPRESSION_REGEXP = /\\${\\s*steps\\.([\\S]+)\\s*}/;\n\nexport function interpolateWithInputs(\n templateString: string,\n inputs: Record<string, string>\n): string {\n return interpolate(templateString, BUILD_STEP_INPUT_EXPRESSION_REGEXP, inputs);\n}\n\nexport function interpolateWithOutputs(\n templateString: string,\n fn: (path: string) => string\n): string {\n return interpolate(templateString, BUILD_STEP_OUTPUT_EXPRESSION_REGEXP, fn);\n}\n\nfunction interpolate(\n templateString: string,\n regex: RegExp,\n varsOrFn: Record<string, string> | ((key: string) => string)\n): string {\n const matched = templateString.match(new RegExp(regex, 'g'));\n if (!matched) {\n return templateString;\n }\n let result = templateString;\n for (const match of matched) {\n const [, key] = nullthrows(match.match(regex));\n const value = typeof varsOrFn === 'function' ? varsOrFn(key) : varsOrFn[key];\n result = result.replace(match, value);\n }\n return result;\n}\n\ninterface BuildOutputPath {\n stepId: string;\n outputId: string;\n}\n\nexport function findOutputPaths(templateString: string): BuildOutputPath[] {\n const result: BuildOutputPath[] = [];\n const matches = templateString.matchAll(new RegExp(BUILD_STEP_OUTPUT_EXPRESSION_REGEXP, 'g'));\n for (const match of matches) {\n result.push(parseOutputPath(match[1]));\n }\n return result;\n}\n\nexport function parseOutputPath(outputPath: string): BuildOutputPath {\n const splits = outputPath.split('.');\n if (splits.length !== 2) {\n throw new BuildConfigError(\n `Step output path must consist of two components joined with a dot, where first is the step ID, and second is the output name, e.g. \"step3.output1\". Passed: \"${outputPath}\"`\n );\n }\n const [stepId, outputId] = splits;\n return { stepId, outputId };\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@expo/steps",
3
3
  "type": "module",
4
- "version": "0.0.9",
4
+ "version": "0.0.10",
5
5
  "main": "./dist_commonjs/index.cjs",
6
6
  "types": "./dist_esm/index.d.ts",
7
7
  "exports": {
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BuildConfigError = void 0;
4
- const UserError_js_1 = require("./UserError.cjs");
5
- class BuildConfigError extends UserError_js_1.UserError {
6
- }
7
- exports.BuildConfigError = BuildConfigError;
8
- //# sourceMappingURL=BuildConfigError.js.map
@@ -1,3 +0,0 @@
1
- import { UserError } from './UserError.js';
2
- export declare class BuildConfigError extends UserError {
3
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"BuildConfigError.js","sourceRoot":"","sources":["../../src/errors/BuildConfigError.ts"],"names":[],"mappings":";;;AAAA,iDAA2C;AAE3C,MAAa,gBAAiB,SAAQ,wBAAS;CAAG;AAAlD,4CAAkD","sourcesContent":["import { UserError } from './UserError.js';\n\nexport class BuildConfigError extends UserError {}\n"]}
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BuildInternalError = void 0;
4
- class BuildInternalError extends Error {
5
- }
6
- exports.BuildInternalError = BuildInternalError;
7
- //# sourceMappingURL=BuildInternalError.js.map
@@ -1,2 +0,0 @@
1
- export declare class BuildInternalError extends Error {
2
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"BuildInternalError.js","sourceRoot":"","sources":["../../src/errors/BuildInternalError.ts"],"names":[],"mappings":";;;AAAA,MAAa,kBAAmB,SAAQ,KAAK;CAAG;AAAhD,gDAAgD","sourcesContent":["export class BuildInternalError extends Error {}\n"]}
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BuildStepRuntimeError = void 0;
4
- const UserError_js_1 = require("./UserError.cjs");
5
- class BuildStepRuntimeError extends UserError_js_1.UserError {
6
- }
7
- exports.BuildStepRuntimeError = BuildStepRuntimeError;
8
- //# sourceMappingURL=BuildStepRuntimeError.js.map
@@ -1,3 +0,0 @@
1
- import { UserError } from './UserError.js';
2
- export declare class BuildStepRuntimeError extends UserError {
3
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"BuildStepRuntimeError.js","sourceRoot":"","sources":["../../src/errors/BuildStepRuntimeError.ts"],"names":[],"mappings":";;;AAAA,iDAA2C;AAE3C,MAAa,qBAAsB,SAAQ,wBAAS;CAAG;AAAvD,sDAAuD","sourcesContent":["import { UserError } from './UserError.js';\n\nexport class BuildStepRuntimeError extends UserError {}\n"]}
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BuildWorkflowError = void 0;
4
- const UserError_js_1 = require("./UserError.cjs");
5
- class BuildWorkflowError extends UserError_js_1.UserError {
6
- constructor(message, errors, extra) {
7
- super(message, extra);
8
- this.message = message;
9
- this.errors = errors;
10
- }
11
- }
12
- exports.BuildWorkflowError = BuildWorkflowError;
13
- //# sourceMappingURL=BuildWorkflowError.js.map
@@ -1,10 +0,0 @@
1
- import { BuildConfigError } from './BuildConfigError.js';
2
- import { UserError } from './UserError.js';
3
- export declare class BuildWorkflowError extends UserError {
4
- readonly message: string;
5
- readonly errors: BuildConfigError[];
6
- constructor(message: string, errors: BuildConfigError[], extra?: {
7
- metadata?: object;
8
- cause?: Error;
9
- });
10
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"BuildWorkflowError.js","sourceRoot":"","sources":["../../src/errors/BuildWorkflowError.ts"],"names":[],"mappings":";;;AACA,iDAA2C;AAE3C,MAAa,kBAAmB,SAAQ,wBAAS;IAC/C,YAC2B,OAAe,EACxB,MAA0B,EAC1C,KAGC;QAED,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAPG,YAAO,GAAP,OAAO,CAAQ;QACxB,WAAM,GAAN,MAAM,CAAoB;IAO5C,CAAC;CACF;AAXD,gDAWC","sourcesContent":["import { BuildConfigError } from './BuildConfigError.js';\nimport { UserError } from './UserError.js';\n\nexport class BuildWorkflowError extends UserError {\n constructor(\n public override readonly message: string,\n public readonly errors: BuildConfigError[],\n extra?: {\n metadata?: object;\n cause?: Error;\n }\n ) {\n super(message, extra);\n }\n}\n"]}
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UserError = void 0;
4
- class UserError extends Error {
5
- constructor(message, extra) {
6
- var _a;
7
- super(message);
8
- this.message = message;
9
- this.metadata = (_a = extra === null || extra === void 0 ? void 0 : extra.cause) !== null && _a !== void 0 ? _a : {};
10
- this.cause = extra === null || extra === void 0 ? void 0 : extra.cause;
11
- }
12
- }
13
- exports.UserError = UserError;
14
- //# sourceMappingURL=UserError.js.map
@@ -1,9 +0,0 @@
1
- export declare abstract class UserError extends Error {
2
- readonly message: string;
3
- readonly cause?: Error;
4
- readonly metadata: object;
5
- constructor(message: string, extra?: {
6
- metadata?: object;
7
- cause?: Error;
8
- });
9
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"UserError.js","sourceRoot":"","sources":["../../src/errors/UserError.ts"],"names":[],"mappings":";;;AAAA,MAAsB,SAAU,SAAQ,KAAK;IAI3C,YAC2B,OAAe,EACxC,KAGC;;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QANU,YAAO,GAAP,OAAO,CAAQ;QAOxC,IAAI,CAAC,QAAQ,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,mCAAI,EAAE,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CAAC;IAC5B,CAAC;CACF;AAfD,8BAeC","sourcesContent":["export abstract class UserError extends Error {\n public readonly cause?: Error;\n public readonly metadata: object;\n\n constructor(\n public override readonly message: string,\n extra?: {\n metadata?: object;\n cause?: Error;\n }\n ) {\n super(message);\n this.metadata = extra?.cause ?? {};\n this.cause = extra?.cause;\n }\n}\n"]}
@@ -1,3 +0,0 @@
1
- import { UserError } from './UserError.js';
2
- export declare class BuildConfigError extends UserError {
3
- }
@@ -1,4 +0,0 @@
1
- import { UserError } from './UserError.js';
2
- export class BuildConfigError extends UserError {
3
- }
4
- //# sourceMappingURL=BuildConfigError.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BuildConfigError.js","sourceRoot":"","sources":["../../src/errors/BuildConfigError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,OAAO,gBAAiB,SAAQ,SAAS;CAAG","sourcesContent":["import { UserError } from './UserError.js';\n\nexport class BuildConfigError extends UserError {}\n"]}
@@ -1,2 +0,0 @@
1
- export declare class BuildInternalError extends Error {
2
- }
@@ -1,3 +0,0 @@
1
- export class BuildInternalError extends Error {
2
- }
3
- //# sourceMappingURL=BuildInternalError.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BuildInternalError.js","sourceRoot":"","sources":["../../src/errors/BuildInternalError.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,kBAAmB,SAAQ,KAAK;CAAG","sourcesContent":["export class BuildInternalError extends Error {}\n"]}
@@ -1,3 +0,0 @@
1
- import { UserError } from './UserError.js';
2
- export declare class BuildStepRuntimeError extends UserError {
3
- }
@@ -1,4 +0,0 @@
1
- import { UserError } from './UserError.js';
2
- export class BuildStepRuntimeError extends UserError {
3
- }
4
- //# sourceMappingURL=BuildStepRuntimeError.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BuildStepRuntimeError.js","sourceRoot":"","sources":["../../src/errors/BuildStepRuntimeError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,OAAO,qBAAsB,SAAQ,SAAS;CAAG","sourcesContent":["import { UserError } from './UserError.js';\n\nexport class BuildStepRuntimeError extends UserError {}\n"]}
@@ -1,10 +0,0 @@
1
- import { BuildConfigError } from './BuildConfigError.js';
2
- import { UserError } from './UserError.js';
3
- export declare class BuildWorkflowError extends UserError {
4
- readonly message: string;
5
- readonly errors: BuildConfigError[];
6
- constructor(message: string, errors: BuildConfigError[], extra?: {
7
- metadata?: object;
8
- cause?: Error;
9
- });
10
- }
@@ -1,9 +0,0 @@
1
- import { UserError } from './UserError.js';
2
- export class BuildWorkflowError extends UserError {
3
- constructor(message, errors, extra) {
4
- super(message, extra);
5
- this.message = message;
6
- this.errors = errors;
7
- }
8
- }
9
- //# sourceMappingURL=BuildWorkflowError.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BuildWorkflowError.js","sourceRoot":"","sources":["../../src/errors/BuildWorkflowError.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAC/C,YAC2B,OAAe,EACxB,MAA0B,EAC1C,KAGC;QAED,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAPG,YAAO,GAAP,OAAO,CAAQ;QACxB,WAAM,GAAN,MAAM,CAAoB;IAO5C,CAAC;CACF","sourcesContent":["import { BuildConfigError } from './BuildConfigError.js';\nimport { UserError } from './UserError.js';\n\nexport class BuildWorkflowError extends UserError {\n constructor(\n public override readonly message: string,\n public readonly errors: BuildConfigError[],\n extra?: {\n metadata?: object;\n cause?: Error;\n }\n ) {\n super(message, extra);\n }\n}\n"]}
@@ -1,9 +0,0 @@
1
- export declare abstract class UserError extends Error {
2
- readonly message: string;
3
- readonly cause?: Error;
4
- readonly metadata: object;
5
- constructor(message: string, extra?: {
6
- metadata?: object;
7
- cause?: Error;
8
- });
9
- }
@@ -1,10 +0,0 @@
1
- export class UserError extends Error {
2
- constructor(message, extra) {
3
- var _a;
4
- super(message);
5
- this.message = message;
6
- this.metadata = (_a = extra === null || extra === void 0 ? void 0 : extra.cause) !== null && _a !== void 0 ? _a : {};
7
- this.cause = extra === null || extra === void 0 ? void 0 : extra.cause;
8
- }
9
- }
10
- //# sourceMappingURL=UserError.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UserError.js","sourceRoot":"","sources":["../../src/errors/UserError.ts"],"names":[],"mappings":"AAAA,MAAM,OAAgB,SAAU,SAAQ,KAAK;IAI3C,YAC2B,OAAe,EACxC,KAGC;;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QANU,YAAO,GAAP,OAAO,CAAQ;QAOxC,IAAI,CAAC,QAAQ,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,mCAAI,EAAE,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CAAC;IAC5B,CAAC;CACF","sourcesContent":["export abstract class UserError extends Error {\n public readonly cause?: Error;\n public readonly metadata: object;\n\n constructor(\n public override readonly message: string,\n extra?: {\n metadata?: object;\n cause?: Error;\n }\n ) {\n super(message);\n this.metadata = extra?.cause ?? {};\n this.cause = extra?.cause;\n }\n}\n"]}