@kici-dev/sdk 0.1.16 → 0.1.18

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 (70) hide show
  1. package/dist/api-types.d.ts +25 -1
  2. package/dist/api-types.js +29 -3
  3. package/dist/approval.js +1 -1
  4. package/dist/cache-types.js +1 -1
  5. package/dist/context.d.ts +75 -2
  6. package/dist/context.js +14 -2
  7. package/dist/dynamic-group.js +1 -1
  8. package/dist/errors.js +3 -1
  9. package/dist/events/define-event.js +1 -1
  10. package/dist/events/event-payloads.js +1 -1
  11. package/dist/events/event-payloads.test-d.js +1 -1
  12. package/dist/events/index.js +1 -1
  13. package/dist/events/types.js +1 -1
  14. package/dist/fixture.js +1 -1
  15. package/dist/hooks/index.js +1 -1
  16. package/dist/hooks/types.js +1 -1
  17. package/dist/idempotent.js +1 -1
  18. package/dist/index.d.ts +10 -5
  19. package/dist/index.js +7 -4
  20. package/dist/job.js +21 -7
  21. package/dist/matrix/expand.d.ts +1 -24
  22. package/dist/matrix/expand.js +2 -65
  23. package/dist/matrix/index.js +1 -1
  24. package/dist/matrix/types.d.ts +2 -19
  25. package/dist/matrix/types.js +1 -1
  26. package/dist/needs-context.d.ts +32 -0
  27. package/dist/needs-context.js +44 -0
  28. package/dist/outputs.d.ts +12 -0
  29. package/dist/outputs.js +37 -2
  30. package/dist/provenance-types.d.ts +38 -0
  31. package/dist/provenance-types.js +10 -0
  32. package/dist/rules/evaluator.js +1 -1
  33. package/dist/rules/index.js +1 -1
  34. package/dist/rules/rule.js +1 -1
  35. package/dist/rules/types.js +1 -1
  36. package/dist/secrets.js +1 -1
  37. package/dist/step.js +1 -1
  38. package/dist/triggers/comment.js +1 -1
  39. package/dist/triggers/create.js +1 -1
  40. package/dist/triggers/delete.js +1 -1
  41. package/dist/triggers/dispatch.js +1 -1
  42. package/dist/triggers/fork.js +1 -1
  43. package/dist/triggers/generic-webhook.js +1 -1
  44. package/dist/triggers/index.js +1 -1
  45. package/dist/triggers/job-complete.js +1 -1
  46. package/dist/triggers/kici-event.js +1 -1
  47. package/dist/triggers/lifecycle.js +1 -1
  48. package/dist/triggers/pr.js +1 -1
  49. package/dist/triggers/push.js +1 -1
  50. package/dist/triggers/release.js +1 -1
  51. package/dist/triggers/review-comment.js +1 -1
  52. package/dist/triggers/review.js +1 -1
  53. package/dist/triggers/schedule.js +1 -1
  54. package/dist/triggers/star.js +1 -1
  55. package/dist/triggers/status.js +1 -1
  56. package/dist/triggers/tag.js +1 -1
  57. package/dist/triggers/types.js +1 -1
  58. package/dist/triggers/watch.js +1 -1
  59. package/dist/triggers/webhook.js +1 -1
  60. package/dist/triggers/workflow-complete.js +1 -1
  61. package/dist/triggers/workflow-run.js +1 -1
  62. package/dist/types.d.ts +162 -28
  63. package/dist/types.js +25 -5
  64. package/dist/validation/dag.js +1 -1
  65. package/dist/validation/index.js +1 -1
  66. package/dist/wait-for.js +1 -1
  67. package/dist/workflow.js +1 -1
  68. package/package.json +4 -5
  69. package/sbom.spdx.json +229 -179
  70. /package/dist/{chunk-gOLHoazu.js → chunk-BTugEXQM.js} +0 -0
