@dbos-inc/dbos-sdk 1.2.12 → 1.3.5-preview

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. package/dist/src/dbos-runtime/cli.d.ts.map +1 -1
  2. package/dist/src/dbos-runtime/cli.js +2 -3
  3. package/dist/src/dbos-runtime/cli.js.map +1 -1
  4. package/dist/src/dbos-runtime/runtime.d.ts +1 -0
  5. package/dist/src/dbos-runtime/runtime.d.ts.map +1 -1
  6. package/dist/src/dbos-runtime/runtime.js +5 -0
  7. package/dist/src/dbos-runtime/runtime.js.map +1 -1
  8. package/dist/src/index.d.ts +1 -0
  9. package/dist/src/index.d.ts.map +1 -1
  10. package/dist/src/index.js +4 -1
  11. package/dist/src/index.js.map +1 -1
  12. package/dist/src/kafka/kafka.d.ts +30 -0
  13. package/dist/src/kafka/kafka.d.ts.map +1 -0
  14. package/dist/src/kafka/kafka.js +98 -0
  15. package/dist/src/kafka/kafka.js.map +1 -0
  16. package/dist/src/system_database.js +4 -4
  17. package/dist/src/system_database.js.map +1 -1
  18. package/dist/src/testing/testing_runtime.d.ts.map +1 -1
  19. package/dist/src/testing/testing_runtime.js +5 -0
  20. package/dist/src/testing/testing_runtime.js.map +1 -1
  21. package/dist/src/utils.d.ts +13 -0
  22. package/dist/src/utils.d.ts.map +1 -1
  23. package/dist/src/utils.js +24 -1
  24. package/dist/src/utils.js.map +1 -1
  25. package/dist/tsconfig.build.tsbuildinfo +1 -1
  26. package/package.json +4 -3
  27. package/dist/src/dbos-runtime/init.d.ts +0 -7
  28. package/dist/src/dbos-runtime/init.d.ts.map +0 -1
  29. package/dist/src/dbos-runtime/init.js +0 -87
  30. package/dist/src/dbos-runtime/init.js.map +0 -1
  31. package/examples/hello/.eslintignore +0 -4
  32. package/examples/hello/.eslintrc +0 -19
  33. package/examples/hello/.vscode/extensions.json +0 -7
  34. package/examples/hello/.vscode/launch.json +0 -22
  35. package/examples/hello/.vscode/tasks.json +0 -17
  36. package/examples/hello/README.md +0 -50
  37. package/examples/hello/dbos-config.yaml +0 -15
  38. package/examples/hello/jest.config.js +0 -8
  39. package/examples/hello/knexfile.js +0 -20
  40. package/examples/hello/migrations/20240212161006_create_dbos_hello_tables.js +0 -18
  41. package/examples/hello/package-lock.json +0 -5532
  42. package/examples/hello/package.json +0 -24
  43. package/examples/hello/src/operations.test.ts +0 -38
  44. package/examples/hello/src/operations.ts +0 -21
  45. package/examples/hello/start_postgres_docker.bat +0 -36
  46. package/examples/hello/start_postgres_docker.sh +0 -23
  47. package/examples/hello/tsconfig.json +0 -24
