@scarn/sdk 0.8.1 → 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-dp86pa6m.js → chunk-01nfqm18.js} +5 -1
  7. package/dist/chunk-0vzq22dj.js +73 -0
  8. package/dist/chunk-11hbmexe.js +250 -0
  9. package/dist/{chunk-700xe701.js → chunk-3gy0cb5f.js} +5 -1
  10. package/dist/{chunk-102vfpw4.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-3ctaaseb.js → chunk-fyfvp6jx.js} +48 -21
  18. package/dist/{chunk-mz53r914.js → chunk-jj9pezwb.js} +22 -119
  19. package/dist/{chunk-vfeytkqx.js → chunk-wnfj3wyx.js} +106 -33
  20. package/dist/chunk-x0hjhqrf.js +416 -0
  21. package/dist/chunk-y11p1q7r.js +159 -0
  22. package/dist/client.js +6 -4
  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 +51 -0
  30. package/dist/contracts/work-item-changes.js +68 -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 +29 -1
  40. package/dist/definitions/steps/index.js +12 -7
  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 +18 -0
  44. package/dist/definitions/steps/step-features.d.ts +2 -2
  45. package/dist/definitions/steps/step-handle.d.ts +8 -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 +66 -11
  49. package/dist/generated/types.gen.d.ts +5513 -3488
  50. package/dist/index.d.ts +1 -0
  51. package/dist/index.js +61 -49
  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 +90 -127
  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 +42 -0
  64. package/package.json +17 -1
  65. package/dist/chunk-zm72ksz0.js +0 -256
  66. package/dist/definitions/pipelines/define-default-pipeline-assignment.d.ts +0 -263
