@boboddy/sdk 0.0.16-alpha → 0.1.1-alpha

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.
@@ -0,0 +1,183 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __returnValue = (v) => v;
3
+ function __exportSetter(name, newValue) {
4
+ this[name] = __returnValue.bind(null, newValue);
5
+ }
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true,
11
+ configurable: true,
12
+ set: __exportSetter.bind(all, name)
13
+ });
14
+ };
15
+
16
+ // src/definitions/advancement-policies/define-advancement-policy.ts
17
+ function signal(signal2, operator, value) {
18
+ return { _tag: "signal", signal: signal2, operator, value };
19
+ }
20
+ function all(conditions, outcome) {
21
+ if (outcome === undefined) {
22
+ return { _tag: "all", conditions };
23
+ }
24
+ return { _tag: "rule", mode: "all", conditions, outcome };
25
+ }
26
+ function any(conditions, outcome) {
27
+ if (outcome === undefined) {
28
+ return { _tag: "any", conditions };
29
+ }
30
+ return { _tag: "rule", mode: "any", conditions, outcome };
31
+ }
32
+ function when(signal2, operator, value, outcome) {
33
+ return {
34
+ _tag: "rule",
35
+ mode: "all",
36
+ conditions: [{ _tag: "signal", signal: signal2, operator, value }],
37
+ outcome
38
+ };
39
+ }
40
+ var Rule = { signal, all, any, when };
41
+ function resolveOutcome(outcome) {
42
+ if (typeof outcome === "string") {
43
+ return { type: outcome, params: null };
44
+ }
45
+ return { type: outcome.outcome, params: outcome.outcomeJson ?? null };
46
+ }
47
+ function serializeCondition(condition) {
48
+ if (condition._tag === "signal") {
49
+ return {
50
+ fact: condition.signal,
51
+ operator: condition.operator,
52
+ value: condition.value
53
+ };
54
+ }
55
+ if (condition._tag === "all") {
56
+ return { all: condition.conditions.map(serializeCondition) };
57
+ }
58
+ return { any: condition.conditions.map(serializeCondition) };
59
+ }
60
+ function serializeRule(rule) {
61
+ const resolved = resolveOutcome(rule.outcome);
62
+ return {
63
+ conditions: { [rule.mode]: rule.conditions.map(serializeCondition) },
64
+ event: {
65
+ type: resolved.type,
66
+ ...resolved.params ? { params: resolved.params } : {}
67
+ }
68
+ };
69
+ }
70
+ function serializeAdvancementPolicy(policy) {
71
+ if (!policy) {
72
+ return {
73
+ rulesJson: { rules: [] },
74
+ defaultEventType: "continue",
75
+ defaultEventParamsJson: null,
76
+ allowedEventTypes: ["continue"]
77
+ };
78
+ }
79
+ const defaultResolved = resolveOutcome(policy.defaultOutcome);
80
+ const outcomeSet = new Set([defaultResolved.type]);
81
+ const serializedRules = (policy.rules ?? []).map((rule) => {
82
+ outcomeSet.add(resolveOutcome(rule.outcome).type);
83
+ return serializeRule(rule);
84
+ });
85
+ return {
86
+ rulesJson: { rules: serializedRules },
87
+ defaultEventType: defaultResolved.type,
88
+ defaultEventParamsJson: defaultResolved.params,
89
+ allowedEventTypes: [...outcomeSet]
90
+ };
91
+ }
92
+
93
+ // src/definitions/pipelines/define-pipeline.ts
94
+ function fromPipelineInput(_schema, path) {
95
+ return { source: "pipeline_input", path };
96
+ }
97
+ function fromSignal(step, signalKey) {
98
+ return { source: "step_signal", step, signalKey };
99
+ }
100
+ function stepOutput(step) {
101
+ return { source: "step_output", step };
102
+ }
103
+ function serializeBinding(binding) {
104
+ if (binding.source === "pipeline_input") {
105
+ return { source: "pipeline_input", path: binding.path };
106
+ }
107
+ if (binding.source === "step_signal") {
108
+ return {
109
+ source: "step_signal",
110
+ stepKey: binding.step.key,
111
+ signalKey: binding.signalKey
112
+ };
113
+ }
114
+ return { source: "step_output", stepKey: binding.step.key };
115
+ }
116
+ function definePipeline(config) {
117
+ const steps = config.steps;
118
+ return {
119
+ key: config.key,
120
+ name: config.name,
121
+ description: config.description ?? null,
122
+ version: config.version ?? 1,
123
+ status: config.status ?? "active",
124
+ steps: steps.map((stepConfig, index) => ({
125
+ stepKey: stepConfig.step.key,
126
+ stepName: stepConfig.step.name,
127
+ stepDescription: stepConfig.step.description,
128
+ position: index + 1,
129
+ inputBindingsJson: Object.fromEntries(Object.entries(stepConfig.input ?? {}).filter((entry) => entry[1] !== undefined).map(([key, binding]) => [key, serializeBinding(binding)])),
130
+ timeoutSeconds: stepConfig.timeout ?? null,
131
+ advancementPolicyDefinition: serializeAdvancementPolicy(stepConfig.advancement)
132
+ }))
133
+ };
134
+ }
135
+ // src/definitions/pipelines/pipeline-definitions-client.ts
136
+ function createPipelineDefinitionsClient(baseUrl) {
137
+ const base = baseUrl.replace(/\/$/, "");
138
+ async function doFetch(path, method, headers, body) {
139
+ const requestHeaders = { ...headers };
140
+ if (body !== undefined) {
141
+ requestHeaders["Content-Type"] = "application/json";
142
+ }
143
+ const response = await fetch(`${base}${path}`, {
144
+ method,
145
+ headers: requestHeaders,
146
+ ...body !== undefined ? { body: JSON.stringify(body) } : {}
147
+ });
148
+ if (!response.ok) {
149
+ const err = await response.json().catch(() => null);
150
+ throw new Error(err?.title ?? `HTTP ${String(response.status)} ${method} ${path}`);
151
+ }
152
+ return response.json().catch(() => null);
153
+ }
154
+ return buildPipelineDefinitionsClient(base, doFetch);
155
+ }
156
+ var buildPipelineDefinitionsClient = (_base, doFetch) => ({
157
+ listByProjectId: async (projectId, options) => {
158
+ const path = `/api/linear-pipeline-definitions?projectId=${encodeURIComponent(projectId)}`;
159
+ const result = await doFetch(path, "GET", options?.headers ?? {});
160
+ return result ?? [];
161
+ },
162
+ create: async (body, options) => {
163
+ const result = await doFetch("/api/linear-pipeline-definitions", "POST", options?.headers ?? {}, body);
164
+ return result;
165
+ },
166
+ update: async (pipelineId, body, options) => {
167
+ await doFetch(`/api/linear-pipeline-definitions/${pipelineId}`, "PUT", options?.headers ?? {}, body);
168
+ },
169
+ addStep: async (pipelineId, body, options) => {
170
+ await doFetch(`/api/linear-pipeline-definitions/${pipelineId}/steps`, "POST", options?.headers ?? {}, body);
171
+ },
172
+ removeStep: async (pipelineId, stepId, options) => {
173
+ await doFetch(`/api/linear-pipeline-definitions/${pipelineId}/steps/${stepId}`, "DELETE", options?.headers ?? {});
174
+ }
175
+ });
176
+ export {
177
+ stepOutput,
178
+ fromSignal,
179
+ fromPipelineInput,
180
+ definePipeline,
181
+ createPipelineDefinitionsClient,
182
+ Rule
183
+ };
@@ -0,0 +1,56 @@
1
+ import type { SerializedAdvancementPolicy } from "../advancement-policies/define-advancement-policy";
2
+ type RequestOptions = {
3
+ headers?: Record<string, unknown>;
4
+ };
5
+ export type PipelineStepCreateInput = {
6
+ stepDefinitionId: string;
7
+ stepDefinitionVersion: number;
8
+ key: string;
9
+ name: string;
10
+ description: string | null;
11
+ position: number;
12
+ inputBindingsJson: Record<string, unknown>;
13
+ timeoutSeconds: number | null;
14
+ retryPolicyJson: null;
15
+ advancementPolicyDefinition: SerializedAdvancementPolicy;
16
+ };
17
+ export type CreatePipelineInput = {
18
+ projectId: string;
19
+ key: string;
20
+ name: string;
21
+ description: string | null;
22
+ version: number;
23
+ status: "draft" | "active" | "archived";
24
+ stepDefinitions: PipelineStepCreateInput[];
25
+ };
26
+ export type UpdatePipelineInput = {
27
+ projectId: string;
28
+ key: string;
29
+ name: string;
30
+ description: string | null;
31
+ version: number;
32
+ status: "draft" | "active" | "archived";
33
+ };
34
+ export type ExistingPipelineStep = {
35
+ id: string;
36
+ key: string;
37
+ };
38
+ export type ExistingPipeline = {
39
+ id: string;
40
+ key: string;
41
+ version: number;
42
+ status: string;
43
+ steps: ExistingPipelineStep[];
44
+ };
45
+ export declare function createPipelineDefinitionsClient(baseUrl: string): ReturnType<typeof buildPipelineDefinitionsClient>;
46
+ declare const buildPipelineDefinitionsClient: (_base: string, doFetch: (path: string, method: string, headers: Record<string, string>, body?: unknown) => Promise<unknown>) => {
47
+ listByProjectId: (projectId: string, options?: RequestOptions) => Promise<ExistingPipeline[]>;
48
+ create: (body: CreatePipelineInput, options?: RequestOptions) => Promise<{
49
+ id: string;
50
+ key: string;
51
+ }>;
52
+ update: (pipelineId: string, body: UpdatePipelineInput, options?: RequestOptions) => Promise<void>;
53
+ addStep: (pipelineId: string, body: PipelineStepCreateInput, options?: RequestOptions) => Promise<void>;
54
+ removeStep: (pipelineId: string, stepId: string, options?: RequestOptions) => Promise<void>;
55
+ };
56
+ export {};
@@ -21,10 +21,10 @@ type OpenCodeMcpServers = Record<string, {
21
21
  enabled: boolean;
22
22
  }>;
