@scarn/sdk 0.8.2 → 0.8.3

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 (66) hide show
  1. package/dist/automations/define-automation.d.ts +20 -0
  2. package/dist/automations/index.d.ts +8 -0
  3. package/dist/automations/index.js +21 -0
  4. package/dist/automations/targets.d.ts +36 -0
  5. package/dist/automations/types.d.ts +116 -0
  6. package/dist/{chunk-nb0nkt71.js → chunk-01nfqm18.js} +1 -0
  7. package/dist/chunk-0vzq22dj.js +73 -0
  8. package/dist/chunk-11hbmexe.js +250 -0
  9. package/dist/{chunk-2fn95pdd.js → chunk-3gy0cb5f.js} +5 -1
  10. package/dist/{chunk-qrasq5xe.js → chunk-43y7tfn4.js} +33 -414
  11. package/dist/chunk-61jf8b6s.js +53 -0
  12. package/dist/chunk-76d1bwwz.js +119 -0
  13. package/dist/chunk-8z1wa3kd.js +109 -0
  14. package/dist/{chunk-p7yrcmqm.js → chunk-cnxaagfj.js} +2 -52
  15. package/dist/{chunk-cdanncng.js → chunk-ejzfdm1z.js} +21 -5
  16. package/dist/{chunk-gds7w7zh.js → chunk-fgfhvsee.js} +1 -4
  17. package/dist/{chunk-x9788y82.js → chunk-fyfvp6jx.js} +30 -13
  18. package/dist/{chunk-mz53r914.js → chunk-jj9pezwb.js} +22 -119
  19. package/dist/{chunk-8pyhrdgy.js → chunk-wnfj3wyx.js} +55 -11
  20. package/dist/chunk-x0hjhqrf.js +416 -0
  21. package/dist/chunk-y11p1q7r.js +159 -0
  22. package/dist/client.js +4 -2
  23. package/dist/contracts/automation-document/index.d.ts +5 -0
  24. package/dist/contracts/automation-document/index.js +34 -0
  25. package/dist/contracts/automation-document/schema.d.ts +363 -0
  26. package/dist/contracts/pipeline-document/built-ins.d.ts +1 -1
  27. package/dist/contracts/pipeline-document/index.js +9 -7
  28. package/dist/contracts/pipeline-document/schema.d.ts +3 -3
  29. package/dist/contracts/work-item-changes.d.ts +6 -0
  30. package/dist/contracts/work-item-changes.js +1 -0
  31. package/dist/defaults/index.js +2 -2
  32. package/dist/definitions/automations/automations-client.d.ts +178 -0
  33. package/dist/definitions/automations/index.d.ts +1 -0
  34. package/dist/definitions/automations/index.js +12 -0
  35. package/dist/definitions/pipelines/index.d.ts +0 -1
  36. package/dist/definitions/pipelines/index.js +4 -12
  37. package/dist/definitions/pipelines/work-item-fields.d.ts +11 -22
  38. package/dist/definitions/steps/define-code-step.d.ts +3 -1
  39. package/dist/definitions/steps/define-step.d.ts +13 -0
  40. package/dist/definitions/steps/index.js +9 -6
  41. package/dist/definitions/steps/repo.d.ts +11 -3
  42. package/dist/definitions/steps/runtime.d.ts +11 -12
  43. package/dist/definitions/steps/step-definitions-client.d.ts +12 -0
  44. package/dist/definitions/steps/step-features.d.ts +2 -2
  45. package/dist/definitions/steps/step-handle.d.ts +6 -1
  46. package/dist/definitions/validation/index.js +2 -2
  47. package/dist/generated/index.d.ts +2 -2
  48. package/dist/generated/sdk.gen.d.ts +37 -5
  49. package/dist/generated/types.gen.d.ts +2756 -1875
  50. package/dist/index.d.ts +1 -0
  51. package/dist/index.js +40 -30
  52. package/dist/pipelines/define-pipeline.d.ts +7 -7
  53. package/dist/pipelines/handles.d.ts +0 -5
  54. package/dist/pipelines/index.js +7 -4
  55. package/dist/pipelines/types.d.ts +13 -1
  56. package/dist/push/collect-definitions.d.ts +3 -8
  57. package/dist/push/collect-pipeline-documents.d.ts +13 -3
  58. package/dist/push/index.d.ts +2 -2
  59. package/dist/push/index.js +87 -124
  60. package/dist/push/push-from-directory.d.ts +10 -6
  61. package/dist/repo-config.d.ts +14 -4
  62. package/dist/repo-config.js +5 -1
  63. package/dist/task-plane-client.d.ts +40 -0
  64. package/package.json +13 -1
  65. package/dist/chunk-ra53p0v8.js +0 -256
  66. package/dist/definitions/pipelines/define-default-pipeline-assignment.d.ts +0 -263
