@actions/languageservice 0.2.0
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/LICENSE +21 -0
- package/README.md +131 -0
- package/dist/action.d.ts +28 -0
- package/dist/action.d.ts.map +1 -0
- package/dist/action.js +36 -0
- package/dist/action.js.map +1 -0
- package/dist/complete.d.ts +15 -0
- package/dist/complete.d.ts.map +1 -0
- package/dist/complete.js +203 -0
- package/dist/complete.js.map +1 -0
- package/dist/context/workflow-context.d.ts +15 -0
- package/dist/context/workflow-context.d.ts.map +1 -0
- package/dist/context/workflow-context.js +64 -0
- package/dist/context/workflow-context.js.map +1 -0
- package/dist/context-providers/config.d.ts +7 -0
- package/dist/context-providers/config.d.ts.map +1 -0
- package/dist/context-providers/config.js +2 -0
- package/dist/context-providers/config.js.map +1 -0
- package/dist/context-providers/default.d.ts +11 -0
- package/dist/context-providers/default.d.ts.map +1 -0
- package/dist/context-providers/default.js +88 -0
- package/dist/context-providers/default.js.map +1 -0
- package/dist/context-providers/descriptions.d.ts +15 -0
- package/dist/context-providers/descriptions.d.ts.map +1 -0
- package/dist/context-providers/descriptions.js +23 -0
- package/dist/context-providers/descriptions.js.map +1 -0
- package/dist/context-providers/descriptions.json +241 -0
- package/dist/context-providers/env.d.ts +4 -0
- package/dist/context-providers/env.d.ts.map +1 -0
- package/dist/context-providers/env.js +29 -0
- package/dist/context-providers/env.js.map +1 -0
- package/dist/context-providers/events/eventPayloads.d.ts +4 -0
- package/dist/context-providers/events/eventPayloads.d.ts.map +1 -0
- package/dist/context-providers/events/eventPayloads.js +111 -0
- package/dist/context-providers/events/eventPayloads.js.map +1 -0
- package/dist/context-providers/events/objects.json +26220 -0
- package/dist/context-providers/events/schedule.json +102 -0
- package/dist/context-providers/events/webhooks.json +124811 -0
- package/dist/context-providers/events/workflow_call.json +134 -0
- package/dist/context-providers/github.d.ts +5 -0
- package/dist/context-providers/github.d.ts.map +1 -0
- package/dist/context-providers/github.js +139 -0
- package/dist/context-providers/github.js.map +1 -0
- package/dist/context-providers/inputs.d.ts +4 -0
- package/dist/context-providers/inputs.d.ts.map +1 -0
- package/dist/context-providers/inputs.js +52 -0
- package/dist/context-providers/inputs.js.map +1 -0
- package/dist/context-providers/job.d.ts +4 -0
- package/dist/context-providers/job.d.ts.map +1 -0
- package/dist/context-providers/job.js +61 -0
- package/dist/context-providers/job.js.map +1 -0
- package/dist/context-providers/jobs.d.ts +4 -0
- package/dist/context-providers/jobs.d.ts.map +1 -0
- package/dist/context-providers/jobs.js +30 -0
- package/dist/context-providers/jobs.js.map +1 -0
- package/dist/context-providers/matrix.d.ts +4 -0
- package/dist/context-providers/matrix.d.ts.map +1 -0
- package/dist/context-providers/matrix.js +163 -0
- package/dist/context-providers/matrix.js.map +1 -0
- package/dist/context-providers/needs.d.ts +4 -0
- package/dist/context-providers/needs.d.ts.map +1 -0
- package/dist/context-providers/needs.js +56 -0
- package/dist/context-providers/needs.js.map +1 -0
- package/dist/context-providers/secrets.d.ts +5 -0
- package/dist/context-providers/secrets.d.ts.map +1 -0
- package/dist/context-providers/secrets.js +23 -0
- package/dist/context-providers/secrets.js.map +1 -0
- package/dist/context-providers/steps.d.ts +4 -0
- package/dist/context-providers/steps.d.ts.map +1 -0
- package/dist/context-providers/steps.js +35 -0
- package/dist/context-providers/steps.js.map +1 -0
- package/dist/context-providers/strategy.d.ts +4 -0
- package/dist/context-providers/strategy.d.ts.map +1 -0
- package/dist/context-providers/strategy.js +31 -0
- package/dist/context-providers/strategy.js.map +1 -0
- package/dist/description-providers/reusable-job-inputs.d.ts +5 -0
- package/dist/description-providers/reusable-job-inputs.d.ts.map +1 -0
- package/dist/description-providers/reusable-job-inputs.js +29 -0
- package/dist/description-providers/reusable-job-inputs.js.map +1 -0
- package/dist/document-links.d.ts +4 -0
- package/dist/document-links.d.ts.map +1 -0
- package/dist/document-links.js +73 -0
- package/dist/document-links.js.map +1 -0
- package/dist/expression-hover/expression-pos.d.ts +13 -0
- package/dist/expression-hover/expression-pos.d.ts.map +1 -0
- package/dist/expression-hover/expression-pos.js +41 -0
- package/dist/expression-hover/expression-pos.js.map +1 -0
- package/dist/expression-hover/pos-range.d.ts +3 -0
- package/dist/expression-hover/pos-range.d.ts.map +1 -0
- package/dist/expression-hover/pos-range.js +7 -0
- package/dist/expression-hover/pos-range.js.map +1 -0
- package/dist/expression-hover/visitor.d.ts +27 -0
- package/dist/expression-hover/visitor.d.ts.map +1 -0
- package/dist/expression-hover/visitor.js +116 -0
- package/dist/expression-hover/visitor.js.map +1 -0
- package/dist/expression-validation/error-dictionary.d.ts +13 -0
- package/dist/expression-validation/error-dictionary.d.ts.map +1 -0
- package/dist/expression-validation/error-dictionary.js +39 -0
- package/dist/expression-validation/error-dictionary.js.map +1 -0
- package/dist/expression-validation/functions.d.ts +9 -0
- package/dist/expression-validation/functions.d.ts.map +1 -0
- package/dist/expression-validation/functions.js +11 -0
- package/dist/expression-validation/functions.js.map +1 -0
- package/dist/hover.d.ts +16 -0
- package/dist/hover.d.ts.map +1 -0
- package/dist/hover.js +154 -0
- package/dist/hover.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/log.d.ts +39 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +48 -0
- package/dist/log.js.map +1 -0
- package/dist/nulltrace.d.ts +3 -0
- package/dist/nulltrace.d.ts.map +1 -0
- package/dist/nulltrace.js +3 -0
- package/dist/nulltrace.js.map +1 -0
- package/dist/utils/expression-detection.d.ts +3 -0
- package/dist/utils/expression-detection.d.ts.map +1 -0
- package/dist/utils/expression-detection.js +9 -0
- package/dist/utils/expression-detection.js.map +1 -0
- package/dist/utils/find-token.d.ts +23 -0
- package/dist/utils/find-token.d.ts.map +1 -0
- package/dist/utils/find-token.js +159 -0
- package/dist/utils/find-token.js.map +1 -0
- package/dist/utils/indentation-guesser.d.ts +16 -0
- package/dist/utils/indentation-guesser.d.ts.map +1 -0
- package/dist/utils/indentation-guesser.js +214 -0
- package/dist/utils/indentation-guesser.js.map +1 -0
- package/dist/utils/range.d.ts +5 -0
- package/dist/utils/range.d.ts.map +1 -0
- package/dist/utils/range.js +25 -0
- package/dist/utils/range.js.map +1 -0
- package/dist/utils/rel-char-pos.d.ts +4 -0
- package/dist/utils/rel-char-pos.d.ts.map +1 -0
- package/dist/utils/rel-char-pos.js +14 -0
- package/dist/utils/rel-char-pos.js.map +1 -0
- package/dist/utils/scalar-to-data.d.ts +4 -0
- package/dist/utils/scalar-to-data.d.ts.map +1 -0
- package/dist/utils/scalar-to-data.js +19 -0
- package/dist/utils/scalar-to-data.js.map +1 -0
- package/dist/utils/transform.d.ts +6 -0
- package/dist/utils/transform.d.ts.map +1 -0
- package/dist/utils/transform.js +66 -0
- package/dist/utils/transform.js.map +1 -0
- package/dist/utils/workflow-cache.d.ts +21 -0
- package/dist/utils/workflow-cache.d.ts.map +1 -0
- package/dist/utils/workflow-cache.js +52 -0
- package/dist/utils/workflow-cache.js.map +1 -0
- package/dist/validate-action.d.ts +6 -0
- package/dist/validate-action.d.ts.map +1 -0
- package/dist/validate-action.js +71 -0
- package/dist/validate-action.js.map +1 -0
- package/dist/validate.d.ts +20 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +162 -0
- package/dist/validate.js.map +1 -0
- package/dist/value-providers/config.d.ts +24 -0
- package/dist/value-providers/config.d.ts.map +1 -0
- package/dist/value-providers/config.js +6 -0
- package/dist/value-providers/config.js.map +1 -0
- package/dist/value-providers/default.d.ts +4 -0
- package/dist/value-providers/default.d.ts.map +1 -0
- package/dist/value-providers/default.js +38 -0
- package/dist/value-providers/default.js.map +1 -0
- package/dist/value-providers/definition.d.ts +4 -0
- package/dist/value-providers/definition.d.ts.map +1 -0
- package/dist/value-providers/definition.js +82 -0
- package/dist/value-providers/definition.js.map +1 -0
- package/dist/value-providers/needs.d.ts +4 -0
- package/dist/value-providers/needs.d.ts.map +1 -0
- package/dist/value-providers/needs.js +10 -0
- package/dist/value-providers/needs.js.map +1 -0
- package/dist/value-providers/reusable-job-inputs.d.ts +4 -0
- package/dist/value-providers/reusable-job-inputs.d.ts.map +1 -0
- package/dist/value-providers/reusable-job-inputs.js +29 -0
- package/dist/value-providers/reusable-job-inputs.js.map +1 -0
- package/dist/value-providers/reusable-job-secrets.d.ts +4 -0
- package/dist/value-providers/reusable-job-secrets.d.ts.map +1 -0
- package/dist/value-providers/reusable-job-secrets.js +41 -0
- package/dist/value-providers/reusable-job-secrets.js.map +1 -0
- package/dist/value-providers/strings-to-values.d.ts +3 -0
- package/dist/value-providers/strings-to-values.d.ts.map +1 -0
- package/dist/value-providers/strings-to-values.js +4 -0
- package/dist/value-providers/strings-to-values.js.map +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { data, DescriptionDictionary } from "@actions/expressions";
|
|
2
|
+
import { Kind } from "@actions/expressions/data/expressiondata";
|
|
3
|
+
import { getDescription, RootContext } from "./descriptions";
|
|
4
|
+
import { getEnvContext } from "./env";
|
|
5
|
+
import { getGithubContext } from "./github";
|
|
6
|
+
import { getInputsContext } from "./inputs";
|
|
7
|
+
import { getJobContext } from "./job";
|
|
8
|
+
import { getJobsContext } from "./jobs";
|
|
9
|
+
import { getMatrixContext } from "./matrix";
|
|
10
|
+
import { getNeedsContext } from "./needs";
|
|
11
|
+
import { getSecretsContext } from "./secrets";
|
|
12
|
+
import { getStepsContext } from "./steps";
|
|
13
|
+
import { getStrategyContext } from "./strategy";
|
|
14
|
+
export var Mode;
|
|
15
|
+
(function (Mode) {
|
|
16
|
+
Mode[Mode["Completion"] = 0] = "Completion";
|
|
17
|
+
Mode[Mode["Validation"] = 1] = "Validation";
|
|
18
|
+
Mode[Mode["Hover"] = 2] = "Hover";
|
|
19
|
+
})(Mode || (Mode = {}));
|
|
20
|
+
export async function getContext(names, config, workflowContext, mode) {
|
|
21
|
+
const context = new DescriptionDictionary();
|
|
22
|
+
const filteredNames = filterContextNames(names, workflowContext);
|
|
23
|
+
for (const contextName of filteredNames) {
|
|
24
|
+
let value = getDefaultContext(contextName, workflowContext, mode) || new DescriptionDictionary();
|
|
25
|
+
if (value.kind === Kind.Null) {
|
|
26
|
+
context.add(contextName, value);
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
value = (await config?.getContext(contextName, value, workflowContext, mode)) || value;
|
|
30
|
+
context.add(contextName, value, getDescription(RootContext, contextName));
|
|
31
|
+
}
|
|
32
|
+
return context;
|
|
33
|
+
}
|
|
34
|
+
function getDefaultContext(name, workflowContext, mode) {
|
|
35
|
+
switch (name) {
|
|
36
|
+
case "env":
|
|
37
|
+
return getEnvContext(workflowContext);
|
|
38
|
+
case "github":
|
|
39
|
+
return getGithubContext(workflowContext, mode);
|
|
40
|
+
case "inputs":
|
|
41
|
+
return getInputsContext(workflowContext);
|
|
42
|
+
case "reusableWorkflowJob":
|
|
43
|
+
case "job":
|
|
44
|
+
return getJobContext(workflowContext);
|
|
45
|
+
case "jobs":
|
|
46
|
+
return getJobsContext(workflowContext);
|
|
47
|
+
case "matrix":
|
|
48
|
+
return getMatrixContext(workflowContext, mode);
|
|
49
|
+
case "needs":
|
|
50
|
+
return getNeedsContext(workflowContext);
|
|
51
|
+
case "runner":
|
|
52
|
+
return objectToDictionary({
|
|
53
|
+
os: "Linux",
|
|
54
|
+
arch: "X64",
|
|
55
|
+
name: "GitHub Actions 2",
|
|
56
|
+
tool_cache: "/opt/hostedtoolcache",
|
|
57
|
+
temp: "/home/runner/work/_temp"
|
|
58
|
+
});
|
|
59
|
+
case "secrets":
|
|
60
|
+
return getSecretsContext(workflowContext, mode);
|
|
61
|
+
case "steps":
|
|
62
|
+
return getStepsContext(workflowContext);
|
|
63
|
+
case "strategy":
|
|
64
|
+
return getStrategyContext(workflowContext);
|
|
65
|
+
}
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
function objectToDictionary(object) {
|
|
69
|
+
const dictionary = new DescriptionDictionary();
|
|
70
|
+
for (const key in object) {
|
|
71
|
+
dictionary.add(key, new data.StringData(object[key]));
|
|
72
|
+
}
|
|
73
|
+
return dictionary;
|
|
74
|
+
}
|
|
75
|
+
function filterContextNames(contextNames, workflowContext) {
|
|
76
|
+
return contextNames.filter(name => {
|
|
77
|
+
switch (name) {
|
|
78
|
+
case "matrix":
|
|
79
|
+
case "strategy":
|
|
80
|
+
return hasStrategy(workflowContext);
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function hasStrategy(workflowContext) {
|
|
86
|
+
return workflowContext.job?.strategy !== undefined || workflowContext.reusableWorkflowJob?.strategy !== undefined;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=default.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../src/context-providers/default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,qBAAqB,EAAC,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAC,IAAI,EAAC,MAAM,0CAA0C,CAAC;AAG9D,OAAO,EAAC,cAAc,EAAE,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AACpC,OAAO,EAAC,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAC,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AACpC,OAAO,EAAC,cAAc,EAAC,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAC,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAC,eAAe,EAAC,MAAM,SAAS,CAAC;AACxC,OAAO,EAAC,iBAAiB,EAAC,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAC,eAAe,EAAC,MAAM,SAAS,CAAC;A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AI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,WAAW,CAAC,eAAgC;IACnD,OAAO,eAAe,CAAC,GAAG,EAAE,QAAQ,KAAK,SAAS,IAAI,eAAe,CAAC,mBAAmB,EAAE,QAAQ,KAAK,SAAS,CAAC;AACpH,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const RootContext = "root";
|
|
2
|
+
/**
|
|
3
|
+
* Get a description for a built-in context
|
|
4
|
+
* @param context Name of the context, for example `github`
|
|
5
|
+
* @param key Key of the context, for example `actor`
|
|
6
|
+
* @returns Description if one is found, otherwise undefined
|
|
7
|
+
*/
|
|
8
|
+
export declare function getDescription(context: string, key: string): string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Get a description for a context function
|
|
11
|
+
* This will not include functions defined by the expressions library (e.g. `contains`, `fromJSON`, etc.)
|
|
12
|
+
* @param name Name of the function, for example `hashFiles`
|
|
13
|
+
*/
|
|
14
|
+
export declare function getFunctionDescription(name: string): string | undefined;
|
|
15
|
+
//# sourceMappingURL=descriptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptions.d.ts","sourceRoot":"","sources":["../../src/context-providers/descriptions.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,SAAS,CAAC;AAGlC;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI/E;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEvE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import descriptions from "./descriptions.json" assert { type: "json" };
|
|
2
|
+
export const RootContext = "root";
|
|
3
|
+
const FunctionContext = "functions";
|
|
4
|
+
/**
|
|
5
|
+
* Get a description for a built-in context
|
|
6
|
+
* @param context Name of the context, for example `github`
|
|
7
|
+
* @param key Key of the context, for example `actor`
|
|
8
|
+
* @returns Description if one is found, otherwise undefined
|
|
9
|
+
*/
|
|
10
|
+
export function getDescription(context, key) {
|
|
11
|
+
// The inferred type doesn't quite match the actual type, use any to work around that
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
|
|
13
|
+
return descriptions[context]?.[key]?.description;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get a description for a context function
|
|
17
|
+
* This will not include functions defined by the expressions library (e.g. `contains`, `fromJSON`, etc.)
|
|
18
|
+
* @param name Name of the function, for example `hashFiles`
|
|
19
|
+
*/
|
|
20
|
+
export function getFunctionDescription(name) {
|
|
21
|
+
return getDescription(FunctionContext, name);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=descriptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptions.js","sourceRoot":"","sources":["../../src/context-providers/descriptions.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,qBAAqB,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAC;AAErE,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC;AAClC,MAAM,eAAe,GAAG,WAAW,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe,EAAE,GAAW;IACzD,qFAAqF;IACrF,+IAA+I;IAC/I,OAAQ,YAAoB,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC;AAC5D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,OAAO,cAAc,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./descriptionsSchema.json",
|
|
3
|
+
"root": {
|
|
4
|
+
"github": {
|
|
5
|
+
"description": "Information about the workflow run. For more information, see [`github` context](https://docs.github.com/actions/learn-github-actions/contexts#github-context)."
|
|
6
|
+
},
|
|
7
|
+
"env": {
|
|
8
|
+
"description": "Contains variables set in a workflow, job, or step. For more information, see [`env` context](https://docs.github.com/actions/learn-github-actions/contexts#env-context)."
|
|
9
|
+
},
|
|
10
|
+
"vars": {
|
|
11
|
+
"description": "Contains variables set at the repository, organization, or environment levels. For more information, see [`vars` context](https://docs.github.com/actions/learn-github-actions/contexts#vars-context)."
|
|
12
|
+
},
|
|
13
|
+
"job": {
|
|
14
|
+
"description": "Information about the currently running job. For more information, see [`job` context](https://docs.github.com/actions/learn-github-actions/contexts#job-context)."
|
|
15
|
+
},
|
|
16
|
+
"jobs": {
|
|
17
|
+
"description": "For reusable workflows only, contains outputs of jobs from the reusable workflow. For more information, see [`jobs` context](https://docs.github.com/actions/learn-github-actions/contexts#jobs-context)."
|
|
18
|
+
},
|
|
19
|
+
"steps": {
|
|
20
|
+
"description": "Information about the steps that have been run in the current job. For more information, see [`steps` context](https://docs.github.com/actions/learn-github-actions/contexts#steps-context)."
|
|
21
|
+
},
|
|
22
|
+
"runner": {
|
|
23
|
+
"description": "Information about the runner that is running the current job. For more information, see [`runner` context](https://docs.github.com/actions/learn-github-actions/contexts#runner-context)."
|
|
24
|
+
},
|
|
25
|
+
"secrets": {
|
|
26
|
+
"description": "Contains the names and values of secrets that are available to a workflow run. For more information, see [`secrets` context](https://docs.github.com/actions/learn-github-actions/contexts#secrets-context)."
|
|
27
|
+
},
|
|
28
|
+
"strategy": {
|
|
29
|
+
"description": "Information about the matrix execution strategy for the current job. For more information, see [`strategy` context](https://docs.github.com/actions/learn-github-actions/contexts#strategy-context)."
|
|
30
|
+
},
|
|
31
|
+
"matrix": {
|
|
32
|
+
"description": "Contains the matrix properties defined in the workflow that apply to the current job. For more information, see [`matrix` context](https://docs.github.com/actions/learn-github-actions/contexts#matrix-context)."
|
|
33
|
+
},
|
|
34
|
+
"needs": {
|
|
35
|
+
"description": "Contains the outputs of all jobs that are defined as a dependency of the current job. For more information, see [`needs` context](https://docs.github.com/actions/learn-github-actions/contexts#needs-context)."
|
|
36
|
+
},
|
|
37
|
+
"inputs": {
|
|
38
|
+
"description": "Contains the inputs of a reusable or manually triggered workflow. For more information, see [`inputs` context](https://docs.github.com/actions/learn-github-actions/contexts#inputs-context)."
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"functions": {
|
|
42
|
+
"always": {
|
|
43
|
+
"description": "Causes the step to always execute, and returns `true`, even when canceled. The `always` expression is best used at the step level or on tasks that you expect to run even when a job is canceled. For example, you can use `always` to send logs even when a job is canceled."
|
|
44
|
+
},
|
|
45
|
+
"cancelled": {
|
|
46
|
+
"description": "Returns `true` if the workflow was canceled."
|
|
47
|
+
},
|
|
48
|
+
"failure": {
|
|
49
|
+
"description": "Returns `true` when any previous step of a job fails. If you have a chain of dependent jobs, `failure()` returns `true` if any ancestor job fails."
|
|
50
|
+
},
|
|
51
|
+
"hashFiles": {
|
|
52
|
+
"description": "Returns a single hash for the set of files that matches the `path` pattern. You can provide a single `path` pattern or multiple `path` patterns separated by commas. The `path` is relative to the `GITHUB_WORKSPACE` directory and can only include files inside of the `GITHUB_WORKSPACE`."
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"github": {
|
|
56
|
+
"action": {
|
|
57
|
+
"description": "The name of the action currently running, or the [`id`](https://docs.github.com/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepsid) of a step. GitHub Actions removes special characters, and uses the name `__run` when the current step runs a script without an `id`. If you use the same action more than once in the same job, the name will include a suffix with the sequence number with underscore before it. For example, the first script you run will have the name `__run`, and the second script will be named `__run_2`. Similarly, the second invocation of `actions/checkout` will be `actionscheckout2`."
|
|
58
|
+
},
|
|
59
|
+
"action_path": {
|
|
60
|
+
"description": "The path where an action is located. This property is only supported in composite actions. You can use this path to access files located in the same repository as the action."
|
|
61
|
+
},
|
|
62
|
+
"action_ref": {
|
|
63
|
+
"description": "For a step executing an action, this is the ref of the action being executed. For example, `v2`."
|
|
64
|
+
},
|
|
65
|
+
"action_repository": {
|
|
66
|
+
"description": "For a step executing an action, this is the owner and repository name of the action. For example, `actions/checkout`."
|
|
67
|
+
},
|
|
68
|
+
"action_status": {
|
|
69
|
+
"description": "For a composite action, the current result of the composite action."
|
|
70
|
+
},
|
|
71
|
+
"actor": {
|
|
72
|
+
"description": "The username of the user that triggered the initial workflow run. If the workflow run is a re-run, this value may differ from `github.triggering_actor`. Any workflow re-runs will use the privileges of `github.actor`, even if the actor initiating the re-run (`github.triggering_actor`) has different privileges."
|
|
73
|
+
},
|
|
74
|
+
"api_url": {
|
|
75
|
+
"description": "The URL of the GitHub Actions REST API."
|
|
76
|
+
},
|
|
77
|
+
"base_ref": {
|
|
78
|
+
"description": "The `base_ref` or target branch of the pull request in a workflow run. This property is only available when the event that triggers a workflow run is either `pull_request` or `pull_request_target`."
|
|
79
|
+
},
|
|
80
|
+
"env": {
|
|
81
|
+
"description": "Path on the runner to the file that sets environment variables from workflow commands. This file is unique to the current step and is a different file for each step in a job. For more information, see [Workflow commands](https://docs.github.com/actions/learn-github-actions/workflow-commands-for-github-actions#setting-an-environment-variable)."
|
|
82
|
+
},
|
|
83
|
+
"event": {
|
|
84
|
+
"description": "The full event webhook payload. You can access individual properties of the event using this context. This object is identical to the webhook payload of the event that triggered the workflow run, and is different for each event. The webhooks for each GitHub Actions event is linked in [Event that trigger workflows](/articles/events-that-trigger-workflows/). For example, for a workflow run triggered by the [`push` event](https://docs.github.com/actions/using-workflows/events-that-trigger-workflows#push), this object contains the contents of the [push webhook payload](https://docs.github.com/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push)."
|
|
85
|
+
},
|
|
86
|
+
"event_name": {
|
|
87
|
+
"description": "The name of the event that triggered the workflow run."
|
|
88
|
+
},
|
|
89
|
+
"event_path": {
|
|
90
|
+
"description": "The path to the file on the runner that contains the full event webhook payload."
|
|
91
|
+
},
|
|
92
|
+
"graphql_url": {
|
|
93
|
+
"description": "The URL of the GitHub Actions GraphQL API."
|
|
94
|
+
},
|
|
95
|
+
"head_ref": {
|
|
96
|
+
"description": "The `head_ref` or source branch of the pull request in a workflow run. This property is only available when the event that triggers a workflow run is either `pull_request` or `pull_request_target`."
|
|
97
|
+
},
|
|
98
|
+
"job": {
|
|
99
|
+
"description": "The [`job_id`](/actions/reference/workflow-syntax-for-github-actions#jobsjob_id) of the current job. <br /> Note: This context property is set by the Actions runner, and is only available within the execution `steps` of a job. Otherwise, the value of this property will be `null`."
|
|
100
|
+
},
|
|
101
|
+
"ref": {
|
|
102
|
+
"description": "The fully-formed ref of the branch or tag that triggered the workflow run. For workflows triggered by `push`, this is the branch or tag ref that was pushed. For workflows triggered by `pull_request`, this is the pull request merge branch. For workflows triggered by `release`, this is the release tag created. For other triggers, this is the branch or tag ref that triggered the workflow run. This is only set if a branch or tag is available for the event type. The ref given is fully-formed, meaning that for branches the format is `refs/heads/<branch_name>`, for pull requests it is `refs/pull/<pr_number>/merge`, and for tags it is `refs/tags/<tag_name>`. For example, `refs/heads/feature-branch-1`.",
|
|
103
|
+
"versions": {
|
|
104
|
+
"ghes": "3.3",
|
|
105
|
+
"ghae": "3.3"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"ref_name": {
|
|
109
|
+
"description": "The short ref name of the branch or tag that triggered the workflow run. This value matches the branch or tag name shown on GitHub. For example, `feature-branch-1`.",
|
|
110
|
+
"versions": {
|
|
111
|
+
"ghes": "3.3",
|
|
112
|
+
"ghae": "3.3"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"ref_protected": {
|
|
116
|
+
"description": "`true` if branch protections are configured for the ref that triggered the workflow run.",
|
|
117
|
+
"versions": {
|
|
118
|
+
"ghes": "3.3",
|
|
119
|
+
"ghae": "3.3"
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"ref_type": {
|
|
123
|
+
"description": "The type of ref that triggered the workflow run. Valid values are `branch` or `tag`.",
|
|
124
|
+
"versions": {
|
|
125
|
+
"ghes": "3.3",
|
|
126
|
+
"ghae": "3.3"
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"path": {
|
|
130
|
+
"description": "Path on the runner to the file that sets system `PATH` variables from workflow commands. This file is unique to the current step and is a different file for each step in a job. For more information, see [Workflow commands](https://docs.github.com/actions/learn-github-actions/workflow-commands-for-github-actions#adding-a-system-path)."
|
|
131
|
+
},
|
|
132
|
+
"repository": {
|
|
133
|
+
"description": "The owner and repository name. For example, `Codertocat/Hello-World`."
|
|
134
|
+
},
|
|
135
|
+
"repository_owner": {
|
|
136
|
+
"description": "The repository owner's name. For example, `Codertocat`."
|
|
137
|
+
},
|
|
138
|
+
"repositoryUrl": {
|
|
139
|
+
"description": "The Git URL to the repository. For example, `git://github.com/codertocat/hello-world.git`."
|
|
140
|
+
},
|
|
141
|
+
"retention_days": {
|
|
142
|
+
"description": "The number of days that workflow run logs and artifacts are kept."
|
|
143
|
+
},
|
|
144
|
+
"run_id": {
|
|
145
|
+
"description": "A unique number for each workflow run within a repository. This number does not change if you re-run the workflow run."
|
|
146
|
+
},
|
|
147
|
+
"run_number": {
|
|
148
|
+
"description": "A unique number for each run of a particular workflow in a repository. This number begins at 1 for the workflow's first run, and increments with each new run. This number does not change if you re-run the workflow run."
|
|
149
|
+
},
|
|
150
|
+
"run_attempt": {
|
|
151
|
+
"description": "A unique number for each attempt of a particular workflow run in a repository. This number begins at 1 for the workflow run's first attempt, and increments with each re-run.",
|
|
152
|
+
"versions": {
|
|
153
|
+
"ghes": "3.5",
|
|
154
|
+
"ghae": "3.4"
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
"secret_source": {
|
|
158
|
+
"description": "The source of a secret used in a workflow. Possible values are `None`, `Actions`, `Dependabot`, or `Codespaces`.",
|
|
159
|
+
"versions": {
|
|
160
|
+
"ghes": "3.3",
|
|
161
|
+
"ghae": "3.3"
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
"server_url": {
|
|
165
|
+
"description": "The URL of the GitHub server. For example: `https://github.com`."
|
|
166
|
+
},
|
|
167
|
+
"sha": {
|
|
168
|
+
"description": "The commit SHA that triggered the workflow. The value of this commit SHA depends on the event that triggered the workflow. For more information, see [Events that trigger workflows.](https://docs.github.com/actions/using-workflows/events-that-trigger-workflows) For example, `ffac537e6cbbf934b08745a378932722df287a53`."
|
|
169
|
+
},
|
|
170
|
+
"token": {
|
|
171
|
+
"description": "A token to authenticate on behalf of the GitHub App installed on your repository. This is functionally equivalent to the `GITHUB_TOKEN` secret. For more information, see [Automatic token authentication](https://docs.github.com/actions/security-guides/automatic-token-authentication).\nNote: This context property is set by the Actions runner, and is only available within the execution `steps` of a job. Otherwise, the value of this property will be `null`."
|
|
172
|
+
},
|
|
173
|
+
"triggering_actor": {
|
|
174
|
+
"description": "The username of the user that initiated the workflow run. If the workflow run is a re-run, this value may differ from `github.actor`. Any workflow re-runs will use the privileges of `github.actor`, even if the actor initiating the re-run (`github.triggering_actor`) has different privileges."
|
|
175
|
+
},
|
|
176
|
+
"workflow": {
|
|
177
|
+
"description": "The name of the workflow. If the workflow file doesn't specify a `name`, the value of this property is the full path of the workflow file in the repository."
|
|
178
|
+
},
|
|
179
|
+
"workspace": {
|
|
180
|
+
"description": "The default working directory on the runner for steps, and the default location of your repository when using the [`checkout`](https://github.com/actions/checkout) action."
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
"secrets": {
|
|
184
|
+
"GITHUB_TOKEN": {
|
|
185
|
+
"description": "`GITHUB_TOKEN` is a secret that is automatically created for every workflow run, and is always included in the secrets context. For more information, see [Automatic token authentication](https://docs.github.com/actions/security-guides/automatic-token-authentication)."
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
"jobs": {
|
|
189
|
+
"outputs": {
|
|
190
|
+
"description": "The set of outputs of a job in a reusable workflow."
|
|
191
|
+
},
|
|
192
|
+
"result": {
|
|
193
|
+
"description": "The result of a job in the reusable workflow. Possible values are `success`, `failure`, `cancelled`, or `skipped`."
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
"steps": {
|
|
197
|
+
"outputs": {
|
|
198
|
+
"description": "The set of outputs defined for the step."
|
|
199
|
+
},
|
|
200
|
+
"conclusion": {
|
|
201
|
+
"description": "The result of a completed step after `continue-on-error` is applied. Possible values are `success`, `failure`, `cancelled`, or `skipped`. When a `continue-on-error` step fails, the `outcome` is `failure`, but the final conclusion is `success`."
|
|
202
|
+
},
|
|
203
|
+
"outcome": {
|
|
204
|
+
"description": "The result of a completed step before `continue-on-error` is applied. Possible values are `success`, `failure`, `cancelled`, or `skipped`. When a `continue-on-error` step fails, the `outcome` is `failure`, but the final conclusion is `success`."
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
"runner": {
|
|
208
|
+
"name": {
|
|
209
|
+
"description": "The name of the runner executing the job."
|
|
210
|
+
},
|
|
211
|
+
"os": {
|
|
212
|
+
"description": "The operating system of the runner executing the job. Possible values are `Linux`, `Windows`, or `macOS`."
|
|
213
|
+
},
|
|
214
|
+
"arch": {
|
|
215
|
+
"description": "The architecture of the runner executing the job. Possible values are `X86`, `X64`, `ARM`, or `ARM64`."
|
|
216
|
+
},
|
|
217
|
+
"temp": {
|
|
218
|
+
"description": "The path to a temporary directory on the runner. This directory is emptied at the beginning and end of each job. Note that files will not be removed if the runner's user account does not have permission to delete them."
|
|
219
|
+
},
|
|
220
|
+
"tool_cache": {
|
|
221
|
+
"description": "The path to the directory containing preinstalled tools for GitHub-hosted runners. For more information, see \"[About GitHub-hosted runners](https://docs.github.com/actions/reference/specifications-for-github-hosted-runners/#supported-software)\"."
|
|
222
|
+
},
|
|
223
|
+
"debug": {
|
|
224
|
+
"description": "This is set only if [debug logging](https://docs.github.com/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging) is enabled, and always has the value of 1. It can be useful as an indicator to enable additional debugging or verbose logging in your own job steps."
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
"strategy": {
|
|
228
|
+
"fail-fast": {
|
|
229
|
+
"description": "The `fail-fast` setting for the job. Possible values are `true` or `false`. For more information, see [Workflow syntax for GitHub Actions: `jobs.<job_id>.strategy.fail-fast`](https://docs.github.com/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategyfail-fast)."
|
|
230
|
+
},
|
|
231
|
+
"max-parallel": {
|
|
232
|
+
"description": "The `max-parallel` setting for the job. For more information, see [Workflow syntax for GitHub Actions: `jobs.<job_id>.strategy.max-parallel`](https://docs.github.com/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategymax-parallel)."
|
|
233
|
+
},
|
|
234
|
+
"job-index": {
|
|
235
|
+
"description": "The index of the current job in the matrix. **Note:** This number is a zero-based number. The first job's index in the matrix is `0`."
|
|
236
|
+
},
|
|
237
|
+
"job-total": {
|
|
238
|
+
"description": "The total number of jobs in the matrix. **Note:** This number **is not** a zero-based number. For example, for a matrix with four jobs, the value of `job-total` is `4`."
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/context-providers/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,qBAAqB,EAAC,MAAM,sBAAsB,CAAC;AAGjE,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAE5D,wBAAgB,aAAa,CAAC,eAAe,EAAE,eAAe,GAAG,qBAAqB,CAoBrF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { data, DescriptionDictionary } from "@actions/expressions";
|
|
2
|
+
import { isScalar, isString } from "@actions/workflow-parser";
|
|
3
|
+
export function getEnvContext(workflowContext) {
|
|
4
|
+
const d = new DescriptionDictionary();
|
|
5
|
+
//step env
|
|
6
|
+
if (workflowContext.step?.env) {
|
|
7
|
+
envContext(workflowContext.step.env, d);
|
|
8
|
+
}
|
|
9
|
+
//job env
|
|
10
|
+
if (workflowContext.job && workflowContext.job.env) {
|
|
11
|
+
envContext(workflowContext.job.env, d);
|
|
12
|
+
}
|
|
13
|
+
//workflow env
|
|
14
|
+
if (workflowContext.template && workflowContext.template.env) {
|
|
15
|
+
const wfEnv = workflowContext.template.env.assertMapping("workflow env");
|
|
16
|
+
envContext(wfEnv, d);
|
|
17
|
+
}
|
|
18
|
+
return d;
|
|
19
|
+
}
|
|
20
|
+
function envContext(envMap, d) {
|
|
21
|
+
for (const env of envMap) {
|
|
22
|
+
if (!isString(env.key)) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const value = isScalar(env.value) ? new data.StringData(env.value.toDisplayString()) : new data.Null();
|
|
26
|
+
d.add(env.key.value, value);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/context-providers/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,qBAAqB,EAAC,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAC,MAAM,0BAA0B,CAAC;AAI5D,MAAM,UAAU,aAAa,CAAC,eAAgC;IAC5D,MAAM,CAAC,GAAG,IAAI,qBAAqB,EAAE,CAAC;IAEtC,UAAU;IACV,IAAI,eAAe,CAAC,IAAI,EAAE,GAAG,EAAE;QAC7B,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;KACzC;IAED,SAAS;IACT,IAAI,eAAe,CAAC,GAAG,IAAI,eAAe,CAAC,GAAG,CAAC,GAAG,EAAE;QAClD,UAAU,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;KACxC;IAED,cAAc;IACd,IAAI,eAAe,CAAC,QAAQ,IAAI,eAAe,CAAC,QAAQ,CAAC,GAAG,EAAE;QAC5D,MAAM,KAAK,GAAG,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;QACzE,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;KACtB;IAED,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,UAAU,CAAC,MAAoB,EAAE,CAAkB;IAC1D,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE;QACxB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YACtB,SAAS;SACV;QAED,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACvG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;KAC7B;AACH,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { DescriptionDictionary } from "@actions/expressions";
|
|
2
|
+
export declare function getSupportedEventTypes(event: string): string[];
|
|
3
|
+
export declare function getEventPayload(event: string, action: string): DescriptionDictionary | undefined;
|
|
4
|
+
//# sourceMappingURL=eventPayloads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventPayloads.d.ts","sourceRoot":"","sources":["../../../src/context-providers/events/eventPayloads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,qBAAqB,EAAC,MAAM,sBAAsB,CAAC;AA8FjE,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAS9D;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS,CAehG"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { data, DescriptionDictionary } from "@actions/expressions";
|
|
2
|
+
import webhookObjects from "./objects.json";
|
|
3
|
+
import webhooks from "./webhooks.json";
|
|
4
|
+
import schedule from "./schedule.json" assert { type: "json" };
|
|
5
|
+
import workflow_call from "./workflow_call.json" assert { type: "json" };
|
|
6
|
+
const customEventPayloads = {
|
|
7
|
+
schedule,
|
|
8
|
+
workflow_call
|
|
9
|
+
};
|
|
10
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any */
|
|
11
|
+
const dedupedWebhookPayloads = webhooks;
|
|
12
|
+
const objects = webhookObjects;
|
|
13
|
+
/* eslint-enable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any */
|
|
14
|
+
// Hydrated webhook payloads
|
|
15
|
+
const webhookPayloads = {};
|
|
16
|
+
// Hydrate the workflow dispatch payload if it exists
|
|
17
|
+
getWebhookPayload("workflow_dispatch", "default");
|
|
18
|
+
//
|
|
19
|
+
// Manual work-arounds for webhook issues
|
|
20
|
+
//
|
|
21
|
+
const inputs = webhookPayloads?.["workflow_dispatch"]?.["default"].bodyParameters.find(p => p.name === "inputs");
|
|
22
|
+
if (inputs) {
|
|
23
|
+
delete inputs.childParamsGroups;
|
|
24
|
+
}
|
|
25
|
+
export function getSupportedEventTypes(event) {
|
|
26
|
+
const payloads = dedupedWebhookPayloads?.[event];
|
|
27
|
+
if (!payloads) {
|
|
28
|
+
if (customEventPayloads[event]) {
|
|
29
|
+
return ["default"];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return Object.keys(payloads || {});
|
|
33
|
+
}
|
|
34
|
+
export function getEventPayload(event, action) {
|
|
35
|
+
const payload = getWebhookPayload(event, action);
|
|
36
|
+
if (!payload) {
|
|
37
|
+
// Not all events are real webhooks. Check if there is a custom payload for this event
|
|
38
|
+
const customPayload = customEventPayloads[event];
|
|
39
|
+
if (customPayload) {
|
|
40
|
+
return mergeObject(new DescriptionDictionary(), customPayload);
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
const d = new DescriptionDictionary();
|
|
45
|
+
payload.bodyParameters.forEach(p => mergeParam(d, p));
|
|
46
|
+
return d;
|
|
47
|
+
}
|
|
48
|
+
function mergeParam(target, param) {
|
|
49
|
+
if (param.childParamsGroups?.length || 0 > 0) {
|
|
50
|
+
// If there are any child params, add this param as an object
|
|
51
|
+
const d = new DescriptionDictionary();
|
|
52
|
+
param.childParamsGroups?.forEach(p => mergeParam(d, p));
|
|
53
|
+
target.add(param.name, d, param.description);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// Otherwise add as a null value. We do not care about the actual content for validation
|
|
57
|
+
// auto-completion. Possible existence and the description are enough.
|
|
58
|
+
//
|
|
59
|
+
// As a special case, if the param is already set, do not overwrite it.
|
|
60
|
+
if (target.get(param.name)) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
target.add(param.name, new data.Null(), param.description);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function mergeObject(d, toAdd) {
|
|
67
|
+
for (const [key, value] of Object.entries(toAdd)) {
|
|
68
|
+
if (value && typeof value === "object" && !d.get(key)) {
|
|
69
|
+
if (!Array.isArray(value) && Object.entries(value).length === 0) {
|
|
70
|
+
// Allow an empty object to be any value
|
|
71
|
+
d.add(key, new data.Null());
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
d.add(key, mergeObject(new DescriptionDictionary(), value));
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
d.add(key, new data.Null());
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return d;
|
|
81
|
+
}
|
|
82
|
+
function getWebhookPayload(event, action) {
|
|
83
|
+
// Is the payload already hydrated?
|
|
84
|
+
const existingPayload = webhookPayloads?.[event]?.[action];
|
|
85
|
+
if (existingPayload) {
|
|
86
|
+
return existingPayload;
|
|
87
|
+
}
|
|
88
|
+
const deduplicatedPayload = dedupedWebhookPayloads?.[event]?.[action];
|
|
89
|
+
if (!deduplicatedPayload) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
// Recreate the full payload and store it for reuse
|
|
93
|
+
const params = deduplicatedPayload.bodyParameters.map(p => fullParam(p));
|
|
94
|
+
const payload = {
|
|
95
|
+
...deduplicatedPayload,
|
|
96
|
+
bodyParameters: params
|
|
97
|
+
};
|
|
98
|
+
webhookPayloads[event] || (webhookPayloads[event] = {});
|
|
99
|
+
webhookPayloads[event][action] = payload;
|
|
100
|
+
return payload;
|
|
101
|
+
}
|
|
102
|
+
function fullParam(dedupedParam) {
|
|
103
|
+
if (typeof dedupedParam === "number") {
|
|
104
|
+
if (dedupedParam >= objects.length) {
|
|
105
|
+
throw new Error(`Unknown object ${dedupedParam}`);
|
|
106
|
+
}
|
|
107
|
+
return objects[dedupedParam];
|
|
108
|
+
}
|
|
109
|
+
return dedupedParam;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=eventPayloads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventPayloads.js","sourceRoot":"","sources":["../../../src/context-providers/events/eventPayloads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,qBAAqB,EAAC,MAAM,sBAAsB,CAAC;AAEjE,OAAO,cAAc,MAAM,gBAAgB,CAAC;AAC5C,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC,OAAO,QAAQ,MAAM,iBAAiB,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAC;AAC7D,OAAO,aAAa,MAAM,sBAAsB,CAAC,SAAQ,IAAI,EAAE,MAAM,EAAC,CAAC;AAEvE,MAAM,mBAAmB,GAA8B;IACrD,QAAQ;IACR,aAAa;CACd,CAAC;AAgEF,gGAAgG;AAChG,MAAM,sBAAsB,GAAyB,QAAe,CAAC;AACrE,MAAM,OAAO,GAAY,cAAqB,CAAC;AAC/C,+FAA+F;AAE/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