23
23
  type SignalTypeStr = "string" | "number" | "boolean" | "object" | "array";
24
- type DotPaths<T, D extends readonly unknown[] = []> = D["length"] extends 4 ? string : unknown extends T ? string : T extends readonly unknown[] ? string : T extends object ? {
24
+ export type DotPaths<T, D extends readonly unknown[] = []> = D["length"] extends 4 ? string : unknown extends T ? string : T extends readonly unknown[] ? string : T extends object ? {
25
25
  [K in keyof T & string]: K | (NonNullable<T[K]> extends object ? `${K}.${DotPaths<NonNullable<T[K]>, [...D, unknown]> & string}` : never);
26
26
  }[keyof T & string] : string;
27
- type TypeAtPath<T, P extends string> = P extends `${infer K}.${infer Rest}` ? K extends keyof NonNullable<T> ? TypeAtPath<NonNullable<NonNullable<T>[K]>, Rest> : unknown : P extends keyof NonNullable<T> ? NonNullable<T>[P] : unknown;
27
+ export type TypeAtPath<T, P extends string> = P extends `${infer K}.${infer Rest}` ? K extends keyof NonNullable<T> ? TypeAtPath<NonNullable<NonNullable<T>[K]>, Rest> : unknown : P extends keyof NonNullable<T> ? NonNullable<T>[P] : unknown;
28
28
  type ToSignalType<T> = string extends T ? SignalTypeStr : [T] extends [string] ? "string" : [T] extends [number] ? "number" : [T] extends [boolean] ? "boolean" : [T] extends [readonly unknown[]] ? "array" : [T] extends [object] ? "object" : SignalTypeStr;
29
29
  type SignalSpecInput<TOutput> = {
30
30
  [P in DotPaths<TOutput>]: {
@@ -88,5 +88,18 @@ export type StepDefinitionSpec = {
88
88
  }>;
89
89
  opencodeMcpJson: OpenCodeMcpServers | null;
90
90
  };
91
- export declare function defineStep<TInput extends ZodType = ZodType, TResult extends ZodType = ZodType>(config: DefineStepInput<TInput, TResult>): StepDefinitionSpec;
91
+ export type TypedStepDefinitionSpec<TInput = unknown, TResult = unknown, TSignalKeys extends string = string> = StepDefinitionSpec & {
92
+ readonly __inputType: TInput;
93
+ readonly __resultType: TResult;
94
+ readonly __signalKeys: TSignalKeys;
95
+ };
96
+ type ExtractSignalKey<T> = T extends {
97
+ key: infer K extends string;
98
+ } ? K : T extends {
99
+ sourcePath: infer S extends string;
100
+ } ? S : string;
101
+ export type SignalKeysOf<TSignals extends readonly unknown[]> = TSignals extends readonly (infer S)[] ? ExtractSignalKey<S> : string;
102
+ export declare function defineStep<TInput extends ZodType = ZodType, TResult extends ZodType = ZodType, const TSignals extends ReadonlyArray<SignalSpecInput<TResult["_output"]>> = never[]>(config: Omit<DefineStepInput<TInput, TResult>, "signals"> & {
103
+ signals?: TSignals;
104
+ }): TypedStepDefinitionSpec<TInput["_output"], TResult["_output"], SignalKeysOf<TSignals>>;
92
105
  export {};
@@ -0,0 +1,2 @@
1
+ export * from "./define-step";
2
+ export * from "./step-definitions-client";