@checkstack/cache-backend 0.2.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 +36 -0
- package/package.json +27 -0
- package/src/index.ts +28 -0
- package/src/router.ts +69 -0
- package/tsconfig.json +6 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# @checkstack/cache-backend
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8d1ef12: ## Infrastructure Configuration Shell & Cache System
|
|
8
|
+
|
|
9
|
+
### New Packages
|
|
10
|
+
|
|
11
|
+
- **`@checkstack/cache-api`**: Core cache abstractions — `CacheProvider` interface, `createScopedCache` factory for plugin key isolation, `CachePlugin`/`CacheManager` lifecycle interfaces.
|
|
12
|
+
- **`@checkstack/cache-common`**: Shared cache types, RPC contract (`getPlugins`, `getConfiguration`, `updateConfiguration`), access rules, and plugin metadata.
|
|
13
|
+
- **`@checkstack/cache-backend`**: Cache settings RPC router — exposes plugin discovery, configuration read/write endpoints with access-gated authorization.
|
|
14
|
+
- **`@checkstack/cache-frontend`**: Cache configuration tab component for the Infrastructure Settings page.
|
|
15
|
+
- **`@checkstack/infrastructure-common`**: Infrastructure tab registry, routes, and shared types for the IDE-style configuration shell.
|
|
16
|
+
- **`@checkstack/infrastructure-frontend`**: Infrastructure Settings page with vertical tab bar, per-tab access control, and user menu integration.
|
|
17
|
+
|
|
18
|
+
### Modified Packages
|
|
19
|
+
|
|
20
|
+
- **`@checkstack/backend-api`**: Added `cachePluginRegistry` and `cacheManager` to `RpcContext` and `coreServices`.
|
|
21
|
+
- **`@checkstack/backend`**: Registered cache services in boot sequence, added cache config loading, extended dependency sorter for cache plugin ordering.
|
|
22
|
+
- **`@checkstack/queue-frontend`**: Refactored from standalone `/queue/config` route to an infrastructure tab. Queue settings now live inside the Infrastructure Settings page.
|
|
23
|
+
|
|
24
|
+
### Architecture
|
|
25
|
+
|
|
26
|
+
The former monolithic Queue Config page is replaced by a pluggable Infrastructure Settings shell (`/infrastructure/config`). Plugins register configuration tabs via `registerInfrastructureTab()` with their own access rules, icons, and components. The shell evaluates per-tab access and only renders tabs the user can see.
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- Updated dependencies [8d1ef12]
|
|
31
|
+
- Updated dependencies [8d1ef12]
|
|
32
|
+
- Updated dependencies [8d1ef12]
|
|
33
|
+
- @checkstack/common@0.7.0
|
|
34
|
+
- @checkstack/cache-api@0.2.0
|
|
35
|
+
- @checkstack/cache-common@0.2.0
|
|
36
|
+
- @checkstack/backend-api@0.13.0
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@checkstack/cache-backend",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "src/index.ts",
|
|
6
|
+
"checkstack": {
|
|
7
|
+
"type": "backend"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"typecheck": "tsc --noEmit",
|
|
11
|
+
"lint": "bun run lint:code",
|
|
12
|
+
"lint:code": "eslint . --max-warnings 0"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@checkstack/backend-api": "0.12.0",
|
|
16
|
+
"@checkstack/cache-api": "0.1.0",
|
|
17
|
+
"@checkstack/cache-common": "0.1.0",
|
|
18
|
+
"@checkstack/common": "0.6.5",
|
|
19
|
+
"@orpc/server": "^1.13.2",
|
|
20
|
+
"zod": "^4.0.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@checkstack/scripts": "0.1.2",
|
|
24
|
+
"@checkstack/tsconfig": "0.0.5",
|
|
25
|
+
"typescript": "^5.7.2"
|
|
26
|
+
}
|
|
27
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createBackendPlugin, coreServices } from "@checkstack/backend-api";
|
|
2
|
+
import {
|
|
3
|
+
cacheAccessRules,
|
|
4
|
+
pluginMetadata,
|
|
5
|
+
cacheContract,
|
|
6
|
+
} from "@checkstack/cache-common";
|
|
7
|
+
import { createCacheRouter } from "./router";
|
|
8
|
+
|
|
9
|
+
export default createBackendPlugin({
|
|
10
|
+
metadata: pluginMetadata,
|
|
11
|
+
register(env) {
|
|
12
|
+
env.registerAccessRules(cacheAccessRules);
|
|
13
|
+
|
|
14
|
+
env.registerInit({
|
|
15
|
+
deps: {
|
|
16
|
+
logger: coreServices.logger,
|
|
17
|
+
rpc: coreServices.rpc,
|
|
18
|
+
config: coreServices.config,
|
|
19
|
+
},
|
|
20
|
+
init: async ({ logger, rpc, config }) => {
|
|
21
|
+
logger.debug("📦 Initializing Cache Settings Backend...");
|
|
22
|
+
|
|
23
|
+
const cacheRouter = createCacheRouter(config);
|
|
24
|
+
rpc.registerRouter(cacheRouter, cacheContract);
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
});
|
package/src/router.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {
|
|
2
|
+
toJsonSchema,
|
|
3
|
+
ConfigService,
|
|
4
|
+
RpcContext,
|
|
5
|
+
autoAuthMiddleware,
|
|
6
|
+
} from "@checkstack/backend-api";
|
|
7
|
+
import { cacheContract } from "@checkstack/cache-common";
|
|
8
|
+
import { implement, ORPCError } from "@orpc/server";
|
|
9
|
+
import { extractErrorMessage } from "@checkstack/common";
|
|
10
|
+
|
|
11
|
+
const os = implement(cacheContract)
|
|
12
|
+
.$context<RpcContext>()
|
|
13
|
+
.use(autoAuthMiddleware);
|
|
14
|
+
|
|
15
|
+
export const createCacheRouter = (configService: ConfigService) => {
|
|
16
|
+
return os.router({
|
|
17
|
+
getPlugins: os.getPlugins.handler(async ({ context }) => {
|
|
18
|
+
const plugins = context.cachePluginRegistry.getPlugins().map((p) => ({
|
|
19
|
+
id: p.id,
|
|
20
|
+
displayName: p.displayName,
|
|
21
|
+
description: p.description,
|
|
22
|
+
configVersion: p.configVersion,
|
|
23
|
+
configSchema: toJsonSchema(p.configSchema),
|
|
24
|
+
}));
|
|
25
|
+
return plugins;
|
|
26
|
+
}),
|
|
27
|
+
|
|
28
|
+
getConfiguration: os.getConfiguration.handler(async ({ context }) => {
|
|
29
|
+
const activePluginId = context.cacheManager.getActivePlugin();
|
|
30
|
+
const plugin = context.cachePluginRegistry.getPlugin(activePluginId);
|
|
31
|
+
|
|
32
|
+
if (!plugin) {
|
|
33
|
+
throw new Error("Active cache plugin not found");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Get redacted config from ConfigService using plugin's schema
|
|
37
|
+
const config = await configService.getRedacted(
|
|
38
|
+
activePluginId,
|
|
39
|
+
plugin.configSchema,
|
|
40
|
+
plugin.configVersion,
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
pluginId: activePluginId,
|
|
45
|
+
config: config || {},
|
|
46
|
+
};
|
|
47
|
+
}),
|
|
48
|
+
|
|
49
|
+
updateConfiguration: os.updateConfiguration.handler(
|
|
50
|
+
async ({ input, context }) => {
|
|
51
|
+
const { pluginId, config } = input;
|
|
52
|
+
try {
|
|
53
|
+
await context.cacheManager.setActiveBackend(pluginId, config);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
throw new ORPCError("INTERNAL_SERVER_ERROR", {
|
|
56
|
+
message: extractErrorMessage(error),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
context.logger.info(
|
|
60
|
+
`Cache configuration updated to plugin: ${pluginId}`,
|
|
61
|
+
);
|
|
62
|
+
return {
|
|
63
|
+
pluginId,
|
|
64
|
+
config,
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
),
|
|
68
|
+
});
|
|
69
|
+
};
|