@@ -0,0 +1,44 @@
1
+ import "./chunk-BTugEXQM.js";
2
+ import { createSnapshotOutputProxy } from "./outputs.js";
3
+ //#region src/needs-context.ts
4
+ function needKey(need) {
5
+ if (typeof need === "string") return {
6
+ kind: "job",
7
+ key: need
8
+ };
9
+ if ("group" in need) return {
10
+ kind: "group",
11
+ key: need.group
12
+ };
13
+ if ("name" in need) return {
14
+ kind: "job",
15
+ key: need.name
16
+ };
17
+ return {
18
+ kind: "job",
19
+ key: need.name
20
+ };
21
+ }
22
+ /**
23
+ * Resolve declared needs against a frozen snapshot into the `ctx.needs` map.
24
+ *
25
+ * - A single static/named-job need resolves to `{ result: <proxy over jobs[name]> }`.
26
+ * - A `dynamicGroup(...)` need resolves to an ordered array of `{ name, result }`,
27
+ * one entry per group member in the snapshot's deterministic eval order.
28
+ */
29
+ function buildNeedsContext(snapshot, declaredNeeds) {
30
+ const out = {};
31
+ for (const need of declaredNeeds) {
32
+ const { kind, key } = needKey(need);
33
+ if (kind === "group") out[key] = (snapshot.groups[key] ?? []).map((name) => ({
34
+ name,
35
+ result: createSnapshotOutputProxy(name, snapshot.jobs[name])
36
+ }));
37
+ else out[key] = { result: createSnapshotOutputProxy(key, snapshot.jobs[key]) };
38
+ }
39
+ return out;
40
+ }
41
+ //#endregion
42
+ export { buildNeedsContext };
43
+
44
+ //# sourceMappingURL=needs-context.js.map
package/dist/outputs.d.ts CHANGED
@@ -61,6 +61,18 @@ export declare function createStepOutputProxy<T>(stepName: string): OutputProxy<
61
61
  * @returns A Proxy that resolves property access at runtime
62
62
  */
63
63
  export declare function createJobOutputProxy(jobName: string): OutputProxy<any>;
