Skip to content
Open
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
55 changes: 18 additions & 37 deletions 6-timer-ticket-creator/README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,28 @@
## Timer Ticket Creator Snap-in
# Timer ticket creator snap-in

Snap-in that creates a new ticket after every 10 minutes.
This example creates one ticket for every ten-minute timer tick. It was ported from the legacy TypeScript snap-in template to the local Effect runtime and typed-manifest packages in `vendor/snap-in-effect`.

### Testing locally
## Preserved behavior

You can test your code by adding test events under `src/fixtures` similar to the example event provided. You can add keyring values to the event payload to test API calls as well.
- The `timer-event-source` event source still runs on `*/10 * * * *` with `ten_minute_event` metadata.
- The `ticket_creator` function remains bound to `periodic_ticket_creator` for `timer.tick`.
- Each accepted event creates one ticket with a timestamped title and body.
- The ticket still uses `PROD-1` and `DEVU-1`.
- The service account remains `Automatic Ticket Creator Bot` with `self` scope only.

Once you have added the event, you can test your code by running:
A completed handler can be delivered again, which creates another ticket. This is intentionally unchanged from the original example: ticket creation has no idempotency key and the runtime does not retry the write inline.

```
npm install
npm run start -- --functionName=on_work_creation --fixturePath=on_work_created_event.json
```

### Adding external dependencies

You can also add dependencies on external packages in package.json under the “dependencies” key. These dependencies will be made available to your function at runtime and testing.

### Packaging the code
## Verify locally

Once you are done with the testing,
Run

```
npm install
npm run build
npm run package
```

and ensure it succeeds.

You will see a `build.tar.gz` file is created and you can provide it while creating the snap_in_version.

### Linting

To check for lint errors, run the following command:
The locally built runtime packages are checked in under `code/vendor/packages`:

```bash
npm run lint
cd 6-timer-ticket-creator/code
npm ci
npm run typecheck
npm test
npm run manifest
npm run build
```

To automatically fix fixable lint errors, run:

```bash
npm run lint:fix
```
`npm run demo` invokes the handler with an offline SDK transport and never sends a DevRev request. The generated `manifest.yaml` is the reviewed deployment manifest. This migration does not deploy, install, or activate the snap-in.
35 changes: 0 additions & 35 deletions 6-timer-ticket-creator/code/.eslintrc.js

This file was deleted.

4 changes: 0 additions & 4 deletions 6-timer-ticket-creator/code/.prettierignore

This file was deleted.

15 changes: 0 additions & 15 deletions 6-timer-ticket-creator/code/.prettierrc

This file was deleted.

3 changes: 0 additions & 3 deletions 6-timer-ticket-creator/code/babel.config.js

This file was deleted.

12 changes: 0 additions & 12 deletions 6-timer-ticket-creator/code/jest.config.js

This file was deleted.

41 changes: 41 additions & 0 deletions 6-timer-ticket-creator/code/manifest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Manifest } from "@devrev-internal/snap-in-manifest";
import { functionFactory } from "./src";

export default Manifest.defineManifest(functionFactory, {
version: "2",
name: "Timely Ticketer",
description: "Snap-in to create ticket every 10 minutes",
service_account: {
display_name: "Automatic Ticket Creator Bot",
scopes: { self: [] },
},
event_sources: {
organization: [
{
name: "timer-event-source",
description: "Event source that sends events every 10 minutes.",
display_name: "Timer Event Source",
type: "timer-events",
config: {
cron: "*/10 * * * *",
metadata: { event_key: "ten_minute_event" },
},
},
],
},
functions: [
{
name: "ticket_creator",
description: "Function to create a new ticket when triggered.",
},
],
automations: [
{
name: "periodic_ticket_creator",
description: "Automation to create a ticket every 10 minutes",
source: "timer-event-source",
event_types: ["timer.tick"],
function: "ticket_creator",
},
],
});
5 changes: 0 additions & 5 deletions 6-timer-ticket-creator/code/nodemon.json

This file was deleted.

Loading
Loading