Some checks failed
Deploy Landing Page to Storj / deploy (push) Failing after 2s
Adds a first-class TypeScript code generator to speckl-compile that emits: - Const enum for workflow states (IssueWorkflowState) - Strongly-typed class with guards, state transitions, decision log - Proper this. prefixing (state vars only, not local params) - Enum references instead of string literals for state comparisons - Clean tsc --noEmit compilation Also includes: - specs/forgejo-issue-workflow.speckdl — full workflow with 9 actions, 8 constraints, 5 temporal verifications - Generator deduplication of duplicate AST nodes - Support for init block initialization of state variables The generator was validated against the Forgejo issue workflow spec, producing IssueWorkflow.ts that compiles with zero errors. Refs: heartbeat conversation re: speckl-compile extensibility
170 lines
No EOL
3.6 KiB
TypeScript
170 lines
No EOL
3.6 KiB
TypeScript
export interface SpeckNode {
|
|
type: 'speck';
|
|
name: string;
|
|
members: MemberNode[];
|
|
}
|
|
export interface ImportNode {
|
|
type: 'import';
|
|
path: string;
|
|
alias?: string;
|
|
version?: string;
|
|
hash?: string;
|
|
}
|
|
export interface InputNode {
|
|
type: 'input';
|
|
typeExpr: TypeExpr;
|
|
}
|
|
export interface OutputNode {
|
|
type: 'output';
|
|
typeExpr: TypeExpr;
|
|
}
|
|
export interface ConstraintNode {
|
|
type: 'constraint';
|
|
expr: string;
|
|
}
|
|
export interface VerifyNode {
|
|
type: 'verify';
|
|
temporalExpr: string;
|
|
}
|
|
export interface InterfaceNode {
|
|
type: 'interface';
|
|
name: string;
|
|
methods: MethodSignature[];
|
|
}
|
|
export interface MethodSignature {
|
|
name: string;
|
|
params: {
|
|
name: string;
|
|
type: TypeExpr;
|
|
}[];
|
|
returnType: TypeExpr;
|
|
}
|
|
export interface EventNode {
|
|
type: 'event';
|
|
name: string;
|
|
fields: {
|
|
name: string;
|
|
type: TypeExpr;
|
|
}[];
|
|
}
|
|
export interface ProvenanceNode {
|
|
type: 'provenance';
|
|
clauses: ProvenanceClause[];
|
|
}
|
|
export interface ProvenanceClause {
|
|
type: 'regulation' | 'design_decision' | 'parent_spec' | 'external_doc';
|
|
value: string;
|
|
location?: string;
|
|
}
|
|
export interface ReviewNode {
|
|
type: 'review';
|
|
kind: 'manual' | 'auto' | 'hybrid';
|
|
}
|
|
export interface DerivesNode {
|
|
type: 'derives';
|
|
from: string;
|
|
via?: string;
|
|
}
|
|
export interface SatisfiesNode {
|
|
type: 'satisfies';
|
|
requirement: string;
|
|
clause?: string;
|
|
}
|
|
export interface AuthorNode {
|
|
type: 'author';
|
|
name: string;
|
|
email?: string;
|
|
}
|
|
export interface SourceNode {
|
|
type: 'source';
|
|
kind: 'conversation' | 'meeting' | 'document' | 'regulation' | 'architecture_review' | 'threat_model' | 'compliance_audit';
|
|
ref?: string;
|
|
}
|
|
export interface BOMNode {
|
|
type: 'bom';
|
|
compiler?: {
|
|
name: string;
|
|
version?: string;
|
|
};
|
|
solver?: {
|
|
name: string;
|
|
version?: string;
|
|
};
|
|
runtime?: {
|
|
name: string;
|
|
version?: string;
|
|
};
|
|
license?: string;
|
|
hash?: string;
|
|
}
|
|
export interface StateNode {
|
|
type: 'state';
|
|
variables: StateVar[];
|
|
}
|
|
export interface StateVar {
|
|
name: string;
|
|
typeExpr: TypeExpr;
|
|
defaultInit?: string;
|
|
}
|
|
export interface InitNode {
|
|
type: 'init';
|
|
assignments: {
|
|
name: string;
|
|
expr: string;
|
|
}[];
|
|
}
|
|
export interface ActionNode {
|
|
type: 'action';
|
|
name: string;
|
|
params: {
|
|
name: string;
|
|
type: TypeExpr;
|
|
}[];
|
|
statements: ActionStatement[];
|
|
}
|
|
export type ActionStatement = {
|
|
type: 'assign';
|
|
target: string;
|
|
expr: string;
|
|
} | {
|
|
type: 'let';
|
|
name: string;
|
|
expr: string;
|
|
} | {
|
|
type: 'require';
|
|
expr: string;
|
|
} | {
|
|
type: 'emit';
|
|
event: string;
|
|
fields: {
|
|
name: string;
|
|
value: string;
|
|
}[];
|
|
} | {
|
|
type: 'return';
|
|
expr: string;
|
|
};
|
|
export type MemberNode = ImportNode | InputNode | OutputNode | ConstraintNode | VerifyNode | InterfaceNode | EventNode | ProvenanceNode | ReviewNode | DerivesNode | SatisfiesNode | AuthorNode | SourceNode | BOMNode | StateNode | InitNode | ActionNode;
|
|
export interface TypeExpr {
|
|
type: 'primitive' | 'record' | 'list' | 'set' | 'map' | 'ident';
|
|
name?: string;
|
|
fields?: {
|
|
name: string;
|
|
type: TypeExpr;
|
|
}[];
|
|
elementType?: TypeExpr;
|
|
keyType?: TypeExpr;
|
|
valueType?: TypeExpr;
|
|
}
|
|
export interface AST {
|
|
specks: SpeckNode[];
|
|
}
|
|
/**
|
|
* Parse a .speck file and return the AST
|
|
*/
|
|
export declare function parseSpeckFile(filePath: string): AST;
|
|
/**
|
|
* Parse SpeckDL content and return the AST
|
|
*/
|
|
export declare function parseSpeckContent(content: string, filePath?: string): AST;
|
|
//# sourceMappingURL=parser.d.ts.map
|