Skip to content

Commit

Permalink
Merge pull request #273 from mnfst/hooks
Browse files Browse the repository at this point in the history
✨  Webhooks
  • Loading branch information
brunobuddy authored Jan 24, 2025
2 parents 351e50a + 68bf2c0 commit 5f1f1d7
Show file tree
Hide file tree
Showing 43 changed files with 964 additions and 33 deletions.
5 changes: 5 additions & 0 deletions .changeset/two-moose-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'manifest': minor
---

Added webhooks
11 changes: 10 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"semi": false,
"singleQuote": true,
"trailingComma": "none"
"trailingComma": "none",

"overrides": [
{
"files": "*.yml",
"options": {
"singleQuote": false
}
}
]
}
98 changes: 97 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion packages/core/json-schema/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import validationSchema from './schema/definitions/validation-schema.json'
import manifestSchema from './schema/schema.json'
import policiesSchema from './schema/definitions/policies/policies-schema.json'
import policySchema from './schema/definitions/policies/policy-schema.json'
import hooksSchema from './schema/definitions/hooks/hooks-schema.json'
import hookSchema from './schema/definitions/hooks/hook-schema.json'

export default [
manifestSchema,
Expand All @@ -25,5 +27,9 @@ export default [

// Policies.
policiesSchema,
policySchema
policySchema,

// Hooks.
hooksSchema,
hookSchema
]
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
"$ref": "./validation-schema.json"
}
}
},
"hooks": {
"description": "The hooks related to entity records events. Doc: https://manifest.build/docs/hooks",
"type": "object",
"$ref": "./hooks/hooks-schema.json"
}
},
"if": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://schema.manifest.build/definitions/hooks/hook-schema.json",
"title": "Hook Schema",
"description": "A hook related to an event the entity records. Doc: https://manifest.build/docs/hooks",
"type": "object",

"properties": {
"url": {
"description": "The URL to send the request to.",
"type": "string"
},
"method": {
"type": "string",
"description": "The HTTP method to use, defaults to POST.",
"enum": ["GET", "POST", "PUT", "PATCH", "DELETE"]
},
"headers": {
"type": "object",
"description": "The headers to send with the request",
"additionalProperties": {
"type": "string"
}
}
},
"required": ["url"],
"additionalProperties": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://schema.manifest.build/definitions/hooks/hooks-schema.json",
"title": "Hooks Schema",
"description": "The hooks related to events the entity records. Doc: https://manifest.build/docs/hooks",
"type": "object",
"properties": {
"beforeCreate": {
"type": "array",
"description": "Hooks to run before creating a record. Doc: https://manifest.build/docs/hooks#events",
"items": {
"$ref": "hook-schema.json"
}
},
"afterCreate": {
"type": "array",
"description": "Hooks to run after creating a record. Doc: https://manifest.build/docs/hooks#events",
"items": {
"$ref": "hook-schema.json"
}
},
"beforeUpdate": {
"type": "array",
"description": "Hooks to run before updating a record. Doc: https://manifest.build/docs/hooks#events",
"items": {
"$ref": "hook-schema.json"
}
},
"afterUpdate": {
"type": "array",
"description": "Hooks to run after updating a record. Doc: https://manifest.build/docs/hooks#events",
"items": {
"$ref": "hook-schema.json"
}
},
"beforeDelete": {
"type": "array",
"description": "Hooks to run before deleting a record. Doc: https://manifest.build/docs/hooks#events",
"items": {
"$ref": "hook-schema.json"
}
},
"afterDelete": {
"type": "array",
"description": "Hooks to run after deleting a record. Doc: https://manifest.build/docs/hooks#events",
"items": {
"$ref": "hook-schema.json"
}
}
},
"additionalProperties": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"properties": {
"name": {
"type": "string",
"description": "The name of the relation"
"description": "The name of the relation."
},
"entity": {
"type": "string",
"description": "The class name of the entity that the relationship is with"
"description": "The class name of the entity that the relationship is with."
},
"eager": {
"type": "boolean",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/json-schema/src/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"type": "object",
"properties": {
"name": {
"description": "The name of your app",
"description": "The name of your app.",
"type": "string"
},
"version": {
"description": "The version of your app",
"description": "The version of your app.",
"type": "string"
},
"entities": {
Expand Down
2 changes: 2 additions & 0 deletions packages/core/manifest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"jsonwebtoken": "^9.0.2",
"livereload": "^0.9.3",
"mock-fs": "^5.4.1",
"node-fetch": "^3.3.2",
"nodemon": "^3.1.7",
"pluralize": "^8.0.0",
"reflect-metadata": "^0.2.1",
Expand All @@ -93,6 +94,7 @@
"@types/dasherize": "^2.0.3",
"@types/express": "^4.17.21",
"@types/js-yaml": "^4.0.9",
"@types/node-fetch": "^2.6.12",
"@types/pluralize": "^0.0.33",
"@types/supertest": "^6.0.2",
"@typescript-eslint/eslint-plugin": "^7.1.1",
Expand Down
4 changes: 3 additions & 1 deletion packages/core/manifest/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { ValidationModule } from './validation/validation.module'
import { UploadModule } from './upload/upload.module'
import { StorageModule } from './storage/storage.module'
import { ManifestService } from './manifest/services/manifest.service'
import { HookModule } from './hook/hook.module';

@Module({
imports: [
Expand Down Expand Up @@ -58,7 +59,8 @@ import { ManifestService } from './manifest/services/manifest.service'
OpenApiModule,
ValidationModule,
UploadModule,
StorageModule
StorageModule,
HookModule
]
})
export class AppModule {
Expand Down
8 changes: 8 additions & 0 deletions packages/core/manifest/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ export const ADMIN_ENTITY_MANIFEST: EntityManifest = {
properties: AUTHENTICABLE_PROPS,
relationships: [],
belongsToMany: [],
hooks: {
beforeCreate: [],
afterCreate: [],
beforeUpdate: [],
afterUpdate: [],
beforeDelete: [],
afterDelete: []
},
policies: {
create: [{ access: 'admin' }],
read: [{ access: 'admin' }],
Expand Down
Loading

0 comments on commit 5f1f1d7

Please sign in to comment.