@devpad/api 2.2.6 → 2.2.8

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.
@@ -69,7 +69,11 @@ type ScanError = BaseError & {
69
69
  type GithubError = BaseError & {
70
70
  kind: "github_error";
71
71
  };
72
- type ServiceError = NotFoundError | ForbiddenError | ValidationError | RateLimitedError | StoreError | NetworkError | AuthExpiredError | ApiError | ParseError | EncryptionError | DatabaseError | ConflictError | ProtectedError | BadRequestError | UnauthorizedError | ScanError | GithubError;
72
+ type ValidationFieldError = BaseError & {
73
+ kind: "validation_error";
74
+ field: string;
75
+ };
76
+ type ServiceError = NotFoundError | ForbiddenError | ValidationError | ValidationFieldError | RateLimitedError | StoreError | NetworkError | AuthExpiredError | ApiError | ParseError | EncryptionError | DatabaseError | ConflictError | ProtectedError | BadRequestError | UnauthorizedError | ScanError | GithubError;
73
77
  type ProviderError = RateLimitedError | AuthExpiredError | NetworkError | ApiError | ParseError;
74
78
  type CronError = StoreError | NetworkError | AuthExpiredError | EncryptionError;
75
79
  type ErrorContext = {
@@ -106,6 +110,7 @@ declare const isBadRequestError: (e: unknown) => e is BadRequestError;
106
110
  declare const isUnauthorizedError: (e: unknown) => e is UnauthorizedError;
107
111
  declare const isScanError: (e: unknown) => e is ScanError;
108
112
  declare const isGithubError: (e: unknown) => e is GithubError;
113
+ declare const isValidationFieldError: (e: unknown) => e is ValidationFieldError;
109
114
  declare const isServiceError: (e: unknown) => e is ServiceError;
110
115
  declare const isRetryableError: (e: unknown) => boolean;
111
116
  declare const notFound: (resource: string, id?: string, ctx?: Record<string, unknown>) => Result<never, NotFoundError>;
@@ -125,6 +130,7 @@ declare const badRequest: (message?: string, details?: unknown, ctx?: Record<str
125
130
  declare const unauthorized: (message?: string, ctx?: Record<string, unknown>) => Result<never, UnauthorizedError>;
126
131
  declare const scanError: (message?: string, ctx?: Record<string, unknown>) => Result<never, ScanError>;
127
132
  declare const githubError: (message?: string, ctx?: Record<string, unknown>) => Result<never, GithubError>;
133
+ declare const validationFieldError: (field: string, message?: string, ctx?: Record<string, unknown>) => Result<never, ValidationFieldError>;
128
134
  declare const errors: {
129
135
  readonly notFound: (resource: string, id?: string, ctx?: Record<string, unknown>) => Result<never, NotFoundError>;
130
136
  readonly forbidden: (reason?: string, ctx?: Record<string, unknown>) => Result<never, ForbiddenError>;
@@ -143,10 +149,12 @@ declare const errors: {
143
149
  readonly unauthorized: (message?: string, ctx?: Record<string, unknown>) => Result<never, UnauthorizedError>;
144
150
  readonly scanError: (message?: string, ctx?: Record<string, unknown>) => Result<never, ScanError>;
145
151
  readonly githubError: (message?: string, ctx?: Record<string, unknown>) => Result<never, GithubError>;
152
+ readonly validationFieldError: (field: string, message?: string, ctx?: Record<string, unknown>) => Result<never, ValidationFieldError>;
146
153
  readonly is: {
147
154
  readonly notFound: (e: unknown) => e is NotFoundError;
148
155
  readonly forbidden: (e: unknown) => e is ForbiddenError;
149
156
  readonly validation: (e: unknown) => e is ValidationError;
157
+ readonly validationField: (e: unknown) => e is ValidationFieldError;
150
158
  readonly rateLimited: (e: unknown) => e is RateLimitedError;
151
159
  readonly storeError: (e: unknown) => e is StoreError;
152
160
  readonly networkError: (e: unknown) => e is NetworkError;
@@ -166,4 +174,4 @@ declare const errors: {
166
174
  };
167
175
  };
168
176
 
169
- export { dbError as $, type AuthExpiredError as A, type BaseError as B, type ConflictError as C, type DatabaseError as D, type EncryptionError as E, type ForbiddenError as F, type GithubError as G, isScanError as H, isGithubError as I, isServiceError as J, isRetryableError as K, notFound as L, forbidden as M, type NotFoundError as N, validation as O, type ParseError as P, rateLimited as Q, type RateLimitedError as R, type StoreError as S, storeError as T, type UnauthorizedError as U, type ValidationError as V, networkError as W, authExpired as X, apiError as Y, parseError as Z, encryptionError as _, type NetworkError as a, conflict as a0, protectedEntity as a1, badRequest as a2, unauthorized as a3, scanError as a4, githubError as a5, errors as a6, type ApiError as b, type ProtectedError as c, type BadRequestError as d, type ScanError as e, type ServiceError as f, type ProviderError as g, type CronError as h, type ErrorContext as i, type ErrorLogEntry as j, configureErrorLogging as k, isNotFoundError as l, isForbiddenError as m, isValidationError as n, isRateLimitedError as o, isStoreError as p, isNetworkError as q, isAuthExpiredError as r, isApiError as s, isParseError as t, isEncryptionError as u, isDatabaseError as v, isConflictError as w, isProtectedError as x, isBadRequestError as y, isUnauthorizedError as z };
177
+ export { isValidationFieldError as $, type ApiError as A, type BadRequestError as B, type ConflictError as C, type DatabaseError as D, type EncryptionError as E, type ForbiddenError as F, type GithubError as G, isEncryptionError as H, isForbiddenError as I, isGithubError as J, isNetworkError as K, isNotFoundError as L, isParseError as M, type NetworkError as N, isProtectedError as O, type ParseError as P, isRateLimitedError as Q, type RateLimitedError as R, type ScanError as S, isRetryableError as T, type UnauthorizedError as U, type ValidationError as V, isScanError as W, isServiceError as X, isStoreError as Y, isUnauthorizedError as Z, isValidationError as _, type AuthExpiredError as a, networkError as a0, notFound as a1, parseError as a2, protectedEntity as a3, rateLimited as a4, scanError as a5, storeError as a6, unauthorized as a7, validation as a8, validationFieldError as a9, type BaseError as b, type CronError as c, type ErrorContext as d, type ErrorLogEntry as e, type NotFoundError as f, type ProtectedError as g, type ProviderError as h, type ServiceError as i, type StoreError as j, type ValidationFieldError as k, apiError as l, authExpired as m, badRequest as n, configureErrorLogging as o, conflict as p, dbError as q, encryptionError as r, errors as s, forbidden as t, githubError as u, isApiError as v, isAuthExpiredError as w, isBadRequestError as x, isConflictError as y, isDatabaseError as z };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- import { Q as PostListParams, S as PostsResponse, J as Post, L as PostCreate, N as PostUpdate, d as VersionInfo, a as PostContent, k as Category, $ as CategoryCreate, v as AccessKey } from './types.d-DLE9TSql.js';
2
- import { T as Profile, a4 as CreateProfileInput, a5 as UpdateProfileInput, U as ProfileFilter, a6 as AddFilterInput, aI as Timeline, A as Account, ai as PlatformSettings } from './types.d-VdW3W-u7.js';
3
- import { A as ApiKey, P as Project, g as UpsertProject, r as GetConfigResult, n as SaveConfigRequest, M as Milestone, G as Goal, o as TaskWithDetails, h as UpsertTodo, i as UpsertTag, H as HistoryAction, u as TagWithTypedColor } from './types.d-CW-e2BrO.js';
4
- export { m as ProjectConfig, T as Task } from './types.d-CW-e2BrO.js';
1
+ import { G as PostListParams, T as PostsResponse, x as Post, D as PostCreate, Q as PostUpdate, Z as VersionInfo, y as PostContent, C as Category, k as CategoryCreate, A as AccessKey } from './types.d-B3vp62jJ.js';
2
+ import { ai as Profile, u as CreateProfileInput, aw as UpdateProfileInput, aj as ProfileFilter, c as AddFilterInput, aq as Timeline, A as Account, ae as PlatformSettings } from './types.d-BcKx3ryl.js';
3
+ import { a as ApiKey, l as Project, Z as UpsertProject, G as GetConfigResult, S as SaveConfigRequest, M as Milestone, d as Goal, z as TaskWithDetails, $ as UpsertTodo, _ as UpsertTag, H as HistoryAction, v as TagWithTypedColor, D as DashboardResponse, j as PipelineRun, k as PipelineStageEvent, g as PipelineGrant, i as PipelinePackage, P as PipelineAnalysisTemplate, h as PipelineOidcTrust } from './types.d-BvfRohlZ.js';
4
+ export { m as ProjectConfig, w as Task } from './types.d-BvfRohlZ.js';
5
5
  import { Result } from '@f0rbit/corpus';
6
6
  export { Result, err, ok } from '@f0rbit/corpus';
7
+ import { S as StageEventKind } from './schema.d-BeVFWenc.js';
7
8
  import { z } from 'zod';
8
9
  import 'drizzle-orm';
9
- import './media.d-CQ56ckoR.js';
10
+ import './media.d-R87HGuRp.js';
10
11
  import 'drizzle-orm/sqlite-core';
11
- import './schema.d-Bka8880l.js';
12
12
 
13
13
  interface BufferedQueue<T> {
14
14
  latest(): T | null;
@@ -652,6 +652,285 @@ declare class ApiClient {
652
652
  }>>;
653
653
  };
654
654
  };
655
+ /**
656
+ * Pipelines namespace with Result-wrapped operations
657
+ */
658
+ readonly pipelines: {
659
+ /**
660
+ * Dashboard namespace — Phase 2.D observability slice. Aggregates
661
+ * `pipeline_run`, `pipeline_stage_event`, and `pipeline_approval`
662
+ * for the project's pipeline_package(s) over `window_ms` and
663
+ * enriches the response with pulse `/summary` when configured.
664
+ *
665
+ * Lives at `GET /v1/pipelines/dashboard?project_id=...&window_ms=...`
666
+ * on the main worker (unified D1 binding — no orchestrator hop).
667
+ * Auth: session cookie + ownership check on the project_id.
668
+ * Cache: `public, max-age=30`.
669
+ */
670
+ dashboard: {
671
+ get: (input: {
672
+ project_id: string;
673
+ window_ms?: number;
674
+ }) => Promise<ApiResult<DashboardResponse & {
675
+ pulse: Record<string, unknown> | null;
676
+ }>>;
677
+ };
678
+ /**
679
+ * List pipeline runs ordered by `created_at` DESC. Optional filters
680
+ * narrow by package and/or status; `limit` defaults to 50 server-side
681
+ * and is capped at 200.
682
+ */
683
+ list: (filter?: {
684
+ package_id?: string;
685
+ status?: string;
686
+ limit?: number;
687
+ }) => Promise<ApiResult<PipelineRun[]>>;
688
+ /**
689
+ * Get a pipeline run by ID
690
+ */
691
+ get: (run_id: string) => Promise<ApiResult<PipelineRun>>;
692
+ /**
693
+ * Create a new pipeline run
694
+ */
695
+ create: (input: {
696
+ package_id: string;
697
+ version_set_id: string;
698
+ }) => Promise<ApiResult<{
699
+ run_id: string;
700
+ status: string;
701
+ }>>;
702
+ /**
703
+ * Approve a stage in a pipeline run
704
+ */
705
+ approve: (run_id: string, input: {
706
+ stage_name: string;
707
+ decision: "approved" | "denied";
708
+ user_id: string;
709
+ reason?: string;
710
+ }) => Promise<ApiResult<void>>;
711
+ /**
712
+ * Cancel a pipeline run
713
+ */
714
+ cancel: (run_id: string) => Promise<ApiResult<void>>;
715
+ /**
716
+ * Rollback a pipeline run
717
+ */
718
+ rollback: (run_id: string) => Promise<ApiResult<void>>;
719
+ /**
720
+ * Stage-event namespace — Phase 2.C webhook ingestion + read-back.
721
+ *
722
+ * `ingest` posts a webhook event against an in-flight run; auth
723
+ * mode is the standard bearer/session header (admin bypass; session
724
+ * must carry `runs:events` and matching `package_id`). Server-side
725
+ * stamps `payload.source = "external"`. Idempotency: same
726
+ * `idempotency_key` + same payload returns `{ duplicated: true }`;
727
+ * same key + different payload returns a 400 validation_error.
728
+ *
729
+ * `list` is read-only and returns the run's events newest-first.
730
+ */
731
+ events: {
732
+ ingest: (run_id: string, input: {
733
+ stage_name: string;
734
+ kind: StageEventKind;
735
+ payload?: unknown;
736
+ idempotency_key: string;
737
+ }) => Promise<ApiResult<{
738
+ event_id: string;
739
+ duplicated: boolean;
740
+ }>>;
741
+ list: (run_id: string) => Promise<ApiResult<PipelineStageEvent[]>>;
742
+ };
743
+ /**
744
+ * Grants namespace
745
+ */
746
+ grants: {
747
+ /**
748
+ * List grants for a package
749
+ */
750
+ list: (package_id?: string) => Promise<ApiResult<PipelineGrant[]>>;
751
+ /**
752
+ * Approve a grant
753
+ */
754
+ approve: (grant_id: string, user_id: string) => Promise<ApiResult<PipelineGrant>>;
755
+ /**
756
+ * Deny a grant
757
+ */
758
+ deny: (grant_id: string, user_id: string, reason?: string) => Promise<ApiResult<{
759
+ success: boolean;
760
+ }>>;
761
+ };
762
+ /**
763
+ * Packages namespace — full CRUD over pipeline_package rows. Writes
764
+ * (create/update/delete) require the orchestrator bearer token; the
765
+ * HttpClient picks it up via the standard auth header injection.
766
+ */
767
+ packages: {
768
+ /**
769
+ * List packages, optionally filtered by linked devpad project.
770
+ * Packages with `project_id = null` are not yet linked.
771
+ */
772
+ list: (filter?: {
773
+ project_id?: string;
774
+ }) => Promise<ApiResult<PipelinePackage[]>>;
775
+ /**
776
+ * Get a single package by id
777
+ */
778
+ get: (package_id: string) => Promise<ApiResult<PipelinePackage>>;
779
+ /**
780
+ * Register a new pipeline package. `id` is canonically the same as
781
+ * `name` per existing convention but is supplied explicitly so the
782
+ * orchestrator can disambiguate renames without conflicts.
783
+ */
784
+ create: (input: {
785
+ id: string;
786
+ name: string;
787
+ owner_id: string;
788
+ repo_url?: string | null;
789
+ project_id?: string | null;
790
+ default_template_ref?: string | null;
791
+ }) => Promise<ApiResult<PipelinePackage>>;
792
+ /**
793
+ * Partially update a package row. Missing keys preserve existing
794
+ * values; explicit `null` clears the field.
795
+ */
796
+ update: (package_id: string, input: {
797
+ repo_url?: string | null;
798
+ project_id?: string | null;
799
+ default_template_ref?: string | null;
800
+ script_name_overrides?: Record<string, string> | null;
801
+ }) => Promise<ApiResult<PipelinePackage>>;
802
+ /**
803
+ * Remove a package. Refuses (409) if pipeline_run rows still
804
+ * reference the package — clean up runs first.
805
+ */
806
+ delete: (package_id: string) => Promise<ApiResult<{
807
+ deleted: true;
808
+ }>>;
809
+ };
810
+ /**
811
+ * Analysis-template namespace — admin-gated CRUD for the
812
+ * `pipeline_analysis_template` table. Phase 2.A surface; each
813
+ * call requires the orchestrator's bearer token (literal
814
+ * `PIPELINES_TOKEN`). `owner_id` is required on every operation
815
+ * — single-tenant today, but the column is in place so multi-user
816
+ * ACLs slot in later.
817
+ */
818
+ analysis_templates: {
819
+ /**
820
+ * List templates for an owner.
821
+ */
822
+ list: (input: {
823
+ owner_id: string;
824
+ }) => Promise<ApiResult<PipelineAnalysisTemplate[]>>;
825
+ /**
826
+ * Get a single template by id, scoped to its owner. 404 when
827
+ * unknown or owned by a different user.
828
+ */
829
+ get: (id: string, input: {
830
+ owner_id: string;
831
+ }) => Promise<ApiResult<PipelineAnalysisTemplate>>;
832
+ /**
833
+ * Create a new analysis template. `threshold_dsl` is parsed
834
+ * server-side; parse failure returns 400 `validation_error`
835
+ * with `field: "threshold_dsl"` and a descriptive message.
836
+ * `window_ms` defaults to 600_000 (10 min) when omitted.
837
+ */
838
+ create: (input: {
839
+ owner_id: string;
840
+ name: string;
841
+ threshold_dsl: string;
842
+ query_dsl?: unknown;
843
+ window_ms?: number;
844
+ }) => Promise<ApiResult<PipelineAnalysisTemplate>>;
845
+ /**
846
+ * Partial patch — only the supplied fields are touched.
847
+ * Re-validates `threshold_dsl` when supplied; same
848
+ * `validation_error` shape as create on parse failure.
849
+ */
850
+ update: (id: string, input: {
851
+ owner_id: string;
852
+ name?: string;
853
+ threshold_dsl?: string;
854
+ query_dsl?: unknown;
855
+ window_ms?: number;
856
+ }) => Promise<ApiResult<PipelineAnalysisTemplate>>;
857
+ /**
858
+ * Hard-delete the template. Does NOT consult
859
+ * `pipeline_run.resolved_gates` — runs snapshot their gate
860
+ * template at resolve-time, so deletion never orphans
861
+ * in-flight runs.
862
+ */
863
+ delete: (id: string, input: {
864
+ owner_id: string;
865
+ }) => Promise<ApiResult<{
866
+ deleted: true;
867
+ }>>;
868
+ };
869
+ /**
870
+ * OIDC trust-policy namespace — admin-gated CRUD for the
871
+ * `pipeline_oidc_trust` table. Phase 15.D surface; each call requires
872
+ * the orchestrator's bearer token (literal `PIPELINES_TOKEN`).
873
+ * `owner_id` is required on every operation — single-tenant today,
874
+ * but the column is in place so multi-user ACLs slot in later.
875
+ */
876
+ oidc_trust: {
877
+ /**
878
+ * List policies for an owner, ordered created_at DESC, id ASC —
879
+ * matches the trust-matcher resolution order so the management UI
880
+ * shows the policy that would be picked first.
881
+ */
882
+ list: (input: {
883
+ owner_id: string;
884
+ }) => Promise<ApiResult<PipelineOidcTrust[]>>;
885
+ /**
886
+ * Get a single policy by id, scoped to its owner. 404 when
887
+ * unknown, soft-deleted, or owned by a different user.
888
+ */
889
+ get: (id: string, input: {
890
+ owner_id: string;
891
+ }) => Promise<ApiResult<PipelineOidcTrust>>;
892
+ /**
893
+ * Create a new policy. Defaults per plan §I.5: `repo_pattern: "*"`,
894
+ * `allowed_actions: ["artifacts:upload","runs:start"]`,
895
+ * `session_ttl_seconds: 900`.
896
+ */
897
+ create: (input: {
898
+ owner_id: string;
899
+ github_owner: string;
900
+ expected_audience: string;
901
+ provider?: "github";
902
+ repo_pattern?: string;
903
+ allowed_refs?: string[];
904
+ allowed_environments?: string[];
905
+ allowed_actions?: string[];
906
+ session_ttl_seconds?: number;
907
+ }) => Promise<ApiResult<PipelineOidcTrust>>;
908
+ /**
909
+ * Partial patch — only the supplied fields are touched. Validation
910
+ * runs against the merged record server-side.
911
+ */
912
+ update: (id: string, input: {
913
+ owner_id: string;
914
+ github_owner?: string;
915
+ expected_audience?: string;
916
+ repo_pattern?: string;
917
+ allowed_refs?: string[];
918
+ allowed_environments?: string[];
919
+ allowed_actions?: string[];
920
+ session_ttl_seconds?: number;
921
+ }) => Promise<ApiResult<PipelineOidcTrust>>;
922
+ /**
923
+ * Soft-delete a policy (sets `deleted = true`; row preserved for
924
+ * audit). The matcher and management list both skip soft-deleted
925
+ * rows.
926
+ */
927
+ delete: (id: string, input: {
928
+ owner_id: string;
929
+ }) => Promise<ApiResult<{
930
+ deleted: true;
931
+ }>>;
932
+ };
933
+ };
655
934
  /**
656
935
  * Get the API key
657
936
  */