64
+ /**
65
+ * Output proxy bound to a specific outputs object (not the module-global map).
66
+ *
67
+ * Used to expose a frozen upstream-job snapshot as `ctx.needs.<job>.result` for
68
+ * result-aware dynamic generators. The snapshot is captured once at eval and
69
+ * replayed unchanged on re-eval, so the proxy reads a fixed `outputs` object
70
+ * rather than the live module-global job-outputs map.
71
+ *
72
+ * @param jobName - The upstream job whose outputs to proxy (used in error text)
73
+ * @param outputs - The frozen outputs object, or undefined if the job produced none
74
+ */
75
+ export declare function createSnapshotOutputProxy(jobName: string, outputs: Record<string, unknown> | undefined): OutputProxy<any>;
64
76
  /**
65
77
  * Resolve step outputs by step reference (Step object or bare function).
66
78
  * Used by ctx.outputsOf() implementation.
package/dist/outputs.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./chunk-gOLHoazu.js";
1
+ import "./chunk-BTugEXQM.js";
2
2
  //#region src/outputs.ts
3
3
  /**
4
4
  * Well-known string property names that should delegate to Reflect rather than throwing.
@@ -140,6 +140,41 @@ function createJobOutputProxy(jobName) {
140
140
  });
141
141
  }
142
142
  /**
143
+ * Output proxy bound to a specific outputs object (not the module-global map).
144
+ *
145
+ * Used to expose a frozen upstream-job snapshot as `ctx.needs.<job>.result` for
146
+ * result-aware dynamic generators. The snapshot is captured once at eval and
147
+ * replayed unchanged on re-eval, so the proxy reads a fixed `outputs` object
148
+ * rather than the live module-global job-outputs map.
149
+ *
150
+ * @param jobName - The upstream job whose outputs to proxy (used in error text)
151
+ * @param outputs - The frozen outputs object, or undefined if the job produced none
152
+ */
153
+ function createSnapshotOutputProxy(jobName, outputs) {
154
+ return new Proxy({}, {
155
+ get(_target, prop, receiver) {
156
+ if (typeof prop === "symbol") return Reflect.get(_target, prop, receiver);
157
+ if (WELL_KNOWN_STRING_PROPS.has(prop)) return Reflect.get(_target, prop, receiver);
158
+ if (!outputs) throw new Error(`Upstream job '${jobName}' has no frozen outputs in the generator snapshot`);
159
+ return outputs[prop];
160
+ },
161
+ ownKeys() {
162
+ return outputs ? Reflect.ownKeys(outputs) : [];
163
+ },
164
+ has(_target, prop) {
165
+ return outputs ? prop in outputs : false;
166
+ },
167
+ getOwnPropertyDescriptor(_target, prop) {
168
+ if (!outputs) return void 0;
169
+ if (prop in outputs) return {
170
+ configurable: true,
171
+ enumerable: true,
172
+ value: outputs[prop]
173
+ };
174
+ }
175
+ });
176
+ }
177
+ /**
143
178
  * Resolve step outputs by step reference (Step object or bare function).
144
179
  * Used by ctx.outputsOf() implementation.
145
180
  *
@@ -175,6 +210,6 @@ function resolveJobOutputs(ref, outputsMap) {
175
210
  return outputs;
176
211
  }
177
212
  //#endregion
178
- export { createJobOutputProxy, createStepOutputProxy, getJobOutputsMap, getStepOutputsMap, getStepRefMap, resolveJobOutputs, resolveStepOutputs, setJobOutputsMap, setStepOutputsMap, setStepRefMap };
213
+ export { createJobOutputProxy, createSnapshotOutputProxy, createStepOutputProxy, getJobOutputsMap, getStepOutputsMap, getStepRefMap, resolveJobOutputs, resolveStepOutputs, setJobOutputsMap, setStepOutputsMap, setStepRefMap };
179
214
 
180
215
  //# sourceMappingURL=outputs.js.map
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Types for `ctx.attestProvenance()` — the imperative step helper that builds,
3
+ * signs, and persists a KiCI build-provenance attestation for a produced
4
+ * artifact.
5
+ */
6
+ /**
7
+ * The artifact being attested. Either supply a precomputed digest, or a path
8
+ * (relative to the step working directory) the agent will digest with SHA-256.
9
+ */
10
+ export type ProvenanceSubjectInput = {
11
+ name: string;
12
+ digest: {
13
+ sha256?: string;
14
+ sha512?: string;
15
+ };
16
+ } | {
17
+ name: string;
18
+ path: string;
19
+ };
20
+ export interface AttestProvenanceOptions {
21
+ subject: ProvenanceSubjectInput;
22
+ /** OIDC audience for the identity token (defaults to 'kici-provenance'). */
23
+ audience?: string;
24
+ }
25
+ export interface AttestProvenanceResult {
26
+ /** Object-storage key the signed bundle was written to. */
27
+ storageKey: string;
28
+ /** Primary subject digest (lowercase hex). */
29
+ subjectDigest: string;
30
+ /** Media type of the persisted bundle. */
31
+ bundleMediaType: string;
32
+ }
33
+ /** Discriminate a path subject from a precomputed-digest subject. */
34
+ export declare function provenanceSubjectIsPath(s: ProvenanceSubjectInput): s is {
35
+ name: string;
36
+ path: string;
37
+ };
38
+ //# sourceMappingURL=provenance-types.d.ts.map
@@ -0,0 +1,10 @@
1
+ import "./chunk-BTugEXQM.js";
2
+ //#region src/provenance-types.ts
3
+ /** Discriminate a path subject from a precomputed-digest subject. */
4
+ function provenanceSubjectIsPath(s) {
5
+ return "path" in s;
6
+ }
7
+ //#endregion
8
+ export { provenanceSubjectIsPath };
9
+
10
+ //# sourceMappingURL=provenance-types.js.map
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  import { toErrorMessage } from "@kici-dev/core";
3
3
  //#region src/rules/evaluator.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  import { rule, skip } from "./rule.js";