@@ -1,24 +0,0 @@
1
- {
2
- "name": "dbos-hello",
3
- "version": "0.0.1",
4
- "scripts": {
5
- "build": "tsc",
6
- "test": "npx knex migrate:rollback && npx knex migrate:up && jest",
7
- "lint": "eslint src",
8
- "lint-fix": "eslint --fix src"
9
- },
10
- "devDependencies": {
11
- "@dbos-inc/eslint-plugin": "^0.0.6",
12
- "@types/jest": "^29.5.5",
13
- "@types/supertest": "^2.0.14",
14
- "eslint": "^8.56.0",
15
- "jest": "^29.7.0",
16
- "supertest": "^6.3.3",
17
- "ts-jest": "^29.1.1",
18
- "typescript": "^5.2.2"
19
- },
20
- "dependencies": {
21
- "@dbos-inc/dbos-sdk": "../..",
22
- "knex": "3.1.0"
23
- }
24
- }
@@ -1,38 +0,0 @@
1
- import { TestingRuntime, createTestingRuntime } from "@dbos-inc/dbos-sdk";
2
- import { Hello, dbos_hello } from "./operations";
3
- import request from "supertest";
4
-
5
- describe("operations-test", () => {
6
- let testRuntime: TestingRuntime;
7
-
8
- beforeAll(async () => {
9
- testRuntime = await createTestingRuntime([Hello]);
10
- });
11
-
12
- afterAll(async () => {
13
- await testRuntime.destroy();
14
- });
15
-
16
- /**
17
- * Test the transaction.
18
- */
19
- test("test-transaction", async () => {
20
- const res = await testRuntime.invoke(Hello).helloTransaction("dbos");
21
- expect(res).toMatch("Hello, dbos! You have been greeted");
22
-
23
- // Check the greet count.
24
- const rows = await testRuntime.queryUserDB<dbos_hello>("SELECT * FROM dbos_hello WHERE name=$1", "dbos");
25
- expect(rows[0].greet_count).toBe(1);
26
- });
27
-
28
- /**
29
- * Test the HTTP endpoint.
30
- */
31
- test("test-endpoint", async () => {
32
- const res = await request(testRuntime.getHandlersCallback()).get(
33
- "/greeting/dbos"
34
- );
35
- expect(res.statusCode).toBe(200);
36
- expect(res.text).toMatch("Hello, dbos! You have been greeted");
37
- });
38
- });
@@ -1,21 +0,0 @@
1
- import { TransactionContext, Transaction, GetApi, ArgSource, ArgSources } from '@dbos-inc/dbos-sdk';
2
- import { Knex } from 'knex';
3
-
4
- // The schema of the database table used in this example.
5
- export interface dbos_hello {
6
- name: string;
7
- greet_count: number;
8
- }
9
-
10
- export class Hello {
11
-
12
- @GetApi('/greeting/:user') // Serve this function from HTTP GET requests to the /greeting endpoint with 'user' as a path parameter
13
- @Transaction() // Run this function as a database transaction
14
- static async helloTransaction(ctxt: TransactionContext<Knex>, @ArgSource(ArgSources.URL) user: string) {
15
- // Retrieve and increment the number of times this user has been greeted.
16
- const query = "INSERT INTO dbos_hello (name, greet_count) VALUES (?, 1) ON CONFLICT (name) DO UPDATE SET greet_count = dbos_hello.greet_count + 1 RETURNING greet_count;";
17
- const { rows } = await ctxt.client.raw(query, [user]) as { rows: dbos_hello[] };
18
- const greet_count = rows[0].greet_count;
19
- return `Hello, ${user}! You have been greeted ${greet_count} times.\n`;
20
- }
21
- }
@@ -1,36 +0,0 @@
1
- @echo off
2
-
3
- setlocal ENABLEEXTENSIONS
4
-
5
- echo Checking if PGPASSWORD is set.
6
- if "%PGPASSWORD%"=="" (
7
- echo Error: PGPASSWORD is not set.
8
- exit /b 1
9
- )
10
-
11
- echo Starting PostgreSQL in a local Docker container
12
- docker run --rm --name=dbos-db --env=POSTGRES_PASSWORD=%PGPASSWORD% --env=PGDATA=/var/lib/postgresql/data --volume=/var/lib/postgresql/data -p 5432:5432 -d postgres:16.1
13
-
14
- if %errorlevel% == 125 (
15
- echo Error: Check if the Docker container already exists
16
- exit /b 1
17
- ) else (
18
- goto :start
19
- )
20
-
21
- :start
22
- echo Waiting for PostgreSQL to start...
23
- for /l %%i in (1,1,30) do (
24
- docker exec dbos-db psql -U postgres -c "SELECT 1;" >NUL 2>&1
25
-
26
- if %errorlevel% equ 0 (
27
- (
28
- echo PostgreSQL started!
29
- goto :break
30
- )
31
- timeout /t 1 /nobreak
32
- )
33
- )
34
- :break
35
-
36
- echo Database started successfully^!
@@ -1,23 +0,0 @@
1
- #!/bin/bash
2
- set -e
3
-
4
- # Check if PGPASSWORD is set
5
- if [[ -z "${PGPASSWORD}" ]]; then
6
- echo "Error: PGPASSWORD is not set." >&2
7
- exit 1
8
- fi
9
-
10
- # Start Postgres in a local Docker container
11
- docker run --rm --name=dbos-db --env=POSTGRES_PASSWORD=${PGPASSWORD} --env=PGDATA=/var/lib/postgresql/data --volume=/var/lib/postgresql/data -p 5432:5432 -d postgres:16.1
12
-
13
- # Wait for PostgreSQL to start
14
- echo "Waiting for PostgreSQL to start..."
15
- for i in {1..30}; do
16
- if docker exec dbos-db psql -U postgres -c "SELECT 1;" > /dev/null 2>&1; then
17
- echo "PostgreSQL started!"
18
- break
19
- fi
20
- sleep 1
21
- done
22
-
23
- echo "Database started successfully!"
@@ -1,24 +0,0 @@
1
- /* Visit https://aka.ms/tsconfig to read more about this file */
2
- {
3
- "compilerOptions": {
4
- "target": "esnext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
5
- "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
6
- "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
7
- "module": "Node16", /* Specify what module code is generated. */
8
- "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
9
- "declarationMap": true, /* Create sourcemaps for d.ts files. */
10
- "sourceMap": true, /* Create source map files for emitted JavaScript files. */
11
- "outDir": "./dist", /* Specify an output folder for all emitted files. */
12
- "newLine": "lf", /* Set the newline character for emitting files. */
13
- "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
14
- "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
15
- "strict": true, /* Enable all strict type-checking options. */
16
- "skipLibCheck": true /* Skip type checking all .d.ts files. */
17
- },
18
- "include": [ /* Specifies an array of filenames or patterns to include in the program. */
19
- "src"
20
- ],
21
- "exclude": [
22
- "**/*.test.ts"
23
- ]
24
- }