Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Shared contracts and runtime libraries for CommerceKit GitHub Actions. This public repository is a pnpm monorepo, not a GitHub Marketplace Action. There is no root `action.yml`.

The source manifests prepare `notification-contract@0.0.4` and `ccv2-client@0.0.3` under the `preview` dist-tag. Source versions are not registry publication evidence. APIs remain pre-1.0; verify registry publication before installation. Placeholder reserved versions, if published later, are not supported dependencies.
The source manifests prepare `notification-contract@0.0.5` (unpublished candidate) and `ccv2-client@0.0.3` under the `preview` dist-tag. Source versions are not registry publication evidence. APIs remain pre-1.0; verify registry publication before installation. Placeholder reserved versions, if published later, are not supported dependencies.

| Package | Responsibility | Consumers |
| ------------------------------------------ | --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
Expand Down
2 changes: 1 addition & 1 deletion compatibility/tests/release-safety.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { tmpdir } from 'node:os';
import { join } from 'node:path';
it('publication requires exact package/channel/confirmation and pre-1.0 version', () => {
for (const [name, version] of [
['notification-contract', '0.0.4'],
['notification-contract', '0.0.5'],
['ccv2-client', '0.0.3'],
])
expect(releasePlan(name, 'preview', 'PUBLISH-COMMERCEKIT-PREVIEW')).toMatchObject({
Expand Down
56 changes: 56 additions & 0 deletions compatibility/tests/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import {
createBuildEvent,
createBuildCleanupEvent,
type BuildCleanupEvent,
type BuildCleanupStatus,
type BuildCleanupInputSnapshot,
stripAngleBracketText,
redactJwtLikeTokens,
createDeploymentEvent,
Expand Down Expand Up @@ -37,3 +41,55 @@ encodeCcv2PathSegment(123);
stripAngleBracketText(null);
// @ts-expect-error JWT-like redaction accepts strings only
redactJwtLikeTokens({});

const cleanupInputs: BuildCleanupInputSnapshot = {
'token-endpoint': '[REDACTED]',
'client-id': '[REDACTED]',
'client-secret': '[REDACTED]',
resource: '[REDACTED]',
'subscription-code': 'synthetic',
'api-base-url': 'https://synthetic.example',
'application-code': '',
'retention-days': '30',
'keep-latest': '10',
'dry-run': 'true',
'max-deletions': '20',
'exclude-build-codes': '',
'timeout-minutes': '15',
'continue-on-delete-error': 'false',
};
const cleanupStatus: BuildCleanupStatus = 'warning';
const cleanup: BuildCleanupEvent = createBuildCleanupEvent({
status: cleanupStatus,
data: {
mode: 'dry-run',
subscriptionCode: 'synthetic',
retentionDays: 30,
keepLatest: 10,
cleanupStatus: 'blocked',
scannedCount: 1,
eligibleCount: 0,
plannedCount: 0,
deletionRequestedCount: 0,
skippedCount: 1,
failedCount: 0,
unknownCount: 0,
deferredCount: 0,
durationMs: 1,
inputs: cleanupInputs,
inputsValidated: true,
inputsTruncated: false,
protectedCount: 1,
blockedCount: 0,
issues: [{ code: 'eligibility-unverified', message: 'Safe explanation.' }],
},
});
void cleanup;
const invalidCleanupInputs: BuildCleanupInputSnapshot = {
...cleanupInputs,
// @ts-expect-error credentials must be redacted before event construction
'client-secret': 'synthetic-confidential-value',
};
void invalidCleanupInputs;
// @ts-expect-error cleanup warning support does not widen Deploy status
createDeploymentEvent({ status: 'warning', data: {} });
16 changes: 16 additions & 0 deletions packages/notification-contract/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# notification-contract changelog

## 0.0.5 — unpublished candidate

Allow the existing `warning` status specifically for build cleanup through new
public `BuildCleanupStatus`, preserving Build/Deploy `CompletedStatus` semantics.
Add optional, bounded all-input display context (`BuildCleanupInputSnapshot`),
validation/truncation flags, protected/blocked counts and safe issue explanations.
All fourteen snapshot keys are required when supplied; authentication values must
be literal `[REDACTED]`, public values are at most 256 characters, and at most three
safe issues are accepted. Issue factories project only safe code/message fields.
Old cleanup events remain valid and existing event meanings are unchanged.

Registry checks found published 0.0.4 and no 0.0.5. This source version is not a
published registry dependency. Consumers require coordinated source/tarball tests
and separately authorized publication before normal exact-version adoption.
No OAuth/transport, provider delivery, package publication or release change.

## 0.0.4

Add the provider-neutral `ccv2.build-cleanup.completed` event, `BuildCleanupEvent`/`BuildCleanupEventData` public types, shared schema validation and `createBuildCleanupEvent` factory. Cleanup data reports dry-run/apply mode, exact scope, combined retention settings, bounded outcome counts and duration using the existing completed-status vocabulary. Accepted deletion requests are distinct from physical removal. Existing events, schema version 1, sanitizers and factory semantics are preserved.
Expand Down
37 changes: 35 additions & 2 deletions packages/notification-contract/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Provider-neutral NotificationEvent v1 types, schema and validation for Notify, Build, Deploy, future Check and reusable workflows. No CCv2 calls, CLI diagnostics, Action I/O, polling, provider rendering or webhook delivery.

Public exports: `NotificationEvent`, `NotificationStatus`, `NotificationEventType`, `NotificationSource`, `NotificationContext`, `NotificationLink`, `SafeNotificationError`, `CheckEventData`, `BuildEventData`, `DeploymentEventData`, `BuildCleanupEvent`, `BuildCleanupEventData`; `validateNotificationEvent`, `parseNotificationEventJson`, `validateNotificationLink`, `validateGitHubRunUrl`, `extractSafeGitHubContext`, `mergeProducerContext`, `mergeNotifierContext`, `createCheckEvent`, `createBuildEvent`, `createDeploymentEvent`, `createBuildCleanupEvent`, `redactKnownSecrets`, `sanitizeBoundedText`, `sanitizeLabel`, `sanitizeErrorMessage`.
Public exports: `NotificationEvent`, `NotificationStatus`, `NotificationEventType`, `NotificationSource`, `NotificationContext`, `NotificationLink`, `SafeNotificationError`, `CheckEventData`, `BuildEventData`, `DeploymentEventData`, `BuildCleanupEvent`, `BuildCleanupEventData`, `BuildCleanupStatus`, `BuildCleanupInputSnapshot`; `validateNotificationEvent`, `parseNotificationEventJson`, `validateNotificationLink`, `validateGitHubRunUrl`, `extractSafeGitHubContext`, `mergeProducerContext`, `mergeNotifierContext`, `createCheckEvent`, `createBuildEvent`, `createDeploymentEvent`, `createBuildCleanupEvent`, `redactKnownSecrets`, `sanitizeBoundedText`, `sanitizeLabel`, `sanitizeErrorMessage`.

```ts
import { createCheckEvent, parseNotificationEventJson } from '@commercekit-tools/notification-contract';
Expand All @@ -22,7 +22,7 @@ Extraction reads only approved runner fields, never event payloads. Explicit pro

Install from GitHub Packages after a supported version is published. Configure `@commercekit-tools:registry=https://npm.pkg.github.com`; local users need a classic PAT with `read:packages` in user-level configuration. Consumer Actions need package Actions read access and `GITHUB_TOKEN` with `packages: read`. See the repository authentication guide. Pin exact versions, never ranges.

Source version: `0.0.4`, prepared for pre-1.0 integration under the `preview` dist-tag. This manifest is not publication evidence. Verify registry availability before installation and pin `0.0.4` exactly. Stable API and coordinated consumer/Sandbox validation remain future gates. Reservation versions are unsupported.
Source version: `0.0.5`, an **unpublished candidate**. Registry inspection verified published versions through `0.0.4`; `0.0.5` was absent. Do not pin `0.0.5` as a registry dependency until separately authorized publication is verified. The currently published `0.0.4` package lacks the additions below. Exact-source packed-tarball tests may validate candidate consumers in isolation; no machine-local link belongs in a normal lockfile. Stable API and coordinated consumer/Sandbox validation remain future gates. Reservation versions are unsupported.

Independent package SemVer applies; stable breaking changes require a major increment. NotificationEvent schema version is separate from package version. Preserve current consumer contracts during migration. No telemetry or logging is performed. Use synthetic tests and register exact runtime secrets; pattern redaction cannot identify all secrets.

Expand All @@ -45,3 +45,36 @@ an event. This additive event requires a compatible Notify renderer. Consumers u
published 0.0.3 or older reject it. Verify 0.0.4 registry availability and the
matching Notify revision before enabling this integration; a source manifest
is not publication evidence.

## Cleanup warning and input context — 0.0.5 candidate

This additive cleanup-only extension accepts the existing global `warning` status
through public `BuildCleanupStatus`; Build and Deploy continue using unchanged
`CompletedStatus`. Old cleanup events remain valid. A published 0.0.4 validator
rejects cleanup warnings, so producer and Notify revisions must be coordinated.
No publication, tag, release or consumer migration is performed by these changes.

`BuildCleanupEventData` adds optional `inputs`, `inputsValidated`,
`inputsTruncated`, `protectedCount`, `blockedCount` and `issues` fields. If an
`inputs` snapshot is present, it must contain exactly all 14 names from the Cleanup
Action: token-endpoint, client-id, client-secret, resource, subscription-code,
api-base-url, application-code, retention-days, keep-latest, dry-run, max-deletions,
exclude-build-codes, timeout-minutes and continue-on-delete-error. No new Action
input or retention option is introduced.

The public `BuildCleanupInputSnapshot` type and schema require all four
technical-user authentication values to be the literal `[REDACTED]`; unredacted
values are rejected with a fixed error that does not echo the payload. Other
snapshot values are display strings bounded to 256 characters, allowing an
invalid supplied setting to be reported without inventing a valid effective
number. Producers set `inputsValidated=false` when execution stopped during
input validation and `inputsTruncated=true` when bounded display omitted text.
They must still redact registered secrets and credential-like text from public
settings with the shared sanitizers before calling the factory.

Counts remain nonnegative safe integers. `issues` holds at most three reusable
`SafeNotificationError` values, with code at most 100 and message 1–1000 characters.
The factory retains only code/message for each issue, dropping raw nested fields,
then validates the event. Outcome/severity interpretation belongs to the producer:
a warning must not hide a deletion failure or unknown mutation result. Accepted
deletion counts still describe initiation rather than physical removal.
2 changes: 1 addition & 1 deletion packages/notification-contract/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@commercekit-tools/notification-contract",
"version": "0.0.4",
"version": "0.0.5",
"description": "Provider-neutral NotificationEvent v1 contracts and factories.",
"license": "MIT",
"type": "module",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
"if": { "properties": { "eventType": { "const": "ccv2.build-cleanup.completed" } } },
"then": {
"properties": {
"status": { "enum": ["success", "failure", "cancelled", "internal-error"] },
"status": { "enum": ["success", "warning", "failure", "cancelled", "internal-error"] },
"data": { "$ref": "#/$defs/cleanup" }
}
}
Expand Down Expand Up @@ -210,9 +210,51 @@
"unknownCount": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
"deferredCount": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
"durationMs": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
"error": { "$ref": "#/$defs/error" }
"error": { "$ref": "#/$defs/error" },
"inputs": { "$ref": "#/$defs/cleanupInputs" },
"inputsValidated": { "type": "boolean" },
"inputsTruncated": { "type": "boolean" },
"protectedCount": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
"blockedCount": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
"issues": { "type": "array", "maxItems": 3, "items": { "$ref": "#/$defs/error" } }
},
"additionalProperties": true
},
"cleanupInputs": {
"type": "object",
"required": [
"token-endpoint",
"client-id",
"client-secret",
"resource",
"subscription-code",
"api-base-url",
"application-code",
"retention-days",
"keep-latest",
"dry-run",
"max-deletions",
"exclude-build-codes",
"timeout-minutes",
"continue-on-delete-error"
],
"properties": {
"token-endpoint": { "const": "[REDACTED]" },
"client-id": { "const": "[REDACTED]" },
"client-secret": { "const": "[REDACTED]" },
"resource": { "const": "[REDACTED]" },
"subscription-code": { "type": "string", "maxLength": 256 },
"api-base-url": { "type": "string", "maxLength": 256 },
"application-code": { "type": "string", "maxLength": 256 },
"retention-days": { "type": "string", "maxLength": 256 },
"keep-latest": { "type": "string", "maxLength": 256 },
"dry-run": { "type": "string", "maxLength": 256 },
"max-deletions": { "type": "string", "maxLength": 256 },
"exclude-build-codes": { "type": "string", "maxLength": 256 },
"timeout-minutes": { "type": "string", "maxLength": 256 },
"continue-on-delete-error": { "type": "string", "maxLength": 256 }
},
"additionalProperties": false
}
},
"additionalProperties": true
Expand Down
10 changes: 10 additions & 0 deletions packages/notification-contract/src/factories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ function create(
const e = selected.error as { code?: string; message?: string };
selected.error = { ...(e.code !== undefined ? { code: e.code } : {}), message: e.message };
}
if (Array.isArray(selected.issues)) {
selected.issues = selected.issues.map((issue: unknown) => {
if (!issue || typeof issue !== 'object') return issue;
const code = 'code' in issue ? issue.code : undefined;
return {
...(code !== undefined ? { code } : {}),
message: 'message' in issue ? issue.message : undefined,
};
});
}
const eventType =
kind === 'cleanup'
? 'ccv2.build-cleanup.completed'
Expand Down
44 changes: 43 additions & 1 deletion packages/notification-contract/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const schema = {
if: { properties: { eventType: { const: 'ccv2.build-cleanup.completed' } } },
then: {
properties: {
status: { enum: ['success', 'failure', 'cancelled', 'internal-error'] },
status: { enum: ['success', 'warning', 'failure', 'cancelled', 'internal-error'] },
data: { $ref: '#/$defs/cleanup' },
},
},
Expand Down Expand Up @@ -210,9 +210,51 @@ export const schema = {
deferredCount: { type: 'integer', minimum: 0, maximum: 9007199254740991 },
durationMs: { type: 'integer', minimum: 0, maximum: 9007199254740991 },
error: { $ref: '#/$defs/error' },
inputs: { $ref: '#/$defs/cleanupInputs' },
inputsValidated: { type: 'boolean' },
inputsTruncated: { type: 'boolean' },
protectedCount: { type: 'integer', minimum: 0, maximum: 9007199254740991 },
blockedCount: { type: 'integer', minimum: 0, maximum: 9007199254740991 },
issues: { type: 'array', maxItems: 3, items: { $ref: '#/$defs/error' } },
},
additionalProperties: true,
},
cleanupInputs: {
type: 'object',
required: [
'token-endpoint',
'client-id',
'client-secret',
'resource',
'subscription-code',
'api-base-url',
'application-code',
'retention-days',
'keep-latest',
'dry-run',
'max-deletions',
'exclude-build-codes',
'timeout-minutes',
'continue-on-delete-error',
],
properties: {
'token-endpoint': { const: '[REDACTED]' },
'client-id': { const: '[REDACTED]' },
'client-secret': { const: '[REDACTED]' },
resource: { const: '[REDACTED]' },
'subscription-code': { type: 'string', maxLength: 256 },
'api-base-url': { type: 'string', maxLength: 256 },
'application-code': { type: 'string', maxLength: 256 },
'retention-days': { type: 'string', maxLength: 256 },
'keep-latest': { type: 'string', maxLength: 256 },
'dry-run': { type: 'string', maxLength: 256 },
'max-deletions': { type: 'string', maxLength: 256 },
'exclude-build-codes': { type: 'string', maxLength: 256 },
'timeout-minutes': { type: 'string', maxLength: 256 },
'continue-on-delete-error': { type: 'string', maxLength: 256 },
},
additionalProperties: false,
},
},
additionalProperties: true,
} as const;
28 changes: 27 additions & 1 deletion packages/notification-contract/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export type NotificationStatus =
'started' | 'success' | 'warning' | 'failure' | 'cancelled' | 'internal-error' | 'action-required';
export type CompletedStatus = 'success' | 'failure' | 'cancelled' | 'internal-error';
/** Cleanup warning support does not change Build or Deploy completed semantics. */
export type BuildCleanupStatus = CompletedStatus | 'warning';
export type NotificationEventType =
| 'ccv2.build-cleanup.completed'
| 'check.completed'
Expand Down Expand Up @@ -97,6 +99,23 @@ export type DeploymentEvent = EventBase &
) & { data: DeploymentEventData };
export type NotificationEvent = CheckEvent | BuildEvent | DeploymentEvent | BuildCleanupEvent;

