Skip to content

feat: OpenAPI & fastify adapter #254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Mar 10, 2023
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
19 changes: 4 additions & 15 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,16 @@ labels: ''
assignees: ''
---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1.
2.
3.

**Expected behavior**
A clear and concise description of what you expected to happen.
**Description and expected behavior**
A clear and concise description of what the bug is and what's the expected behavior.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Environment (please complete the following information):**

- OS: [e.g. Mac OS 13.0]
- Node version: [e.g. 16.15.0]
- NPM version: [e.g. 8.19.2]
- ZenStack version: [e.g., 1.0.0-alpha.50]
- Prisma version: [e.g., 4.10.0]
- Database type: [e.g. Postgresql]

**Additional context**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zenstack-monorepo",
"version": "1.0.0-alpha.62",
"version": "1.0.0-alpha.72",
"description": "",
"scripts": {
"build": "pnpm -r build",
Expand Down
2 changes: 1 addition & 1 deletion packages/language/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/language",
"version": "1.0.0-alpha.62",
"version": "1.0.0-alpha.72",
"displayName": "ZenStack modeling language compiler",
"description": "ZenStack modeling language compiler",
"homepage": "https://zenstack.dev",
Expand Down
60 changes: 48 additions & 12 deletions packages/language/src/generated/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ export type DataModelAttributeName = string;

export type DataModelFieldAttributeName = string;

export type Expression = ArrayExpr | BinaryExpr | InvocationExpr | LiteralExpr | MemberAccessExpr | NullExpr | ReferenceExpr | ThisExpr | UnaryExpr;
export type Expression = ArrayExpr | BinaryExpr | InvocationExpr | LiteralExpr | MemberAccessExpr | NullExpr | ObjectExpr | ReferenceExpr | ThisExpr | UnaryExpr;

export const Expression = 'Expression';

export function isExpression(item: unknown): item is Expression {
return reflection.isInstance(item, Expression);
}

export type ExpressionType = 'Any' | 'Boolean' | 'DateTime' | 'Float' | 'Int' | 'Null' | 'String';
export type ExpressionType = 'Any' | 'Boolean' | 'DateTime' | 'Float' | 'Int' | 'Null' | 'Object' | 'String';

export type QualifiedName = string;

Expand Down Expand Up @@ -66,7 +66,7 @@ export function isArgument(item: unknown): item is Argument {
}

export interface ArrayExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $type: 'ArrayExpr';
items: Array<Expression>
}
Expand Down Expand Up @@ -147,7 +147,7 @@ export function isAttributeParamType(item: unknown): item is AttributeParamType
}

export interface BinaryExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $type: 'BinaryExpr';
left: Expression
operator: '!' | '!=' | '&&' | '<' | '<=' | '==' | '>' | '>=' | '?' | '^' | '||'
Expand Down Expand Up @@ -286,6 +286,19 @@ export function isEnumField(item: unknown): item is EnumField {
return reflection.isInstance(item, EnumField);
}

export interface FieldInitializer extends AstNode {
readonly $container: ObjectExpr;
readonly $type: 'FieldInitializer';
name: string
value: Expression
}

export const FieldInitializer = 'FieldInitializer';

export function isFieldInitializer(item: unknown): item is FieldInitializer {
return reflection.isInstance(item, FieldInitializer);
}

export interface FunctionDecl extends AstNode {
readonly $container: Model;
readonly $type: 'FunctionDecl';
Expand Down Expand Up @@ -355,7 +368,7 @@ export function isGeneratorField(item: unknown): item is GeneratorField {
}

export interface InvocationExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $type: 'InvocationExpr';
args: Array<Argument>
function: Reference<FunctionDecl>
Expand All @@ -368,7 +381,7 @@ export function isInvocationExpr(item: unknown): item is InvocationExpr {
}

export interface LiteralExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $type: 'LiteralExpr';
value: boolean | number | string
}
Expand All @@ -380,7 +393,7 @@ export function isLiteralExpr(item: unknown): item is LiteralExpr {
}

export interface MemberAccessExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $type: 'MemberAccessExpr';
member: Reference<DataModelField>
operand: Expression
Expand All @@ -404,7 +417,7 @@ export function isModel(item: unknown): item is Model {
}

export interface NullExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $type: 'NullExpr';
value: string
}
Expand All @@ -415,6 +428,18 @@ export function isNullExpr(item: unknown): item is NullExpr {
return reflection.isInstance(item, NullExpr);
}

