@xtrape/capsule-contracts-node 0.1.0-public-review.1 → 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/README.md +34 -9
- package/dist/index.cjs +0 -10
- package/dist/index.d.cts +1 -5
- package/dist/index.d.ts +1 -5
- package/dist/index.js +0 -8
- package/package.json +9 -11
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ The package currently exports:
|
|
|
48
48
|
- Command schemas: create command, command detail, command result.
|
|
49
49
|
- Audit and dashboard schemas.
|
|
50
50
|
- System health/version schemas.
|
|
51
|
-
- Helpers: `
|
|
51
|
+
- Helpers: `parseSort`, `paginate`, `HttpError`, `ListQueryBase`.
|
|
52
52
|
|
|
53
53
|
## Validate Agent Registration
|
|
54
54
|
|
|
@@ -249,16 +249,27 @@ Currently exported codes include:
|
|
|
249
249
|
|
|
250
250
|
See the OpenAPI contract and docs site for endpoint-specific errors.
|
|
251
251
|
|
|
252
|
-
## ID
|
|
252
|
+
## ID generation
|
|
253
|
+
|
|
254
|
+
This package validates IDs at the wire boundary (via Zod) but does **not** mint
|
|
255
|
+
them. Until v0.1.x there was a small `newId()` helper plus an `idPrefixes`
|
|
256
|
+
table; both were removed in `0.2.0` to keep the contracts surface focused on
|
|
257
|
+
the wire spec — see [`CHANGELOG.md`](./CHANGELOG.md) and the
|
|
258
|
+
"Breaking changes" section at the top of this README.
|
|
259
|
+
|
|
260
|
+
Consumers that need local ID generation should provide their own factory.
|
|
261
|
+
Example using `nanoid` directly:
|
|
253
262
|
|
|
254
263
|
```ts
|
|
255
|
-
import {
|
|
264
|
+
import { customAlphabet } from "nanoid";
|
|
256
265
|
|
|
257
|
-
const
|
|
266
|
+
const idBody = customAlphabet("0123456789abcdefghijklmnopqrstuvwxyz", 21);
|
|
267
|
+
const commandId = `cmd_${idBody()}`;
|
|
258
268
|
```
|
|
259
269
|
|
|
260
|
-
|
|
261
|
-
`cfg_`, `act_`, `cmd_`, `crs_`, and
|
|
270
|
+
Documented ID prefixes in use across CE and the Agent SDK include `wks_`,
|
|
271
|
+
`usr_`, `agt_`, `tok_`, `svc_`, `hlr_`, `cfg_`, `act_`, `cmd_`, `crs_`, and
|
|
272
|
+
`aud_`. These are enforced by the Zod schemas via `z.string().startsWith(...)`.
|
|
262
273
|
|
|
263
274
|
## List Helpers
|
|
264
275
|
|
|
@@ -290,10 +301,24 @@ const response = paginate(items, query.page, query.pageSize, total);
|
|
|
290
301
|
|
|
291
302
|
| Package | Compatible with |
|
|
292
303
|
| -------------------------------------- | ---------------------------------------- |
|
|
304
|
+
| `@xtrape/capsule-contracts-node@0.2.x` | Opstage CE `0.2.x` and Agent SDK `0.2.x` |
|
|
293
305
|
| `@xtrape/capsule-contracts-node@0.1.x` | Opstage CE `0.1.x` and Agent SDK `0.1.x` |
|
|
294
306
|
|
|
295
|
-
|
|
296
|
-
|
|
307
|
+
Pin matching minor versions across CE, Agent SDK, and Contracts. The wire
|
|
308
|
+
protocol may still evolve before `v1.0`.
|
|
309
|
+
|
|
310
|
+
## Breaking changes in `0.2.0`
|
|
311
|
+
|
|
312
|
+
- **`newId()` removed.** The helper minted random IDs with a prefix; it was
|
|
313
|
+
never used by CE (entity IDs are minted in the backend). External consumers
|
|
314
|
+
that imported `newId` must wire their own factory — see the
|
|
315
|
+
[ID generation](#id-generation) section above.
|
|
316
|
+
- **`idPrefixes` constant and `IdPrefix` type removed.** Same rationale.
|
|
317
|
+
- **`nanoid` runtime dependency removed** as a consequence. Consumers that
|
|
318
|
+
relied on a transitive `nanoid` install must now add it directly.
|
|
319
|
+
|
|
320
|
+
The wire schemas themselves are **unchanged** between `0.1.x` and `0.2.x`;
|
|
321
|
+
existing `0.1.x` agents continue to validate against a `0.2.x` backend.
|
|
297
322
|
|
|
298
323
|
## Schema Stability
|
|
299
324
|
|
|
@@ -309,7 +334,7 @@ guarantees per schema group are:
|
|
|
309
334
|
| `ActionPrepareResultSchema` | Provisional | Added in `0.1.0-public-review.0`. Field shape may still tighten before `v1.0`. |
|
|
310
335
|
| `Command.type` enum | Evolving | Currently `ACTION_PREPARE` / `ACTION_EXECUTE`. New types may be added. |
|
|
311
336
|
| Error codes (`ErrorCode`) | Evolving | New codes may be added. Existing codes will not change meaning before `v1.0`. |
|
|
312
|
-
| Helpers (`
|
|
337
|
+
| Helpers (`parseSort`, `paginate`, `HttpError`, `ListQueryBase`) | Provisional | Helpful for backend-style consumers but not strictly part of the wire spec; may move to a separate utility package in a future minor. (`newId` / `idPrefixes` / `IdPrefix` were removed in `0.2.0` — see "Breaking changes in `0.2.0`" above.) |
|
|
313
338
|
|
|
314
339
|
**Until `v1.0`**, pin to a single minor across CE / Agent SDK / Contracts.
|
|
315
340
|
Breaking changes will be called out in `CHANGELOG.md`.
|
package/dist/index.cjs
CHANGED
|
@@ -81,8 +81,6 @@ __export(index_exports, {
|
|
|
81
81
|
createRegistrationTokenRequestSchema: () => createRegistrationTokenRequestSchema,
|
|
82
82
|
createUserRequestSchema: () => createUserRequestSchema,
|
|
83
83
|
healthReportInputSchema: () => healthReportInputSchema,
|
|
84
|
-
idPrefixes: () => idPrefixes,
|
|
85
|
-
newId: () => newId,
|
|
86
84
|
paginate: () => paginate,
|
|
87
85
|
parseSort: () => parseSort,
|
|
88
86
|
registerAgentRequestSchema: () => registerAgentRequestSchema,
|
|
@@ -94,7 +92,6 @@ __export(index_exports, {
|
|
|
94
92
|
z: () => import_zod.z
|
|
95
93
|
});
|
|
96
94
|
module.exports = __toCommonJS(index_exports);
|
|
97
|
-
var import_nanoid = require("nanoid");
|
|
98
95
|
var import_zod = require("zod");
|
|
99
96
|
var AgentStatus = ["PENDING", "ONLINE", "OFFLINE", "DISABLED", "REVOKED"];
|
|
100
97
|
var CapsuleServiceStatus = ["UNKNOWN", "HEALTHY", "UNHEALTHY", "STALE", "OFFLINE"];
|
|
@@ -119,11 +116,6 @@ var ErrorCode = {
|
|
|
119
116
|
AGENT_REVOKED: "AGENT_REVOKED",
|
|
120
117
|
AGENT_DISABLED: "AGENT_DISABLED"
|
|
121
118
|
};
|
|
122
|
-
var idPrefixes = ["wks_", "usr_", "agt_", "tok_", "svc_", "hlr_", "cfg_", "act_", "cmd_", "crs_", "aud_"];
|
|
123
|
-
var NANO = (0, import_nanoid.customAlphabet)("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-", 21);
|
|
124
|
-
function newId(prefix) {
|
|
125
|
-
return `${prefix}${NANO()}`;
|
|
126
|
-
}
|
|
127
119
|
var AnyJson = import_zod.z.record(import_zod.z.any());
|
|
128
120
|
var AgentStatusSchema = import_zod.z.enum(AgentStatus);
|
|
129
121
|
var CapsuleServiceStatusSchema = import_zod.z.enum(CapsuleServiceStatus);
|
|
@@ -274,8 +266,6 @@ function paginate(items, page, pageSize, total) {
|
|
|
274
266
|
createRegistrationTokenRequestSchema,
|
|
275
267
|
createUserRequestSchema,
|
|
276
268
|
healthReportInputSchema,
|
|
277
|
-
idPrefixes,
|
|
278
|
-
newId,
|
|
279
269
|
paginate,
|
|
280
270
|
parseSort,
|
|
281
271
|
registerAgentRequestSchema,
|
package/dist/index.d.cts
CHANGED
|
@@ -33,10 +33,6 @@ declare const ErrorCode: {
|
|
|
33
33
|
readonly AGENT_DISABLED: "AGENT_DISABLED";
|
|
34
34
|
};
|
|
35
35
|
type ErrorCode = typeof ErrorCode[keyof typeof ErrorCode];
|
|
36
|
-
declare const idPrefixes: readonly ["wks_", "usr_", "agt_", "tok_", "svc_", "hlr_", "cfg_", "act_", "cmd_", "crs_", "aud_"];
|
|
37
|
-
type IdPrefix = typeof idPrefixes[number];
|
|
38
|
-
|
|
39
|
-
declare function newId<P extends IdPrefix>(prefix: P): `${P}${string}`;
|
|
40
36
|
declare const AnyJson: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
41
37
|
declare const AgentStatusSchema: z.ZodEnum<["PENDING", "ONLINE", "OFFLINE", "DISABLED", "REVOKED"]>;
|
|
42
38
|
declare const CapsuleServiceStatusSchema: z.ZodEnum<["UNKNOWN", "HEALTHY", "UNHEALTHY", "STALE", "OFFLINE"]>;
|
|
@@ -2781,4 +2777,4 @@ declare function paginate<T>(items: T[], page: number, pageSize: number, total:
|
|
|
2781
2777
|
};
|
|
2782
2778
|
};
|
|
2783
2779
|
|
|
2784
|
-
export { type ActionDefinition, type ActionDefinitionInput, ActionDefinitionInputSchema, ActionDefinitionSchema, type ActionPrepareResult, ActionPrepareResultSchema, type AdminLoginRequest, AdminLoginRequestSchema, type AdminSession, AdminSessionSchema, type Agent, type AgentHeartbeatRequest, AgentHeartbeatRequestSchema, type AgentHeartbeatResponse, AgentHeartbeatResponseSchema, AgentSchema, AgentStatus, AgentStatusSchema, AnyJson, AuditActorType, type AuditEvent, AuditEventSchema, AuditResult, type CapsuleManifest, CapsuleManifestSchema, type CapsuleService, type CapsuleServiceDetail, CapsuleServiceDetailSchema, CapsuleServiceSchema, CapsuleServiceStatus, CapsuleServiceStatusSchema, type Command, type CommandDetail, CommandDetailSchema, type CommandResult, CommandResultSchema, CommandSchema, CommandStatus, CommandStatusSchema, type CommandType, CommandTypeSchema, type ConfigItem, type ConfigItemInput, ConfigItemInputSchema, ConfigItemSchema, type CreateActionCommandRequest, CreateActionCommandRequestSchema, type CreateRegistrationTokenRequest, CreateRegistrationTokenRequestSchema, type CreateRegistrationTokenResponse, CreateRegistrationTokenResponseSchema, type CreateUserRequest, DangerLevel, DangerLevelSchema, type DashboardSummary, DashboardSummarySchema, ErrorCode, type ErrorEnvelope, type HealthReport, type HealthReportInput, HealthReportInputSchema, HealthReportSchema, HealthStatus, HealthStatusSchema, HttpError,
|
|
2780
|
+
export { type ActionDefinition, type ActionDefinitionInput, ActionDefinitionInputSchema, ActionDefinitionSchema, type ActionPrepareResult, ActionPrepareResultSchema, type AdminLoginRequest, AdminLoginRequestSchema, type AdminSession, AdminSessionSchema, type Agent, type AgentHeartbeatRequest, AgentHeartbeatRequestSchema, type AgentHeartbeatResponse, AgentHeartbeatResponseSchema, AgentSchema, AgentStatus, AgentStatusSchema, AnyJson, AuditActorType, type AuditEvent, AuditEventSchema, AuditResult, type CapsuleManifest, CapsuleManifestSchema, type CapsuleService, type CapsuleServiceDetail, CapsuleServiceDetailSchema, CapsuleServiceSchema, CapsuleServiceStatus, CapsuleServiceStatusSchema, type Command, type CommandDetail, CommandDetailSchema, type CommandResult, CommandResultSchema, CommandSchema, CommandStatus, CommandStatusSchema, type CommandType, CommandTypeSchema, type ConfigItem, type ConfigItemInput, ConfigItemInputSchema, ConfigItemSchema, type CreateActionCommandRequest, CreateActionCommandRequestSchema, type CreateRegistrationTokenRequest, CreateRegistrationTokenRequestSchema, type CreateRegistrationTokenResponse, CreateRegistrationTokenResponseSchema, type CreateUserRequest, DangerLevel, DangerLevelSchema, type DashboardSummary, DashboardSummarySchema, ErrorCode, type ErrorEnvelope, type HealthReport, type HealthReportInput, HealthReportInputSchema, HealthReportSchema, HealthStatus, HealthStatusSchema, HttpError, ListQueryBase, type Pagination, type RegisterAgentRequest, RegisterAgentRequestSchema, type RegisterAgentResponse, RegisterAgentResponseSchema, type RegistrationToken, RegistrationTokenSchema, type ReportCommandResultRequest, ReportCommandResultRequestSchema, type ReportedService, ReportedServiceSchema, type ResetUserPasswordRequest, type RuntimeKind, RuntimeKindSchema, type ServiceReportRequest, ServiceReportRequestSchema, type SuccessEnvelope, type SystemHealth, SystemHealthSchema, type SystemVersion, SystemVersionSchema, TokenStatus, type UpdateUserRequest, type User, UserRole, UserSchema, actionDefinitionInputSchema, actionPrepareResultSchema, adminLoginRequestSchema, agentHeartbeatRequestSchema, configItemInputSchema, createActionCommandRequestSchema, createRegistrationTokenRequestSchema, createUserRequestSchema, healthReportInputSchema, paginate, parseSort, registerAgentRequestSchema, reportCommandResultRequestSchema, reportedServiceSchema, resetUserPasswordRequestSchema, serviceReportRequestSchema, updateUserRequestSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -33,10 +33,6 @@ declare const ErrorCode: {
|
|
|
33
33
|
readonly AGENT_DISABLED: "AGENT_DISABLED";
|
|
34
34
|
};
|
|
35
35
|
type ErrorCode = typeof ErrorCode[keyof typeof ErrorCode];
|
|
36
|
-
declare const idPrefixes: readonly ["wks_", "usr_", "agt_", "tok_", "svc_", "hlr_", "cfg_", "act_", "cmd_", "crs_", "aud_"];
|
|
37
|
-
type IdPrefix = typeof idPrefixes[number];
|
|
38
|
-
|
|
39
|
-
declare function newId<P extends IdPrefix>(prefix: P): `${P}${string}`;
|
|
40
36
|
declare const AnyJson: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
41
37
|
declare const AgentStatusSchema: z.ZodEnum<["PENDING", "ONLINE", "OFFLINE", "DISABLED", "REVOKED"]>;
|
|
42
38
|
declare const CapsuleServiceStatusSchema: z.ZodEnum<["UNKNOWN", "HEALTHY", "UNHEALTHY", "STALE", "OFFLINE"]>;
|
|
@@ -2781,4 +2777,4 @@ declare function paginate<T>(items: T[], page: number, pageSize: number, total:
|
|
|
2781
2777
|
};
|
|
2782
2778
|
};
|
|
2783
2779
|
|
|
2784
|
-
export { type ActionDefinition, type ActionDefinitionInput, ActionDefinitionInputSchema, ActionDefinitionSchema, type ActionPrepareResult, ActionPrepareResultSchema, type AdminLoginRequest, AdminLoginRequestSchema, type AdminSession, AdminSessionSchema, type Agent, type AgentHeartbeatRequest, AgentHeartbeatRequestSchema, type AgentHeartbeatResponse, AgentHeartbeatResponseSchema, AgentSchema, AgentStatus, AgentStatusSchema, AnyJson, AuditActorType, type AuditEvent, AuditEventSchema, AuditResult, type CapsuleManifest, CapsuleManifestSchema, type CapsuleService, type CapsuleServiceDetail, CapsuleServiceDetailSchema, CapsuleServiceSchema, CapsuleServiceStatus, CapsuleServiceStatusSchema, type Command, type CommandDetail, CommandDetailSchema, type CommandResult, CommandResultSchema, CommandSchema, CommandStatus, CommandStatusSchema, type CommandType, CommandTypeSchema, type ConfigItem, type ConfigItemInput, ConfigItemInputSchema, ConfigItemSchema, type CreateActionCommandRequest, CreateActionCommandRequestSchema, type CreateRegistrationTokenRequest, CreateRegistrationTokenRequestSchema, type CreateRegistrationTokenResponse, CreateRegistrationTokenResponseSchema, type CreateUserRequest, DangerLevel, DangerLevelSchema, type DashboardSummary, DashboardSummarySchema, ErrorCode, type ErrorEnvelope, type HealthReport, type HealthReportInput, HealthReportInputSchema, HealthReportSchema, HealthStatus, HealthStatusSchema, HttpError,
|
|
2780
|
+
export { type ActionDefinition, type ActionDefinitionInput, ActionDefinitionInputSchema, ActionDefinitionSchema, type ActionPrepareResult, ActionPrepareResultSchema, type AdminLoginRequest, AdminLoginRequestSchema, type AdminSession, AdminSessionSchema, type Agent, type AgentHeartbeatRequest, AgentHeartbeatRequestSchema, type AgentHeartbeatResponse, AgentHeartbeatResponseSchema, AgentSchema, AgentStatus, AgentStatusSchema, AnyJson, AuditActorType, type AuditEvent, AuditEventSchema, AuditResult, type CapsuleManifest, CapsuleManifestSchema, type CapsuleService, type CapsuleServiceDetail, CapsuleServiceDetailSchema, CapsuleServiceSchema, CapsuleServiceStatus, CapsuleServiceStatusSchema, type Command, type CommandDetail, CommandDetailSchema, type CommandResult, CommandResultSchema, CommandSchema, CommandStatus, CommandStatusSchema, type CommandType, CommandTypeSchema, type ConfigItem, type ConfigItemInput, ConfigItemInputSchema, ConfigItemSchema, type CreateActionCommandRequest, CreateActionCommandRequestSchema, type CreateRegistrationTokenRequest, CreateRegistrationTokenRequestSchema, type CreateRegistrationTokenResponse, CreateRegistrationTokenResponseSchema, type CreateUserRequest, DangerLevel, DangerLevelSchema, type DashboardSummary, DashboardSummarySchema, ErrorCode, type ErrorEnvelope, type HealthReport, type HealthReportInput, HealthReportInputSchema, HealthReportSchema, HealthStatus, HealthStatusSchema, HttpError, ListQueryBase, type Pagination, type RegisterAgentRequest, RegisterAgentRequestSchema, type RegisterAgentResponse, RegisterAgentResponseSchema, type RegistrationToken, RegistrationTokenSchema, type ReportCommandResultRequest, ReportCommandResultRequestSchema, type ReportedService, ReportedServiceSchema, type ResetUserPasswordRequest, type RuntimeKind, RuntimeKindSchema, type ServiceReportRequest, ServiceReportRequestSchema, type SuccessEnvelope, type SystemHealth, SystemHealthSchema, type SystemVersion, SystemVersionSchema, TokenStatus, type UpdateUserRequest, type User, UserRole, UserSchema, actionDefinitionInputSchema, actionPrepareResultSchema, adminLoginRequestSchema, agentHeartbeatRequestSchema, configItemInputSchema, createActionCommandRequestSchema, createRegistrationTokenRequestSchema, createUserRequestSchema, healthReportInputSchema, paginate, parseSort, registerAgentRequestSchema, reportCommandResultRequestSchema, reportedServiceSchema, resetUserPasswordRequestSchema, serviceReportRequestSchema, updateUserRequestSchema };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import { customAlphabet } from "nanoid";
|
|
3
2
|
import { z } from "zod";
|
|
4
3
|
var AgentStatus = ["PENDING", "ONLINE", "OFFLINE", "DISABLED", "REVOKED"];
|
|
5
4
|
var CapsuleServiceStatus = ["UNKNOWN", "HEALTHY", "UNHEALTHY", "STALE", "OFFLINE"];
|
|
@@ -24,11 +23,6 @@ var ErrorCode = {
|
|
|
24
23
|
AGENT_REVOKED: "AGENT_REVOKED",
|
|
25
24
|
AGENT_DISABLED: "AGENT_DISABLED"
|
|
26
25
|
};
|
|
27
|
-
var idPrefixes = ["wks_", "usr_", "agt_", "tok_", "svc_", "hlr_", "cfg_", "act_", "cmd_", "crs_", "aud_"];
|
|
28
|
-
var NANO = customAlphabet("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-", 21);
|
|
29
|
-
function newId(prefix) {
|
|
30
|
-
return `${prefix}${NANO()}`;
|
|
31
|
-
}
|
|
32
26
|
var AnyJson = z.record(z.any());
|
|
33
27
|
var AgentStatusSchema = z.enum(AgentStatus);
|
|
34
28
|
var CapsuleServiceStatusSchema = z.enum(CapsuleServiceStatus);
|
|
@@ -178,8 +172,6 @@ export {
|
|
|
178
172
|
createRegistrationTokenRequestSchema,
|
|
179
173
|
createUserRequestSchema,
|
|
180
174
|
healthReportInputSchema,
|
|
181
|
-
idPrefixes,
|
|
182
|
-
newId,
|
|
183
175
|
paginate,
|
|
184
176
|
parseSort,
|
|
185
177
|
registerAgentRequestSchema,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xtrape/capsule-contracts-node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "TypeScript contracts and Zod schemas for Xtrape Capsule and Opstage wire protocols.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"xtrape",
|
|
@@ -36,15 +36,7 @@
|
|
|
36
36
|
"LICENSE",
|
|
37
37
|
"NOTICE"
|
|
38
38
|
],
|
|
39
|
-
"scripts": {
|
|
40
|
-
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
41
|
-
"prepack": "pnpm build",
|
|
42
|
-
"test": "vitest run",
|
|
43
|
-
"typecheck": "tsc --noEmit",
|
|
44
|
-
"lint": "tsc --noEmit"
|
|
45
|
-
},
|
|
46
39
|
"dependencies": {
|
|
47
|
-
"nanoid": "^5.0.9",
|
|
48
40
|
"zod": "^3.25.0"
|
|
49
41
|
},
|
|
50
42
|
"devDependencies": {
|
|
@@ -59,5 +51,11 @@
|
|
|
59
51
|
"registry": "https://registry.npmjs.org/",
|
|
60
52
|
"access": "public"
|
|
61
53
|
},
|
|
62
|
-
"license": "Apache-2.0"
|
|
63
|
-
|
|
54
|
+
"license": "Apache-2.0",
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
57
|
+
"test": "vitest run",
|
|
58
|
+
"typecheck": "tsc --noEmit",
|
|
59
|
+
"lint": "tsc --noEmit"
|
|
60
|
+
}
|
|
61
|
+
}
|