@checkstack/gitops-backend 0.2.8 → 0.3.1
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 +47 -0
- package/package.json +9 -9
- package/src/router.ts +36 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# @checkstack/gitops-backend
|
|
2
2
|
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [9016526]
|
|
8
|
+
- @checkstack/common@0.10.0
|
|
9
|
+
- @checkstack/gitops-common@0.4.0
|
|
10
|
+
- @checkstack/backend-api@0.15.2
|
|
11
|
+
- @checkstack/command-backend@0.1.26
|
|
12
|
+
- @checkstack/queue-api@0.3.1
|
|
13
|
+
|
|
14
|
+
## 0.3.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- f6f9a5c: Surface the source repository for GitOps-managed entities and gate the
|
|
19
|
+
system→group remove button on the system's lock state.
|
|
20
|
+
|
|
21
|
+
- `provenanceSchema` now carries a `sourceUrl` field, derived on the
|
|
22
|
+
backend from the provider type, baseUrl, repository and filePath. URLs
|
|
23
|
+
are constructed for github.com / gitlab.com and self-hosted
|
|
24
|
+
GitHub/GitLab where the API base ends in `/api/v3` or `/api/v4`. Other
|
|
25
|
+
baseUrls fall back to `null` so the UI keeps showing the raw path.
|
|
26
|
+
- New `useProvenanceLocks` hook (bulk variant of `useProvenanceLock`)
|
|
27
|
+
for views that render many entities and need to look up locks
|
|
28
|
+
client-side.
|
|
29
|
+
- New `<GitOpsSourceBadge>` popover component that replaces the bare
|
|
30
|
+
GitBranch icon on system and group catalog cards. The popover
|
|
31
|
+
surfaces the repository, file path, and a "View in source provider"
|
|
32
|
+
deep link.
|
|
33
|
+
- `<GitOpsLockBanner>` repo line is now a real link when a sourceUrl is
|
|
34
|
+
available.
|
|
35
|
+
- The system→group remove button in the catalog now disables itself
|
|
36
|
+
when the system is GitOps-managed, matching the backend lock that was
|
|
37
|
+
already in place.
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- Updated dependencies [42abfff]
|
|
42
|
+
- Updated dependencies [f6f9a5c]
|
|
43
|
+
- Updated dependencies [aa89bc5]
|
|
44
|
+
- @checkstack/common@0.9.0
|
|
45
|
+
- @checkstack/gitops-common@0.3.0
|
|
46
|
+
- @checkstack/queue-api@0.3.0
|
|
47
|
+
- @checkstack/backend-api@0.15.1
|
|
48
|
+
- @checkstack/command-backend@0.1.25
|
|
49
|
+
|
|
3
50
|
## 0.2.8
|
|
4
51
|
|
|
5
52
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@checkstack/gitops-backend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
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.
|
|
18
|
-
"@checkstack/gitops-common": "0.
|
|
19
|
-
"@checkstack/common": "0.
|
|
20
|
-
"@checkstack/command-backend": "0.1.
|
|
21
|
-
"@checkstack/queue-api": "0.
|
|
17
|
+
"@checkstack/backend-api": "0.15.1",
|
|
18
|
+
"@checkstack/gitops-common": "0.3.0",
|
|
19
|
+
"@checkstack/common": "0.9.0",
|
|
20
|
+
"@checkstack/command-backend": "0.1.25",
|
|
21
|
+
"@checkstack/queue-api": "0.3.0",
|
|
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.
|
|
31
|
-
"@checkstack/scripts": "0.1
|
|
32
|
-
"@checkstack/tsconfig": "0.0.
|
|
30
|
+
"@checkstack/drizzle-helper": "0.0.5",
|
|
31
|
+
"@checkstack/scripts": "0.3.1",
|
|
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
|
-
|
|
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
|
-
|
|
59
|
-
const rows = rawRows.map((row) => (
|
|
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) => {
|