@checkstack/gitops-backend 0.2.8 → 0.3.0

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,41 @@
1
1
  # @checkstack/gitops-backend
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f6f9a5c: Surface the source repository for GitOps-managed entities and gate the
8
+ system→group remove button on the system's lock state.
9
+
10
+ - `provenanceSchema` now carries a `sourceUrl` field, derived on the
11
+ backend from the provider type, baseUrl, repository and filePath. URLs
12
+ are constructed for github.com / gitlab.com and self-hosted
13
+ GitHub/GitLab where the API base ends in `/api/v3` or `/api/v4`. Other
14
+ baseUrls fall back to `null` so the UI keeps showing the raw path.
15
+ - New `useProvenanceLocks` hook (bulk variant of `useProvenanceLock`)
16
+ for views that render many entities and need to look up locks
17
+ client-side.
18
+ - New `<GitOpsSourceBadge>` popover component that replaces the bare
19
+ GitBranch icon on system and group catalog cards. The popover
20
+ surfaces the repository, file path, and a "View in source provider"
21
+ deep link.
22
+ - `<GitOpsLockBanner>` repo line is now a real link when a sourceUrl is
23
+ available.
24
+ - The system→group remove button in the catalog now disables itself
25
+ when the system is GitOps-managed, matching the backend lock that was
26
+ already in place.
27
+
28
+ ### Patch Changes
29
+
30
+ - Updated dependencies [42abfff]
31
+ - Updated dependencies [f6f9a5c]
32
+ - Updated dependencies [aa89bc5]
33
+ - @checkstack/common@0.9.0
34
+ - @checkstack/gitops-common@0.3.0
35
+ - @checkstack/queue-api@0.3.0
36
+ - @checkstack/backend-api@0.15.1
37
+ - @checkstack/command-backend@0.1.25
38
+
3
39
  ## 0.2.8
4
40
 
5
41
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/gitops-backend",
3
- "version": "0.2.8",
3
+ "version": "0.3.0",
4
4
  "license": "Elastic-2.0",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -14,11 +14,11 @@
14
14
  "lint:code": "eslint . --max-warnings 0"
15
15
  },
16
16
  "dependencies": {
17
- "@checkstack/backend-api": "0.14.1",
18
- "@checkstack/gitops-common": "0.2.1",
19
- "@checkstack/common": "0.7.0",
20
- "@checkstack/command-backend": "0.1.23",
21
- "@checkstack/queue-api": "0.2.17",
17
+ "@checkstack/backend-api": "0.15.0",
18
+ "@checkstack/gitops-common": "0.2.2",
19
+ "@checkstack/common": "0.8.0",
20
+ "@checkstack/command-backend": "0.1.24",
21
+ "@checkstack/queue-api": "0.2.18",
22
22
  "@orpc/server": "^1.13.2",
23
23
  "drizzle-orm": "^0.45.0",
24
24
  "minimatch": "^10.0.0",
@@ -27,9 +27,9 @@
27
27
  "yaml": "^2.7.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@checkstack/drizzle-helper": "0.0.4",
31
- "@checkstack/scripts": "0.1.2",
32
- "@checkstack/tsconfig": "0.0.6",
30
+ "@checkstack/drizzle-helper": "0.0.5",
31
+ "@checkstack/scripts": "0.3.0",
32
+ "@checkstack/tsconfig": "0.0.7",
33
33
  "@types/bun": "^1.3.5",
34
34
  "@types/node": "^20.0.0",
35
35
  "@types/uuid": "^11.0.0",
package/src/router.ts CHANGED
@@ -2,7 +2,7 @@ import { implement, ORPCError } from "@orpc/server";
2
2
  import { z } from "zod";
3
3
  import { autoAuthMiddleware, type RpcContext } from "@checkstack/backend-api";
4
4
  import { encrypt, decrypt } from "@checkstack/backend-api";
5
- import { gitopsContract } from "@checkstack/gitops-common";
5
+ import { gitopsContract, deriveSourceUrl } from "@checkstack/gitops-common";
6
6
  import type { SafeDatabase } from "@checkstack/backend-api";
7
7
  import type { QueueManager } from "@checkstack/queue-api";
8
8
  import type { InternalEntityKindRegistry } from "./kind-registry";
@@ -34,6 +34,36 @@ export const createGitOpsRouter = ({
34
34
  }: GitOpsRouterDeps) => {
35
35
  // ─── Provenance ──────────────────────────────────────────────────────
36
36
 
37
+ type ProviderMeta = {
38
+ type: "github" | "gitlab";
39
+ baseUrl: string | null;
40
+ };
41
+
42
+ const buildProviderLookup = async (): Promise<Map<string, ProviderMeta>> => {
43
+ const providers = await db.select().from(schema.providers);
44
+ const map = new Map<string, ProviderMeta>();
45
+ for (const p of providers) {
46
+ map.set(p.id, { type: p.type, baseUrl: p.baseUrl });
47
+ }
48
+ return map;
49
+ };
50
+
51
+ const decorateProvenance = (
52
+ row: typeof schema.provenance.$inferSelect,
53
+ providers: Map<string, ProviderMeta>,
54
+ ) => {
55
+ const provider = providers.get(row.providerId);
56
+ const sourceUrl = provider
57
+ ? deriveSourceUrl({
58
+ providerType: provider.type,
59
+ baseUrl: provider.baseUrl,
60
+ repository: row.repository,
61
+ filePath: row.filePath,
62
+ })
63
+ : null;
64
+ return { ...row, warnings: row.warnings ?? [], sourceUrl };
65
+ };
66
+
37
67
  const getProvenance = os.getProvenance.handler(async ({ input }) => {
38
68
  const conditions = [eq(schema.provenance.kind, input.kind)];
39
69
 
@@ -49,14 +79,15 @@ export const createGitOpsRouter = ({
49
79
  .from(schema.provenance)
50
80
  .where(and(...conditions));
51
81
  const row = result[0];
52
-
53
- return row ? { ...row, warnings: row.warnings ?? [] } : null;
82
+ if (!row) return null;
83
+ const providers = await buildProviderLookup();
84
+ return decorateProvenance(row, providers);
54
85
  });
55
86
 
56
87
  const listProvenance = os.listProvenance.handler(async ({ input }) => {
57
88
  const rawRows = await db.select().from(schema.provenance);
58
- // Normalize: ensure warnings is always a string[] (Drizzle may return null for pre-migration rows)
59
- const rows = rawRows.map((row) => ({ ...row, warnings: row.warnings ?? [] }));
89
+ const providers = await buildProviderLookup();
90
+ const rows = rawRows.map((row) => decorateProvenance(row, providers));
60
91
  if (!input) return rows;
61
92
 
62
93
  return rows.filter((row) => {