3
3
  import { evaluateRules } from "./evaluator.js";
4
4
  import { isEventType } from "../events/event-payloads.js";
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  //#region src/rules/rule.ts
3
3
  /**
4
4
  * Implementation of rule() factory.
@@ -1,2 +1,2 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  export {};
package/dist/secrets.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./chunk-gOLHoazu.js";
1
+ import "./chunk-BTugEXQM.js";
2
2
  import { SecretNotFoundError } from "./errors.js";
3
3
  //#region src/secrets.ts
4
4
  /**
package/dist/step.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./chunk-gOLHoazu.js";
1
+ import "./chunk-BTugEXQM.js";
2
2
  import { createStepOutputProxy } from "./outputs.js";
3
3
  //#region src/step.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  import { asArray, toBranchPattern } from "./types.js";
3
3
  //#region src/triggers/comment.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  import { asArray, toBranchPattern } from "./types.js";
3
3
  //#region src/triggers/create.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  import { asArray, toBranchPattern } from "./types.js";
3
3
  //#region src/triggers/delete.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  import { asArray, toBranchPattern } from "./types.js";
3
3
  //#region src/triggers/dispatch.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  import { asArray, toBranchPattern } from "./types.js";
3
3
  //#region src/triggers/fork.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  //#region src/triggers/generic-webhook.ts
3
3
  /**
4
4
  * Create a generic webhook trigger configuration.
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  import { DEFAULT_PR_EVENTS, toBranchPattern } from "./types.js";
3
3
  import { pr } from "./pr.js";
4
4
  import { push } from "./push.js";
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  //#region src/triggers/job-complete.ts
3
3
  /**
4
4
  * Create a job completion trigger configuration.
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  //#region src/triggers/kici-event.ts
3
3
  /**
4
4
  * Create a KiCI custom event trigger configuration.
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  //#region src/triggers/lifecycle.ts
3
3
  /**
4
4
  * Create a lifecycle trigger configuration.
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  import { DEFAULT_PR_EVENTS, asArray, toBranchPattern } from "./types.js";
3
3
  //#region src/triggers/pr.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  import { asArray, toBranchPattern } from "./types.js";
3
3
  //#region src/triggers/push.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  import { asArray, toBranchPattern } from "./types.js";
3
3
  //#region src/triggers/release.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  import { asArray, toBranchPattern } from "./types.js";
3
3
  //#region src/triggers/review-comment.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  import { asArray, toBranchPattern } from "./types.js";
3
3
  //#region src/triggers/review.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  //#region src/triggers/schedule.ts
3
3
  /**
4
4
  * Create a schedule trigger configuration.
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  import { asArray, toBranchPattern } from "./types.js";
3
3
  //#region src/triggers/star.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  import { asArray, toBranchPattern } from "./types.js";
3
3
  //#region src/triggers/status.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  import { asArray, toBranchPattern } from "./types.js";
3
3
  //#region src/triggers/tag.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  //#region src/triggers/types.ts
3
3
  /**
4
4
  * Default PR events when pr() is called without explicit events.
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  import { asArray, toBranchPattern } from "./types.js";
3
3
  //#region src/triggers/watch.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  import { asArray, toBranchPattern } from "./types.js";
3
3
  //#region src/triggers/webhook.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  //#region src/triggers/workflow-complete.ts
3
3
  /**
4
4
  * Create a workflow completion trigger configuration.
@@ -1,4 +1,4 @@
1
- import "../chunk-gOLHoazu.js";
1
+ import "../chunk-BTugEXQM.js";
2
2
  import { asArray, toBranchPattern } from "./types.js";
3
3
  //#region src/triggers/workflow-run.ts
4
4
  /**