export interface ObjectExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $type: 'ObjectExpr';
fields: Array<FieldInitializer>
}

export const ObjectExpr = 'ObjectExpr';

export function isObjectExpr(item: unknown): item is ObjectExpr {
return reflection.isInstance(item, ObjectExpr);
}

export interface Plugin extends AstNode {
readonly $container: Model;
readonly $type: 'Plugin';
Expand Down Expand Up @@ -455,7 +480,7 @@ export function isReferenceArg(item: unknown): item is ReferenceArg {
}

export interface ReferenceExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $type: 'ReferenceExpr';
args: Array<ReferenceArg>
target: Reference<ReferenceTarget>
Expand All @@ -468,7 +493,7 @@ export function isReferenceExpr(item: unknown): item is ReferenceExpr {
}

export interface ThisExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $type: 'ThisExpr';
value: string
}
Expand All @@ -480,7 +505,7 @@ export function isThisExpr(item: unknown): item is ThisExpr {
}

export interface UnaryExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $type: 'UnaryExpr';
operand: Expression
operator: '!'
Expand Down Expand Up @@ -512,6 +537,7 @@ export interface ZModelAstType {
Enum: Enum
EnumField: EnumField
Expression: Expression
FieldInitializer: FieldInitializer
FunctionDecl: FunctionDecl
FunctionParam: FunctionParam
FunctionParamType: FunctionParamType
Expand All @@ -522,6 +548,7 @@ export interface ZModelAstType {
MemberAccessExpr: MemberAccessExpr
Model: Model
NullExpr: NullExpr
ObjectExpr: ObjectExpr
Plugin: Plugin
PluginField: PluginField
ReferenceArg: ReferenceArg
Expand All @@ -535,7 +562,7 @@ export interface ZModelAstType {
export class ZModelAstReflection extends AbstractAstReflection {

getAllTypes(): string[] {
return ['AbstractDeclaration', 'Argument', 'ArrayExpr', 'Attribute', 'AttributeArg', 'AttributeAttribute', 'AttributeParam', 'AttributeParamType', 'BinaryExpr', 'DataModel', 'DataModelAttribute', 'DataModelField', 'DataModelFieldAttribute', 'DataModelFieldType', 'DataSource', 'DataSourceField', 'Enum', 'EnumField', 'Expression', 'FunctionDecl', 'FunctionParam', 'FunctionParamType', 'GeneratorDecl', 'GeneratorField', 'InvocationExpr', 'LiteralExpr', 'MemberAccessExpr', 'Model', 'NullExpr', 'Plugin', 'PluginField', 'ReferenceArg', 'ReferenceExpr', 'ReferenceTarget', 'ThisExpr', 'TypeDeclaration', 'UnaryExpr'];
return ['AbstractDeclaration', 'Argument', 'ArrayExpr', 'Attribute', 'AttributeArg', 'AttributeAttribute', 'AttributeParam', 'AttributeParamType', 'BinaryExpr', 'DataModel', 'DataModelAttribute', 'DataModelField', 'DataModelFieldAttribute', 'DataModelFieldType', 'DataSource', 'DataSourceField', 'Enum', 'EnumField', 'Expression', 'FieldInitializer', 'FunctionDecl', 'FunctionParam', 'FunctionParamType', 'GeneratorDecl', 'GeneratorField', 'InvocationExpr', 'LiteralExpr', 'MemberAccessExpr', 'Model', 'NullExpr', 'ObjectExpr', 'Plugin', 'PluginField', 'ReferenceArg', 'ReferenceExpr', 'ReferenceTarget', 'ThisExpr', 'TypeDeclaration', 'UnaryExpr'];
}

protected override computeIsSubtype(subtype: string, supertype: string): boolean {
Expand All @@ -546,6 +573,7 @@ export class ZModelAstReflection extends AbstractAstReflection {
case LiteralExpr:
case MemberAccessExpr:
case NullExpr:
case ObjectExpr:
case ReferenceExpr:
case ThisExpr:
case UnaryExpr: {
Expand Down Expand Up @@ -756,6 +784,14 @@ export class ZModelAstReflection extends AbstractAstReflection {
]
};
}
case 'ObjectExpr': {
return {
name: 'ObjectExpr',
mandatory: [
{ name: 'fields', type: 'array' }
]
};
}
case 'Plugin': {
return {
name: 'Plugin',
Expand Down
Loading