@checkstack/gitops-backend 0.2.7 → 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 +143 -0
- package/package.json +10 -9
- package/src/router.ts +39 -8
- package/src/sync/reconciler.ts +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,148 @@
|
|
|
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
|
+
|
|
39
|
+
## 0.2.8
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- 50e5f5f: Runtime plugin system: install + uninstall plugins from npm, GitHub releases
|
|
44
|
+
(including private GitHub Enterprise instances), or tarball uploads at
|
|
45
|
+
runtime, with multi-package bundles, dependency-derived compatibility checks,
|
|
46
|
+
multi-instance coordination via a Postgres artifact store, and
|
|
47
|
+
single-coordinator destructive cleanup.
|
|
48
|
+
|
|
49
|
+
Highlights:
|
|
50
|
+
|
|
51
|
+
- New `PluginSource` discriminated union and `PluginInstaller` /
|
|
52
|
+
`PluginInstallerRegistry` interfaces in `@checkstack/backend-api`. The
|
|
53
|
+
GitHub variant accepts an optional `apiBaseUrl` so deployments backed by
|
|
54
|
+
GitHub Enterprise can install from `https://ghe.example.com/api/v3`
|
|
55
|
+
instead of `api.github.com`.
|
|
56
|
+
- New `installPackageMetadataSchema` (Zod) in `@checkstack/common` validates
|
|
57
|
+
every plugin's `package.json` at install time. Required fields: `name`,
|
|
58
|
+
`version`, `description`, `author`, `license`, `checkstack.type`,
|
|
59
|
+
`checkstack.pluginId`. Optional: `checkstack.bundle`,
|
|
60
|
+
`checkstack.usageInstructions`, `checkstack.allowInstallScripts`.
|
|
61
|
+
- New `pluginManagerContract` in `@checkstack/pluginmanager-common` with
|
|
62
|
+
`list`, `previewInstall`, `install`, `previewUninstall`, `uninstall`, and
|
|
63
|
+
`events` procedures.
|
|
64
|
+
- New `@checkstack/pluginmanager-frontend` admin UI: installed-plugins list
|
|
65
|
+
with per-row uninstall (typed-confirmation modal, schema/configs/cascade
|
|
66
|
+
toggles), install page with NPM / Tarball Upload / GitHub Release tabs
|
|
67
|
+
(Catalog tab disabled — coming soon), and an events page surfacing the
|
|
68
|
+
install/uninstall audit log.
|
|
69
|
+
- New `bunx @checkstack/scripts plugin-pack` CLI for plugin authors —
|
|
70
|
+
per-package mode produces an npm-shaped tarball; `--bundle` mode produces
|
|
71
|
+
an outer tarball containing every sibling declared in
|
|
72
|
+
`package.json#checkstack.bundle`. Published to npm so external authors
|
|
73
|
+
can `bunx` it directly without a workspace checkout.
|
|
74
|
+
- Compatibility derived from `package.json#dependencies` ranges
|
|
75
|
+
(`semver.satisfies` against the platform's loaded `@checkstack/*`
|
|
76
|
+
versions) — no separate `compatibility` field.
|
|
77
|
+
- Multi-instance: originator persists artifacts + `plugins` rows + broadcasts
|
|
78
|
+
install/uninstall; receiving instances do in-process register/unregister
|
|
79
|
+
only. Destructive ops (drop schema, delete plugin_configs, delete
|
|
80
|
+
artifacts, delete `plugins` rows) run exactly once on the originator.
|
|
81
|
+
- Fresh-instance bootstrap: `loadPlugins()` hydrates any
|
|
82
|
+
`is_uninstallable=true` plugin missing from `node_modules` from the
|
|
83
|
+
artifact store before normal Phase 1 register.
|
|
84
|
+
- New schema: `plugin_artifacts` (tarball storage), `plugin_install_events`
|
|
85
|
+
(audit/error log). `plugins` extended with `version`, `metadata`,
|
|
86
|
+
`source`, `bundle_id`, `is_primary`. Local plugin sync now writes
|
|
87
|
+
`version` from each plugin's `package.json` so the admin UI shows real
|
|
88
|
+
versions instead of `—`.
|
|
89
|
+
- Tarball-upload endpoint (`POST /api/pluginmanager/upload-tarball`) for
|
|
90
|
+
the install UI; access-gated by `pluginmanager.plugin.manage`.
|
|
91
|
+
- Plugin Manager menu link added to the user menu (main grid, alongside
|
|
92
|
+
Profile / Notification Settings / etc.).
|
|
93
|
+
|
|
94
|
+
Cross-cutting changes:
|
|
95
|
+
|
|
96
|
+
- Backend request/response logging now flows through `rootLogger` (winston)
|
|
97
|
+
instead of `hono/logger`. 5xx responses include the response body inline
|
|
98
|
+
so swallowed early-return errors are visible in the log.
|
|
99
|
+
- The `/api/:pluginId/*` dispatcher now logs which core service is missing
|
|
100
|
+
or which `pluginId` had no metadata when it 500s.
|
|
101
|
+
- New `registerCorePluginMetadata` on `PluginManager` for core routers
|
|
102
|
+
(like the plugin manager itself) that need their metadata visible to the
|
|
103
|
+
RPC dispatcher without going through the full plugin lifecycle.
|
|
104
|
+
- ESLint: `unicorn/no-null` is now disabled globally. Drizzle distinguishes
|
|
105
|
+
between `null` (writes a real SQL NULL) and `undefined` (skip the column
|
|
106
|
+
on insert), so treating them as interchangeable produced latent bugs at
|
|
107
|
+
the persistence boundary. The bulk of the patch-bumped packages above
|
|
108
|
+
reflect lint-fix touches that landed when this rule was relaxed.
|
|
109
|
+
- Workspace-wide license normalization to `Elastic-2.0` (matches
|
|
110
|
+
`LICENSE.md`). Every `package.json` in the workspace now declares the
|
|
111
|
+
same SPDX identifier; the patch bumps capture this.
|
|
112
|
+
|
|
113
|
+
Plugin packages (every `plugins/*`): added a `pack` npm script
|
|
114
|
+
(`bunx @checkstack/scripts plugin-pack`), mirrored each plugin's
|
|
115
|
+
`pluginId` from `plugin-metadata.ts` into `package.json#checkstack.pluginId`
|
|
116
|
+
so install-time validation passes, stubbed any missing required metadata
|
|
117
|
+
fields (`description`, `author`, `license`), and added
|
|
118
|
+
`checkstack.bundle` to multi-package plugin primaries (telegram, rcon, ssh,
|
|
119
|
+
jira, queue-bullmq, queue-memory, cache-memory).
|
|
120
|
+
|
|
121
|
+
Breaking changes:
|
|
122
|
+
|
|
123
|
+
- The legacy single-method `PluginInstaller` interface (`install(packageName)`)
|
|
124
|
+
is removed. Callers must use `coreServices.pluginInstallerRegistry`.
|
|
125
|
+
- The old `pluginAdminContract` and `createPluginAdminRouter` are removed.
|
|
126
|
+
Replaced by `pluginManagerContract` in `@checkstack/pluginmanager-common`
|
|
127
|
+
and `createPluginManagerRouter` in `core/backend`.
|
|
128
|
+
- `@checkstack/test-utils-backend` no longer exports
|
|
129
|
+
`createMockPluginInstaller` / `MockPluginInstaller` (the legacy interface
|
|
130
|
+
it shimmed is gone).
|
|
131
|
+
|
|
132
|
+
Note: bumps are limited to `minor` (for packages with new public API
|
|
133
|
+
surface) and `patch` (for downstream consumers, license normalization,
|
|
134
|
+
and lint fixes). No `major` bumps despite the `PluginInstaller` removal —
|
|
135
|
+
the legacy interface had no third-party consumers in the wild before this
|
|
136
|
+
runtime plugin system landed, and the contract surface is the same shape
|
|
137
|
+
modulo the rename.
|
|
138
|
+
|
|
139
|
+
- Updated dependencies [50e5f5f]
|
|
140
|
+
- @checkstack/backend-api@0.15.0
|
|
141
|
+
- @checkstack/common@0.8.0
|
|
142
|
+
- @checkstack/gitops-common@0.2.2
|
|
143
|
+
- @checkstack/queue-api@0.2.18
|
|
144
|
+
- @checkstack/command-backend@0.1.24
|
|
145
|
+
|
|
3
146
|
## 0.2.7
|
|
4
147
|
|
|
5
148
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@checkstack/gitops-backend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"license": "Elastic-2.0",
|
|
4
5
|
"type": "module",
|
|
5
6
|
"main": "src/index.ts",
|
|
6
7
|
"checkstack": {
|
|
@@ -13,11 +14,11 @@
|
|
|
13
14
|
"lint:code": "eslint . --max-warnings 0"
|
|
14
15
|
},
|
|
15
16
|
"dependencies": {
|
|
16
|
-
"@checkstack/backend-api": "0.
|
|
17
|
-
"@checkstack/gitops-common": "0.2.
|
|
18
|
-
"@checkstack/common": "0.
|
|
19
|
-
"@checkstack/command-backend": "0.1.
|
|
20
|
-
"@checkstack/queue-api": "0.2.
|
|
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",
|
|
21
22
|
"@orpc/server": "^1.13.2",
|
|
22
23
|
"drizzle-orm": "^0.45.0",
|
|
23
24
|
"minimatch": "^10.0.0",
|
|
@@ -26,9 +27,9 @@
|
|
|
26
27
|
"yaml": "^2.7.0"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
|
-
"@checkstack/drizzle-helper": "0.0.
|
|
30
|
-
"@checkstack/scripts": "0.
|
|
31
|
-
"@checkstack/tsconfig": "0.0.
|
|
30
|
+
"@checkstack/drizzle-helper": "0.0.5",
|
|
31
|
+
"@checkstack/scripts": "0.3.0",
|
|
32
|
+
"@checkstack/tsconfig": "0.0.7",
|
|
32
33
|
"@types/bun": "^1.3.5",
|
|
33
34
|
"@types/node": "^20.0.0",
|
|
34
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) => {
|
|
@@ -92,8 +123,8 @@ export const createGitOpsRouter = ({
|
|
|
92
123
|
type: input.type,
|
|
93
124
|
target: input.target,
|
|
94
125
|
pathPattern: input.pathPattern,
|
|
95
|
-
baseUrl: input.baseUrl ?? null,
|
|
96
|
-
authToken: input.authToken ? encrypt(input.authToken) : null,
|
|
126
|
+
baseUrl: input.baseUrl ?? null,
|
|
127
|
+
authToken: input.authToken ? encrypt(input.authToken) : null,
|
|
97
128
|
syncInterval,
|
|
98
129
|
deletionPolicy: input.deletionPolicy ?? "orphan",
|
|
99
130
|
});
|
|
@@ -127,7 +158,7 @@ export const createGitOpsRouter = ({
|
|
|
127
158
|
if (input.data.baseUrl !== undefined) updates.baseUrl = input.data.baseUrl;
|
|
128
159
|
if (input.data.authToken !== undefined) {
|
|
129
160
|
// null = explicitly clear token, string = encrypt and store
|
|
130
|
-
|
|
161
|
+
|
|
131
162
|
updates.authToken = input.data.authToken ? encrypt(input.data.authToken) : null;
|
|
132
163
|
}
|
|
133
164
|
if (input.data.syncInterval !== undefined)
|
package/src/sync/reconciler.ts
CHANGED
|
@@ -475,7 +475,7 @@ async function upsertProvenance(params: {
|
|
|
475
475
|
// Preserve existing entityId on error retries; update on successful reconcile
|
|
476
476
|
...(entityId ? { entityId } : {}),
|
|
477
477
|
status,
|
|
478
|
-
errorMessage: errorMessage ?? null,
|
|
478
|
+
errorMessage: errorMessage ?? null,
|
|
479
479
|
warnings: warnings ?? [],
|
|
480
480
|
repository: file.repository,
|
|
481
481
|
filePath: file.filePath,
|
|
@@ -502,7 +502,7 @@ async function upsertProvenance(params: {
|
|
|
502
502
|
lastSyncHash: contentHash,
|
|
503
503
|
secretRefs,
|
|
504
504
|
status,
|
|
505
|
-
errorMessage: errorMessage ?? null,
|
|
505
|
+
errorMessage: errorMessage ?? null,
|
|
506
506
|
warnings: warnings ?? [],
|
|
507
507
|
});
|
|
508
508
|
}
|
|
@@ -518,7 +518,7 @@ async function updateProviderSyncStatus(params: {
|
|
|
518
518
|
.update(schema.providers)
|
|
519
519
|
.set({
|
|
520
520
|
lastSyncAt: new Date(),
|
|
521
|
-
lastSyncError: error ?? null,
|
|
521
|
+
lastSyncError: error ?? null,
|
|
522
522
|
updatedAt: new Date(),
|
|
523
523
|
})
|
|
524
524
|
.where(eq(schema.providers.id, providerId));
|