@@ -1,263 +0,0 @@
1
- import type { PipelineDefinition } from "../../pipelines/define-pipeline";
2
- import { type WorkItemTopLevelField, type WorkItemTopLevelFieldTypeMap } from "./work-item-fields";
3
- /**
4
- * The reserved filename for the default pipeline assignment file.
5
- * This file is NOT treated as a pipeline definition by the push scanner.
6
- */
7
- export declare const DEFAULT_PIPELINE_ASSIGNMENT_FILENAME = "default-pipeline-assignment.ts";
8
- type ConditionOperator = "equal" | "notEqual" | "lessThan" | "lessThanInclusive" | "greaterThan" | "greaterThanInclusive" | "in" | "notIn" | "contains" | "doesNotContain";
9
- type LeafCondition = {
10
- readonly _tag: "leaf";
11
- /** Top-level fact name: "workItem" or "context". */
12
- readonly fact: string;
13
- /** JSONPath within the fact value, e.g. "$.fields.status". */
14
- readonly path?: string;
15
- readonly operator: ConditionOperator;
16
- readonly value: unknown;
17
- };
18
- type GroupCondition = {
19
- readonly _tag: "group";
20
- readonly mode: "all" | "any";
21
- readonly conditions: AssignmentCondition[];
22
- };
23
- type AssignmentCondition = LeafCondition | GroupCondition;
24
- export type AssignOutcome = {
25
- readonly _tag: "assign";
26
- readonly pipelineKey: string;
27
- };
28
- /** What `assign(...)` accepts: a pipeline key, or a `definePipeline` value. */
29
- export type AssignablePipeline = string | Pick<PipelineDefinition, "_tag" | "key">;
30
- export type SkipOutcome = {
31
- readonly _tag: "skip";
32
- };
33
- export type DefaultPipelineAssignmentOutcome = AssignOutcome | SkipOutcome;
34
- export type AssignmentRule = {
35
- readonly _tag: "assignment_rule";
36
- readonly conditions: AssignmentCondition[];
37
- readonly mode: "all" | "any";
38
- readonly outcome: DefaultPipelineAssignmentOutcome;
39
- };
40
- /** A leaf condition; nestable in a group or terminable with `.then()`. */
41
- export interface AssignmentLeaf {
42
- then(outcome: DefaultPipelineAssignmentOutcome): AssignmentRule;
43
- /** @internal */
44
- readonly _condition: AssignmentCondition;
45
- }
46
- /** A group condition (`all`/`any`); nestable or terminable with `.then()`. */
47
- export interface AssignmentGroup {
48
- then(outcome: DefaultPipelineAssignmentOutcome): AssignmentRule;
49
- /** @internal */
50
- readonly _condition: AssignmentCondition;
51
- }
52
- type AssignmentNestable = AssignmentLeaf | AssignmentGroup;
53
- /**
54
- * `.gt`/`.gte`/`.lt`/`.lte` are only ever meaningful for numeric fields.
55
- * Intersected onto `AssignmentFieldRef<T>` only when `T` is (or includes)
56
- * `number`, so e.g. `workItem.title.gt(...)` doesn't even type-check, let
57
- * alone appear in autocomplete.
58
- */
59
- type NumericComparators = {
60
- gt(value: number): AssignmentLeaf;
61
- gte(value: number): AssignmentLeaf;
62
- lt(value: number): AssignmentLeaf;
63
- lte(value: number): AssignmentLeaf;
64
- };
65
- /**
66
- * Comparator-bound reference to a work-item field or context fact.
67
- *
68
- * `T` is the field's value type (defaulting to `unknown`, which preserves
69
- * the pre-generic behavior for any caller that doesn't otherwise constrain
70
- * it). `.contains`/`.doesNotContain` narrow to the array element type when
71
- * `T` is an array — json-rules-engine's `contains`/`doesNotContain`
72
- * operators check array-membership (or substring-membership for strings)
73
- * against the fact's actual runtime shape, so an array-typed field's
74
- * `.contains(...)` should accept one element, not the whole array.
75
- */
76
- export type AssignmentFieldRef<T = unknown> = {
77
- eq(value: T): AssignmentLeaf;
78
- ne(value: T): AssignmentLeaf;
79
- in(values: ReadonlyArray<T>): AssignmentLeaf;
80
- notIn(values: ReadonlyArray<T>): AssignmentLeaf;
81
- contains(value: T extends ReadonlyArray<infer U> ? U : T): AssignmentLeaf;
82
- doesNotContain(value: T extends ReadonlyArray<infer U> ? U : T): AssignmentLeaf;
83
- } & (T extends number ? NumericComparators : Record<string, never>);
84
- /** Comparator-bound accessor for the work item passed to `defaultPipelineAssignment`. */
85
- export type WorkItemAssignmentAccessor = {
86
- [K in WorkItemTopLevelField]: AssignmentFieldRef<WorkItemTopLevelFieldTypeMap[K]>;
87
- } & {
88
- /**
89
- * Accessor for a platform-specific field (Jira custom field, GitHub label,
90
- * etc.) stored in the work item's `fields` bag. Since `fields` keys and
91
- * value shapes are platform- and project-dependent, there is no static
92
- * schema to check either against by default.
93
- *
94
- * Two independent, optional type parameters:
95
- * - `TName` constrains the `name` argument itself — pass a literal union
96
- * of known field names (e.g. the `WorkItemFieldName` type
97
- * `scarn pipelines pull` generates into `work-item-fields.ts`) to get
98
- * compile-time validation and autocomplete on the field name.
99
- * - `TValue` types the comparator (`.eq`/`.gte`/etc.) argument, exactly
100
- * like the top-level accessors above — pass it for a known-shaped
101
- * custom field (e.g. a numeric one).
102
- * Both default to permissive types, so `workItem.field(name)` with no
103
- * type arguments keeps working exactly as before.
104
- *
105
- * @example
106
- * workItem.field("issueType").eq("bug")
107
- * workItem.field("labels").contains("regression")
108
- * workItem.field<WorkItemFieldName>("issueType").eq("bug")
109
- * workItem.field<WorkItemFieldName, number>("storyPoints").gte(3)
110
- */
111
- field<TName extends string = string, TValue = unknown>(name: TName): AssignmentFieldRef<TValue>;
112
- };
113
- export type DefaultPipelineAssignmentCtx = {
114
- /**
115
- * Work-item accessor: top-level properties (`workItem.title`,
116
- * `workItem.platform`, `workItem.url`, ...) plus `workItem.field(name)`
117
- * for the platform-specific `fields` bag.
118
- *
119
- * @example
120
- * workItem.field("issueType").eq("bug").then(assign("bug-triage"))
121
- * workItem.field("labels").contains("regression").then(assign("regression-review"))
122
- * workItem.field("status").eq("resolved").then(skip())
123
- * workItem.platform.eq("github").then(assign("github-triage"))
124
- * workItem.title.contains("[urgent]").then(assign("urgent-triage"))
125
- */
126
- workItem: WorkItemAssignmentAccessor;
127
- /**
128
- * Context facts for the current ingestion event.
129
- * `context.isNew` is `true` when the work item is being created for the first time.
130
- *
131
- * @example
132
- * context.isNew.eq(true).then(assign("onboarding"))
133
- */
134
- context: {
135
- isNew: AssignmentFieldRef<boolean>;
136
- };
137
- /**
138
- * Outcome: assign the work item to the given pipeline, by key or by the
139
- * `definePipeline` value a pipeline file default-exports.
140
- * Used in both `rules` (via `.then(assign(...))`) and `default`.
141
- *
142
- * @example
143
- * workItem.field("issueType").eq("bug").then(assign("bug-triage"))
144
- */
145
- assign: (pipeline: AssignablePipeline) => AssignOutcome;
146
- /**
147
- * Outcome: do not assign any pipeline to this work item.
148
- * Used in both `rules` (via `.then(skip())`) and `default`.
149
- *
150
- * @example
151
- * workItem.field("status").eq("resolved").then(skip())
152
- */
153
- skip: () => SkipOutcome;
154
- /**
155
- * All nested conditions must match.
156
- *
157
- * @example
158
- * all(
159
- * workItem.field("issueType").eq("bug"),
160
- * workItem.field("priority").eq("high"),
161
- * ).then(assign("bug-triage"))
162
- */
163
- all: (...refs: AssignmentNestable[]) => AssignmentGroup;
164
- /**
165
- * Any nested condition must match.
166
- *
167
- * @example
168
- * any(
169
- * workItem.field("status").eq("resolved"),
170
- * workItem.field("status").eq("closed"),
171
- * ).then(skip())
172
- */
173
- any: (...refs: AssignmentNestable[]) => AssignmentGroup;
174
- };
175
- export type DefaultPipelineAssignmentInput = {
176
- /**
177
- * The outcome when no rule matches. Use `assign(pipeline)` to assign a
178
- * specific pipeline, or `skip()` to do nothing.
179
- */
180
- default: DefaultPipelineAssignmentOutcome;
181
- /**
182
- * Ordered list of rules evaluated against each incoming work item.
183
- * First match wins; unmatched work items fall through to `default`.
184
- */
185
- rules: AssignmentRule[];
186
- };
187
- export type DefaultPipelineAssignmentSpec = {
188
- readonly _tag: "default_pipeline_assignment";
189
- readonly default: DefaultPipelineAssignmentOutcome;
190
- readonly rules: AssignmentRule[];
191
- };
192
- /**
193
- * Define a default pipeline assignment policy for this project.
194
- *
195
- * Pass a callback that receives a context object with `workItem`, `context`,
196
- * `assign`, `skip`, `all`, and `any`. Return an object with `default` and
197
- * `rules`.
198
- *
199
- * `default` is the outcome when no rule matches — either `assign(key)`
200
- * or `skip()`.
201
- *
202
- * `rules` is an ordered list; the first matching rule wins.
203
- *
204
- * @example
205
- * import { defaultPipelineAssignment } from "@scarn/sdk/definitions/pipelines";
206
- *
207
- * export default defaultPipelineAssignment(({ workItem, any, assign, skip }) => ({
208
- * default: assign("bug-triage"),
209
- * rules: [
210
- * any(
211
- * workItem.field("status").eq("resolved"),
212
- * workItem.field("status").eq("manual support"),
213
- * ).then(skip()),
214
- * workItem.field("issueType").eq("bug").then(assign("bug-triage")),
215
- * ],
216
- * }));
217
- */
218
- export declare function defaultPipelineAssignment(callback: (ctx: DefaultPipelineAssignmentCtx) => DefaultPipelineAssignmentInput): DefaultPipelineAssignmentSpec;
219
- type SerializedLeafCondition = {
220
- fact: string;
221
- path?: string;
222
- operator: string;
223
- value: unknown;
224
- };
225
- type SerializedConditionGroup = {
226
- all?: SerializedConditionNode[];
227
- any?: SerializedConditionNode[];
228
- };
229
- type SerializedConditionNode = SerializedLeafCondition | SerializedConditionGroup;
230
- type SerializedAssignmentRule = {
231
- conditions: SerializedConditionGroup;
232
- event: {
233
- type: string;
234
- params?: Record<string, unknown>;
235
- };
236
- };
237
- export type SerializedDefaultPipelineAssignment = {
238
- /**
239
- * Pipeline key for the primary assign pipeline; resolved to a
240
- * `pipelineDefinitionId` by the push layer. Null when `default`
241
- * is `skip()` and no rule assigns a pipeline (push will reject this).
242
- */
243
- pipelineDefinitionKey: string;
244
- rulesJson: {
245
- rules: SerializedAssignmentRule[];
246
- };
247
- defaultEventType: "assign" | "skip";
248
- defaultEventParamsJson: Record<string, unknown> | null;
249
- allowedEventTypes: Array<"assign" | "skip">;
250
- };
251
- /**
252
- * Serialize a `DefaultPipelineAssignmentSpec` to the wire format.
253
- *
254
- * `pipelineDefinitionKey` is the key of the primary assign pipeline —
255
- * taken from `default` if it's `assign(...)`, otherwise from the first rule
256
- * that assigns a pipeline. The push layer rejects specs with no assign outcome.
257
- */
258
- export declare function serializeDefaultPipelineAssignment(spec: DefaultPipelineAssignmentSpec): SerializedDefaultPipelineAssignment;
259
- /**
260
- * Type guard: returns true if `value` is a `DefaultPipelineAssignmentSpec`.
261
- */
262
- export declare function isDefaultPipelineAssignmentSpec(value: unknown): value is DefaultPipelineAssignmentSpec;
263
- export {};