@@ -1,256 +0,0 @@
1
- // @bun
2
- import {
3
- PipelineDefinitions,
4
- createClient
5
- } from "./chunk-vfeytkqx.js";
6
- import {
7
- exports_external
8
- } from "./chunk-skzxcba3.js";
9
-
10
- // src/definitions/pipelines/pipeline-definitions-client.ts
11
- var pipelineDocumentIssueSchema = exports_external.object({
12
- code: exports_external.string(),
13
- path: exports_external.string(),
14
- message: exports_external.string(),
15
- hint: exports_external.string().optional()
16
- });
17
-
18
- class PipelineDefinitionsApiError extends Error {
19
- code;
20
- issues;
21
- constructor(error) {
22
- super(error.detail ?? error.title ?? JSON.stringify(error));
23
- this.name = "PipelineDefinitionsApiError";
24
- this.code = error.code;
25
- this.issues = documentIssuesOf(error.meta);
26
- }
27
- }
28
- function documentIssuesOf(meta) {
29
- const errors = meta?.["errors"];
30
- if (!Array.isArray(errors))
31
- return [];
32
- return errors.flatMap((error) => {
33
- const parsed = pipelineDocumentIssueSchema.safeParse(error);
34
- return parsed.success ? [parsed.data] : [];
35
- });
36
- }
37
- function unwrap(result) {
38
- if (result.error !== undefined) {
39
- throw new PipelineDefinitionsApiError(result.error);
40
- }
41
- return result.data;
42
- }
43
- function createPipelineDefinitionsClient(baseUrl) {
44
- const client = createClient({ baseUrl });
45
- return buildPipelineDefinitionsClient(new PipelineDefinitions({ client }));
46
- }
47
- var buildPipelineDefinitionsClient = (pipelineDefinitions) => ({
48
- listByProjectId: async (projectId, options) => unwrap(await pipelineDefinitions.listPipelineDefinitions({
49
- path: { projectId },
50
- headers: options?.headers
51
- })),
52
- get: async (pipelineDefinitionId, options) => unwrap(await pipelineDefinitions.getPipelineDefinition({
53
- path: { pipelineDefinitionId },
54
- headers: options?.headers
55
- })),
56
- create: async (input, options) => unwrap(await pipelineDefinitions.createPipelineDefinition({
57
- body: input,
58
- headers: options?.headers
59
- })),
60
- publishVersion: async (pipelineDefinitionId, document, options) => unwrap(await pipelineDefinitions.publishPipelineDefinitionVersion({
61
- path: { pipelineDefinitionId },
62
- body: { document },
63
- headers: options?.headers
64
- })),
65
- activateVersion: async (pipelineDefinitionId, version, options) => unwrap(await pipelineDefinitions.activatePipelineDefinitionVersion({
66
- path: { pipelineDefinitionId, version },
67
- headers: options?.headers
68
- })),
69
- listVersions: async (pipelineDefinitionId, options) => unwrap(await pipelineDefinitions.listPipelineDefinitionVersions({
70
- path: { pipelineDefinitionId },
71
- headers: options?.headers
72
- })),
73
- getVersion: async (pipelineDefinitionId, version, options) => unwrap(await pipelineDefinitions.getPipelineDefinitionVersion({
74
- path: { pipelineDefinitionId, version },
75
- headers: options?.headers
76
- }))
77
- });
78
- // src/definitions/pipelines/work-item-fields.ts
79
- var WORK_ITEM_TOP_LEVEL_FIELDS = [
80
- "id",
81
- "projectId",
82
- "platform",
83
- "platformId",
84
- "platformKey",
85
- "url",
86
- "title",
87
- "description",
88
- "sourceCreatedAt",
89
- "sourceUpdatedAt",
90
- "createdByUserId",
91
- "parentWorkItemId",
92
- "createdAt",
93
- "updatedAt"
94
- ];
95
- var WORK_ITEM_FIELDS_PATH_PREFIX = "fields.";
96
- function resolveWorkItemFieldPath(record, path) {
97
- if (typeof record !== "object" || record === null)
98
- return;
99
- const asRecord = record;
100
- if (path.startsWith(WORK_ITEM_FIELDS_PATH_PREFIX)) {
101
- const fieldName = path.slice(WORK_ITEM_FIELDS_PATH_PREFIX.length);
102
- const fields = asRecord["fields"];
103
- if (typeof fields !== "object" || fields === null)
104
- return;
105
- return fields[fieldName];
106
- }
107
- return asRecord[path];
108
- }
109
-
110
- // src/definitions/pipelines/define-default-pipeline-assignment.ts
111
- var DEFAULT_PIPELINE_ASSIGNMENT_FILENAME = "default-pipeline-assignment.ts";
112
- function makeLeaf(fact, path, operator, value) {
113
- const condition = {
114
- _tag: "leaf",
115
- fact,
116
- ...path ? { path } : {},
117
- operator,
118
- value
119
- };
120
- return {
121
- _condition: condition,
122
- then(outcome) {
123
- return {
124
- _tag: "assignment_rule",
125
- conditions: [condition],
126
- mode: "all",
127
- outcome
128
- };
129
- }
130
- };
131
- }
132
- function makeFieldRef(fact, path) {
133
- const untyped = {
134
- eq: (v) => makeLeaf(fact, path, "equal", v),
135
- ne: (v) => makeLeaf(fact, path, "notEqual", v),
136
- gt: (v) => makeLeaf(fact, path, "greaterThan", v),
137
- gte: (v) => makeLeaf(fact, path, "greaterThanInclusive", v),
138
- lt: (v) => makeLeaf(fact, path, "lessThan", v),
139
- lte: (v) => makeLeaf(fact, path, "lessThanInclusive", v),
140
- in: (vs) => makeLeaf(fact, path, "in", vs),
141
- notIn: (vs) => makeLeaf(fact, path, "notIn", vs),
142
- contains: (v) => makeLeaf(fact, path, "contains", v),
143
- doesNotContain: (v) => makeLeaf(fact, path, "doesNotContain", v)
144
- };
145
- return untyped;
146
- }
147
- function buildWorkItemAccessor() {
148
- const accessor = {
149
- field: (name) => makeFieldRef("workItem", `$.${WORK_ITEM_FIELDS_PATH_PREFIX}${name}`)
150
- };
151
- for (const key of WORK_ITEM_TOP_LEVEL_FIELDS) {
152
- accessor[key] = makeFieldRef("workItem", `$.${key}`);
153
- }
154
- return accessor;
155
- }
156
- function makeAssign(pipeline) {
157
- const key = typeof pipeline === "string" ? pipeline : pipeline.key;
158
- if (typeof key !== "string" || key.length === 0) {
159
- throw new Error("assign() requires a pipeline key or the value definePipeline() returns.");
160
- }
161
- return { _tag: "assign", pipelineKey: key };
162
- }
163
- function extractCondition(ref) {
164
- return ref._condition;
165
- }
166
- function makeGroup(mode, refs) {
167
- const conditions = refs.map(extractCondition);
168
- const condition = { _tag: "group", mode, conditions };
169
- return {
170
- _condition: condition,
171
- then(outcome) {
172
- return { _tag: "assignment_rule", conditions, mode, outcome };
173
- }
174
- };
175
- }
176
- function buildCtx() {
177
- return {
178
- workItem: buildWorkItemAccessor(),
179
- context: {
180
- isNew: makeFieldRef("context", "$.isNew")
181
- },
182
- assign: makeAssign,
183
- skip: () => ({ _tag: "skip" }),
184
- all: (...refs) => makeGroup("all", refs),
185
- any: (...refs) => makeGroup("any", refs)
186
- };
187
- }
188
- function defaultPipelineAssignment(callback) {
189
- const input = callback(buildCtx());
190
- return {
191
- _tag: "default_pipeline_assignment",
192
- default: input.default,
193
- rules: input.rules
194
- };
195
- }
196
- function serializeConditionNode(condition) {
197
- if (condition._tag === "leaf") {
198
- return {
199
- fact: condition.fact,
200
- ...condition.path ? { path: condition.path } : {},
201
- operator: condition.operator,
202
- value: condition.value
203
- };
204
- }
205
- if (condition.mode === "all") {
206
- return { all: condition.conditions.map(serializeConditionNode) };
207
- }
208
- return { any: condition.conditions.map(serializeConditionNode) };
209
- }
210
- function serializeOutcome(outcome) {
211
- if (outcome._tag === "skip")
212
- return { type: "skip", params: null };
213
- return { type: "assign", params: { pipelineKey: outcome.pipelineKey } };
214
- }
215
- function serializeAssignmentRule(rule) {
216
- const { type, params } = serializeOutcome(rule.outcome);
217
- return {
218
- conditions: { [rule.mode]: rule.conditions.map(serializeConditionNode) },
219
- event: { type, ...params ? { params } : {} }
220
- };
221
- }
222
- function serializeDefaultPipelineAssignment(spec) {
223
- let primaryKey = null;
224
- if (spec.default._tag === "assign") {
225
- primaryKey = spec.default.pipelineKey;
226
- } else {
227
- for (const rule of spec.rules) {
228
- if (rule.outcome._tag === "assign") {
229
- primaryKey = rule.outcome.pipelineKey;
230
- break;
231
- }
232
- }
233
- }
234
- if (primaryKey === null) {
235
- throw new Error("defaultPipelineAssignment must contain at least one assign() outcome " + "(in `default` or in `rules`). A policy that only skips is not useful.");
236
- }
237
- const { type: defaultType, params: defaultParams } = serializeOutcome(spec.default);
238
- const outcomeSet = new Set([defaultType]);
239
- const serializedRules = spec.rules.map((rule) => {
240
- outcomeSet.add(serializeOutcome(rule.outcome).type);
241
- return serializeAssignmentRule(rule);
242
- });
243
- return {
244
- pipelineDefinitionKey: primaryKey,
245
- rulesJson: { rules: serializedRules },
246
- defaultEventType: defaultType,
247
- defaultEventParamsJson: defaultParams,
248
- allowedEventTypes: [...outcomeSet]
249
- };
250
- }
251
- function isDefaultPipelineAssignmentSpec(value) {
252
- if (typeof value !== "object" || value === null)
253
- return false;
254
- return value["_tag"] === "default_pipeline_assignment";
255
- }
256
- export { PipelineDefinitionsApiError, createPipelineDefinitionsClient, WORK_ITEM_TOP_LEVEL_FIELDS, WORK_ITEM_FIELDS_PATH_PREFIX, resolveWorkItemFieldPath, DEFAULT_PIPELINE_ASSIGNMENT_FILENAME, defaultPipelineAssignment, serializeDefaultPipelineAssignment, isDefaultPipelineAssignmentSpec };
@@ -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 {};