@claudian-collab/protocol 1.0.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/LICENSE +21 -0
- package/README.md +105 -0
- package/dist/CollabCloudBinding.d.ts +106 -0
- package/dist/CollabCloudBinding.js +431 -0
- package/dist/CollabCloudProjectEvent.d.ts +41 -0
- package/dist/CollabCloudProjectEvent.js +133 -0
- package/dist/CollabCloudProjectSnapshot.d.ts +42 -0
- package/dist/CollabCloudProjectSnapshot.js +281 -0
- package/dist/CollabConstants.d.ts +32 -0
- package/dist/CollabConstants.js +34 -0
- package/dist/CollabControlOperationCodecs.d.ts +28 -0
- package/dist/CollabControlOperationCodecs.js +63 -0
- package/dist/CollabError.d.ts +27 -0
- package/dist/CollabError.js +165 -0
- package/dist/CollabMarkdownProse.d.ts +1 -0
- package/dist/CollabMarkdownProse.js +57 -0
- package/dist/CollabMemberMentionParser.d.ts +6 -0
- package/dist/CollabMemberMentionParser.js +51 -0
- package/dist/CollabProtocol.d.ts +144 -0
- package/dist/CollabProtocol.js +67 -0
- package/dist/CollabRequestTicketRequestCodecs.d.ts +5 -0
- package/dist/CollabRequestTicketRequestCodecs.js +266 -0
- package/dist/CollabRequestTicketResponseCodecs.d.ts +15 -0
- package/dist/CollabRequestTicketResponseCodecs.js +368 -0
- package/dist/CollabTicketReferenceParser.d.ts +24 -0
- package/dist/CollabTicketReferenceParser.js +56 -0
- package/dist/CollabValidation.d.ts +5 -0
- package/dist/CollabValidation.js +26 -0
- package/dist/DevelopmentBootstrap.d.ts +199 -0
- package/dist/DevelopmentBootstrap.js +544 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +67 -0
- package/dist/types.d.ts +138 -0
- package/dist/types.js +11 -0
- package/package.json +66 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseCollabTicketReferences = parseCollabTicketReferences;
|
|
4
|
+
exports.scanCollabTicketReferences = scanCollabTicketReferences;
|
|
5
|
+
const CollabConstants_1 = require("./CollabConstants");
|
|
6
|
+
const CollabMarkdownProse_1 = require("./CollabMarkdownProse");
|
|
7
|
+
const CLOSING_KEYWORD_PATTERN = /(?:^|[^A-Za-z])(close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved)[ \t]*:?[ \t]*$/i;
|
|
8
|
+
const TICKET_REFERENCE_PATTERN = /(^|[^#0-9A-Za-z_])#([1-9][0-9]*)(?![#0-9A-Za-z_])/gm;
|
|
9
|
+
function relationKindBefore(maskedDescription, referenceOffset) {
|
|
10
|
+
const prefix = maskedDescription.slice(0, referenceOffset);
|
|
11
|
+
return CLOSING_KEYWORD_PATTERN.test(prefix) ? 'resolves' : 'references';
|
|
12
|
+
}
|
|
13
|
+
function parseCollabTicketReferences(description) {
|
|
14
|
+
if (new TextEncoder().encode(description).byteLength >
|
|
15
|
+
CollabConstants_1.COLLAB_LIMITS.maxRequestDescriptionBytes) {
|
|
16
|
+
return { status: 'invalid', reason: 'description-too-large' };
|
|
17
|
+
}
|
|
18
|
+
const scanned = scanCollabTicketReferences(description);
|
|
19
|
+
if (scanned.status === 'invalid')
|
|
20
|
+
return scanned;
|
|
21
|
+
const references = new Map();
|
|
22
|
+
for (const token of scanned.tokens) {
|
|
23
|
+
const existing = references.get(token.ticketNumber);
|
|
24
|
+
if (existing !== 'resolves' || token.kind === 'resolves') {
|
|
25
|
+
references.set(token.ticketNumber, token.kind);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
status: 'ok',
|
|
30
|
+
references: [...references.entries()]
|
|
31
|
+
.sort(([left], [right]) => left - right)
|
|
32
|
+
.map(([ticketNumber, kind]) => ({ ticketNumber, kind })),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function scanCollabTicketReferences(description) {
|
|
36
|
+
const prose = (0, CollabMarkdownProse_1.maskCollabMarkdownProse)(description);
|
|
37
|
+
const tokens = [];
|
|
38
|
+
for (const match of prose.matchAll(TICKET_REFERENCE_PATTERN)) {
|
|
39
|
+
const prefix = match[1] ?? '';
|
|
40
|
+
const numberToken = match[2];
|
|
41
|
+
if (!numberToken || match.index === undefined)
|
|
42
|
+
continue;
|
|
43
|
+
const ticketNumber = Number(numberToken);
|
|
44
|
+
if (!Number.isSafeInteger(ticketNumber)) {
|
|
45
|
+
return { status: 'invalid', reason: 'ticket-number-out-of-range' };
|
|
46
|
+
}
|
|
47
|
+
const referenceOffset = match.index + prefix.length;
|
|
48
|
+
tokens.push({
|
|
49
|
+
from: referenceOffset,
|
|
50
|
+
kind: relationKindBefore(prose, referenceOffset),
|
|
51
|
+
ticketNumber,
|
|
52
|
+
to: referenceOffset + numberToken.length + 1,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return { status: 'ok', tokens };
|
|
56
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function isCollabProjectId(value: unknown): value is string;
|
|
2
|
+
export declare function isCollabMemberId(value: unknown): value is string;
|
|
3
|
+
export declare function isCollabOpaqueId(value: unknown): value is string;
|
|
4
|
+
export declare function isCollabGitOid(value: unknown): value is string;
|
|
5
|
+
export declare function hasUtf8ByteLengthAtMost(value: string, maximum: number): boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isCollabProjectId = isCollabProjectId;
|
|
4
|
+
exports.isCollabMemberId = isCollabMemberId;
|
|
5
|
+
exports.isCollabOpaqueId = isCollabOpaqueId;
|
|
6
|
+
exports.isCollabGitOid = isCollabGitOid;
|
|
7
|
+
exports.hasUtf8ByteLengthAtMost = hasUtf8ByteLengthAtMost;
|
|
8
|
+
const COLLAB_PROJECT_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
|
|
9
|
+
const COLLAB_MEMBER_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
|
|
10
|
+
const COLLAB_OPAQUE_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;
|
|
11
|
+
const COLLAB_GIT_OID_PATTERN = /^[0-9a-f]{40}(?:[0-9a-f]{24})?$/;
|
|
12
|
+
function isCollabProjectId(value) {
|
|
13
|
+
return typeof value === 'string' && COLLAB_PROJECT_ID_PATTERN.test(value);
|
|
14
|
+
}
|
|
15
|
+
function isCollabMemberId(value) {
|
|
16
|
+
return typeof value === 'string' && COLLAB_MEMBER_ID_PATTERN.test(value);
|
|
17
|
+
}
|
|
18
|
+
function isCollabOpaqueId(value) {
|
|
19
|
+
return typeof value === 'string' && COLLAB_OPAQUE_ID_PATTERN.test(value);
|
|
20
|
+
}
|
|
21
|
+
function isCollabGitOid(value) {
|
|
22
|
+
return typeof value === 'string' && COLLAB_GIT_OID_PATTERN.test(value);
|
|
23
|
+
}
|
|
24
|
+
function hasUtf8ByteLengthAtMost(value, maximum) {
|
|
25
|
+
return new TextEncoder().encode(value).byteLength <= maximum;
|
|
26
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { COLLAB_MAIN_REF, type CollabProtocolVersion } from './CollabConstants';
|
|
2
|
+
import { type DevelopmentBootstrapOperation } from './CollabCloudBinding';
|
|
3
|
+
import type { CollabDecodeResult } from './CollabProtocol';
|
|
4
|
+
import type { CollabGitOid, CollabIsoTimestamp, CollabMemberId, CollabOperationId, CollabProjectId, CollabRole } from './types';
|
|
5
|
+
export declare const DEVELOPMENT_BOOTSTRAP_MANIFEST_SCHEMA_VERSION: 1;
|
|
6
|
+
export declare const DEVELOPMENT_BOOTSTRAP_ATTEMPT_STATES: readonly ["collecting", "validating", "ready", "activating", "rejected", "cancelled", "recovery-required", "activated"];
|
|
7
|
+
export declare const DEVELOPMENT_BOOTSTRAP_ACTIVATION_PHASES: readonly ["publish-intent", "repository-published", "activated", "completed"];
|
|
8
|
+
export declare const DEVELOPMENT_BOOTSTRAP_CANCELLATION_PHASES: readonly ["cancel-intent", "cancelled", "recovery-required"];
|
|
9
|
+
export declare const DEVELOPMENT_BOOTSTRAP_OPERATIONS: readonly ["beginDevelopmentBootstrap", "submitDevelopmentBootstrapReport", "getDevelopmentBootstrap", "activateDevelopmentBootstrap", "cancelDevelopmentBootstrap", "putDevelopmentBootstrapGitBundle"];
|
|
10
|
+
export type DevelopmentBootstrapAttemptState = typeof DEVELOPMENT_BOOTSTRAP_ATTEMPT_STATES[number];
|
|
11
|
+
export type DevelopmentBootstrapActivationPhase = typeof DEVELOPMENT_BOOTSTRAP_ACTIVATION_PHASES[number];
|
|
12
|
+
export type DevelopmentBootstrapCancellationPhase = typeof DEVELOPMENT_BOOTSTRAP_CANCELLATION_PHASES[number];
|
|
13
|
+
export type DevelopmentBootstrapBundleState = 'missing' | 'uploaded' | 'validated';
|
|
14
|
+
export type DevelopmentBootstrapObjectFormat = 'sha1' | 'sha256';
|
|
15
|
+
export interface DevelopmentBootstrapComparisonMember {
|
|
16
|
+
readonly activatedAt: CollabIsoTimestamp;
|
|
17
|
+
readonly createdAt: CollabIsoTimestamp;
|
|
18
|
+
readonly displayName: string;
|
|
19
|
+
readonly memberId: CollabMemberId;
|
|
20
|
+
readonly personalRef: string;
|
|
21
|
+
readonly role: CollabRole;
|
|
22
|
+
readonly status: 'active';
|
|
23
|
+
}
|
|
24
|
+
export interface DevelopmentBootstrapComparison {
|
|
25
|
+
readonly mainOid: CollabGitOid;
|
|
26
|
+
readonly mainRef: typeof COLLAB_MAIN_REF;
|
|
27
|
+
readonly managerSetGeneration: number;
|
|
28
|
+
readonly members: readonly [
|
|
29
|
+
DevelopmentBootstrapComparisonMember,
|
|
30
|
+
DevelopmentBootstrapComparisonMember
|
|
31
|
+
];
|
|
32
|
+
readonly projectCreatedAt: CollabIsoTimestamp;
|
|
33
|
+
readonly projectId: CollabProjectId;
|
|
34
|
+
readonly projectName: string;
|
|
35
|
+
readonly sourceCaFingerprint: string;
|
|
36
|
+
readonly sourceEventSequence: number;
|
|
37
|
+
readonly sourceHostMemberId: CollabMemberId;
|
|
38
|
+
}
|
|
39
|
+
export interface DevelopmentBootstrapSourceEligibility {
|
|
40
|
+
readonly liveInvitations: 0;
|
|
41
|
+
readonly nonActiveMemberships: 0;
|
|
42
|
+
readonly nonterminalAcceptOperations: 0;
|
|
43
|
+
readonly nonterminalHostTransfers: 0;
|
|
44
|
+
readonly nonterminalManagerOffers: 0;
|
|
45
|
+
readonly requestComments: 0;
|
|
46
|
+
readonly requests: 0;
|
|
47
|
+
readonly terminalProjectTransitions: 0;
|
|
48
|
+
readonly ticketComments: 0;
|
|
49
|
+
readonly ticketMentions: 0;
|
|
50
|
+
readonly ticketRelations: 0;
|
|
51
|
+
readonly tickets: 0;
|
|
52
|
+
}
|
|
53
|
+
export interface DevelopmentBootstrapGitRef {
|
|
54
|
+
readonly name: string;
|
|
55
|
+
readonly oid: CollabGitOid;
|
|
56
|
+
}
|
|
57
|
+
export interface DevelopmentBootstrapManifest {
|
|
58
|
+
readonly attemptId: string;
|
|
59
|
+
readonly comparison: DevelopmentBootstrapComparison;
|
|
60
|
+
readonly createdAt: CollabIsoTimestamp;
|
|
61
|
+
readonly git: {
|
|
62
|
+
readonly bundle: {
|
|
63
|
+
readonly byteCount: number;
|
|
64
|
+
readonly sha256: string;
|
|
65
|
+
};
|
|
66
|
+
readonly objectFormat: DevelopmentBootstrapObjectFormat;
|
|
67
|
+
readonly refs: readonly DevelopmentBootstrapGitRef[];
|
|
68
|
+
};
|
|
69
|
+
readonly manifestSchemaVersion: typeof DEVELOPMENT_BOOTSTRAP_MANIFEST_SCHEMA_VERSION;
|
|
70
|
+
readonly protocolVersion: CollabProtocolVersion;
|
|
71
|
+
readonly sourceEligibility: DevelopmentBootstrapSourceEligibility;
|
|
72
|
+
}
|
|
73
|
+
export interface DevelopmentBootstrapClientReadiness {
|
|
74
|
+
readonly cleanupSettled: true;
|
|
75
|
+
readonly collabGitChildrenDrained: true;
|
|
76
|
+
readonly conflictRecoverySettled: true;
|
|
77
|
+
readonly hostTransferSettled: true;
|
|
78
|
+
readonly joinSettled: true;
|
|
79
|
+
readonly leaveSettled: true;
|
|
80
|
+
readonly managerResponsibilitySettled: true;
|
|
81
|
+
readonly projectOperationQueueDrained: true;
|
|
82
|
+
readonly projectSetupSettled: true;
|
|
83
|
+
readonly projectWorkSessionClosed: true;
|
|
84
|
+
readonly publishSettled: true;
|
|
85
|
+
readonly reconciliationSettled: true;
|
|
86
|
+
readonly reconnectSettled: true;
|
|
87
|
+
readonly repositoryIdentityExact: true;
|
|
88
|
+
readonly retirementSettled: true;
|
|
89
|
+
}
|
|
90
|
+
export interface DevelopmentHostStopAttestation {
|
|
91
|
+
readonly attemptId: string;
|
|
92
|
+
readonly autoStartDisabled: true;
|
|
93
|
+
readonly fenceDurable: true;
|
|
94
|
+
readonly fenceId: string;
|
|
95
|
+
readonly hostStopped: true;
|
|
96
|
+
readonly manifestSha256: string;
|
|
97
|
+
readonly projectId: CollabProjectId;
|
|
98
|
+
readonly resourcesDrained: true;
|
|
99
|
+
readonly routeUnregistered: true;
|
|
100
|
+
readonly stoppedAt: CollabIsoTimestamp;
|
|
101
|
+
}
|
|
102
|
+
export interface DevelopmentBootstrapReport {
|
|
103
|
+
readonly attemptId: string;
|
|
104
|
+
readonly capturedAt: CollabIsoTimestamp;
|
|
105
|
+
readonly clientReadiness: DevelopmentBootstrapClientReadiness;
|
|
106
|
+
readonly comparison: DevelopmentBootstrapComparison;
|
|
107
|
+
readonly hostStopAttestation?: DevelopmentHostStopAttestation;
|
|
108
|
+
readonly observedPersonalRefOid: CollabGitOid;
|
|
109
|
+
readonly reporterMemberId: CollabMemberId;
|
|
110
|
+
}
|
|
111
|
+
export interface DevelopmentBootstrapActivationResult {
|
|
112
|
+
readonly activatedAt: CollabIsoTimestamp;
|
|
113
|
+
readonly activationOperationId: CollabOperationId;
|
|
114
|
+
readonly placementGeneration: number;
|
|
115
|
+
readonly projectId: CollabProjectId;
|
|
116
|
+
}
|
|
117
|
+
export interface DevelopmentBootstrapAttemptStatus {
|
|
118
|
+
readonly activationPhase?: DevelopmentBootstrapActivationPhase;
|
|
119
|
+
readonly activationResult?: DevelopmentBootstrapActivationResult;
|
|
120
|
+
readonly attemptId: string;
|
|
121
|
+
readonly bundleState: DevelopmentBootstrapBundleState;
|
|
122
|
+
readonly cancellationPhase?: DevelopmentBootstrapCancellationPhase;
|
|
123
|
+
readonly createdAt: CollabIsoTimestamp;
|
|
124
|
+
readonly expiresAt: CollabIsoTimestamp;
|
|
125
|
+
readonly manifestSha256: string;
|
|
126
|
+
readonly projectId: CollabProjectId;
|
|
127
|
+
readonly reporterMemberIds: readonly CollabMemberId[];
|
|
128
|
+
readonly state: DevelopmentBootstrapAttemptState;
|
|
129
|
+
}
|
|
130
|
+
export interface BeginDevelopmentBootstrapRequest {
|
|
131
|
+
readonly manifest: DevelopmentBootstrapManifest;
|
|
132
|
+
}
|
|
133
|
+
export interface SubmitDevelopmentBootstrapReportRequest {
|
|
134
|
+
readonly attemptId: string;
|
|
135
|
+
readonly report: DevelopmentBootstrapReport;
|
|
136
|
+
}
|
|
137
|
+
export interface GetDevelopmentBootstrapRequest {
|
|
138
|
+
readonly attemptId: string;
|
|
139
|
+
}
|
|
140
|
+
export interface ActivateDevelopmentBootstrapRequest {
|
|
141
|
+
readonly attemptId: string;
|
|
142
|
+
readonly manifestSha256: string;
|
|
143
|
+
}
|
|
144
|
+
export interface CancelDevelopmentBootstrapRequest {
|
|
145
|
+
readonly attemptId: string;
|
|
146
|
+
}
|
|
147
|
+
export interface PutDevelopmentBootstrapGitBundleRequest {
|
|
148
|
+
readonly attemptId: string;
|
|
149
|
+
readonly byteCount: number;
|
|
150
|
+
readonly contentEncoding: 'identity';
|
|
151
|
+
readonly contentType: 'application/x-git-bundle';
|
|
152
|
+
readonly sha256: string;
|
|
153
|
+
}
|
|
154
|
+
export interface DevelopmentBootstrapOperationMap {
|
|
155
|
+
readonly activateDevelopmentBootstrap: {
|
|
156
|
+
readonly request: ActivateDevelopmentBootstrapRequest;
|
|
157
|
+
readonly response: DevelopmentBootstrapAttemptStatus;
|
|
158
|
+
};
|
|
159
|
+
readonly beginDevelopmentBootstrap: {
|
|
160
|
+
readonly request: BeginDevelopmentBootstrapRequest;
|
|
161
|
+
readonly response: DevelopmentBootstrapAttemptStatus;
|
|
162
|
+
};
|
|
163
|
+
readonly cancelDevelopmentBootstrap: {
|
|
164
|
+
readonly request: CancelDevelopmentBootstrapRequest;
|
|
165
|
+
readonly response: DevelopmentBootstrapAttemptStatus;
|
|
166
|
+
};
|
|
167
|
+
readonly getDevelopmentBootstrap: {
|
|
168
|
+
readonly request: GetDevelopmentBootstrapRequest;
|
|
169
|
+
readonly response: DevelopmentBootstrapAttemptStatus;
|
|
170
|
+
};
|
|
171
|
+
readonly putDevelopmentBootstrapGitBundle: {
|
|
172
|
+
readonly request: PutDevelopmentBootstrapGitBundleRequest;
|
|
173
|
+
readonly response: DevelopmentBootstrapAttemptStatus;
|
|
174
|
+
};
|
|
175
|
+
readonly submitDevelopmentBootstrapReport: {
|
|
176
|
+
readonly request: SubmitDevelopmentBootstrapReportRequest;
|
|
177
|
+
readonly response: DevelopmentBootstrapAttemptStatus;
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
export interface DevelopmentBootstrapOperationCodec<Request, Response> {
|
|
181
|
+
readonly decodeRequest: (value: unknown) => CollabDecodeResult<Request>;
|
|
182
|
+
readonly decodeResponse: (value: unknown) => Response;
|
|
183
|
+
}
|
|
184
|
+
type DevelopmentBootstrapCodecMap = {
|
|
185
|
+
readonly [Operation in DevelopmentBootstrapOperation]: DevelopmentBootstrapOperationCodec<DevelopmentBootstrapOperationMap[Operation]['request'], DevelopmentBootstrapOperationMap[Operation]['response']>;
|
|
186
|
+
};
|
|
187
|
+
export declare function decodeDevelopmentBootstrapManifest(value: unknown): DevelopmentBootstrapManifest;
|
|
188
|
+
export declare function encodeDevelopmentBootstrapManifestCanonicalJson(value: DevelopmentBootstrapManifest): string;
|
|
189
|
+
export declare function decodeDevelopmentBootstrapReport(value: unknown): DevelopmentBootstrapReport;
|
|
190
|
+
export declare const DEVELOPMENT_BOOTSTRAP_OPERATION_CODECS: Readonly<{
|
|
191
|
+
readonly beginDevelopmentBootstrap: DevelopmentBootstrapOperationCodec<BeginDevelopmentBootstrapRequest, DevelopmentBootstrapAttemptStatus>;
|
|
192
|
+
readonly submitDevelopmentBootstrapReport: DevelopmentBootstrapOperationCodec<SubmitDevelopmentBootstrapReportRequest, DevelopmentBootstrapAttemptStatus>;
|
|
193
|
+
readonly getDevelopmentBootstrap: DevelopmentBootstrapOperationCodec<GetDevelopmentBootstrapRequest, DevelopmentBootstrapAttemptStatus>;
|
|
194
|
+
readonly activateDevelopmentBootstrap: DevelopmentBootstrapOperationCodec<ActivateDevelopmentBootstrapRequest, DevelopmentBootstrapAttemptStatus>;
|
|
195
|
+
readonly cancelDevelopmentBootstrap: DevelopmentBootstrapOperationCodec<CancelDevelopmentBootstrapRequest, DevelopmentBootstrapAttemptStatus>;
|
|
196
|
+
readonly putDevelopmentBootstrapGitBundle: DevelopmentBootstrapOperationCodec<PutDevelopmentBootstrapGitBundleRequest, DevelopmentBootstrapAttemptStatus>;
|
|
197
|
+
}>;
|
|
198
|
+
export declare function developmentBootstrapOperationCodec<Operation extends DevelopmentBootstrapOperation>(operation: Operation): DevelopmentBootstrapCodecMap[Operation];
|
|
199
|
+
export {};
|