/** Bounded display context only; authentication values must never enter an event. */
export interface BuildCleanupInputSnapshot {
'token-endpoint': '[REDACTED]';
'client-id': '[REDACTED]';
'client-secret': '[REDACTED]';
resource: '[REDACTED]';
'subscription-code': string;
'api-base-url': string;
'application-code': string;
'retention-days': string;
'keep-latest': string;
'dry-run': string;
'max-deletions': string;
'exclude-build-codes': string;
'timeout-minutes': string;
'continue-on-delete-error': string;
}
export interface BuildCleanupEventData {
mode: 'dry-run' | 'apply';
subscriptionCode: string;
Expand All @@ -114,9 +133,16 @@ export interface BuildCleanupEventData {
deferredCount: number;
durationMs: number;
error?: SafeNotificationError;
/** Optional for compatibility with events emitted before 0.0.5. */
inputs?: BuildCleanupInputSnapshot;
inputsValidated?: boolean;
inputsTruncated?: boolean;
protectedCount?: number;
blockedCount?: number;
issues?: SafeNotificationError[];
}
export type BuildCleanupEvent = EventBase & {
eventType: 'ccv2.build-cleanup.completed';
status: CompletedStatus;
status: BuildCleanupStatus;
data: BuildCleanupEventData;
};
Loading
Loading