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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dbos-inc/dbos-sdk",
3
- "version": "1.2.12",
3
+ "version": "1.3.5-preview",
4
4
  "description": "A Typescript framework built on the database",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -19,8 +19,8 @@
19
19
  "lint": "eslint --fix --ext .ts --ignore-pattern foundationdb/ --ignore-pattern templates/ .",
20
20
  "lint-fdb": "eslint --fix --ext .ts --ignore-pattern templates/ .",
21
21
  "setversion": "npm run --workspaces setversion && grunt setversion",
22
- "test": "npm run --workspaces test && npx prisma generate --schema tests/prisma/schema.prisma && npm run build && jest --coverage --collectCoverageFrom='src/**/*' --collectCoverageFrom='!src/foundationdb/**/*' --detectOpenHandles --testPathIgnorePatterns=examples/* --testPathIgnorePatterns=packages/* --testPathIgnorePatterns=tests/foundationdb/*",
23
- "test-fdb": "npm run --workspaces test && npx prisma generate --schema tests/prisma/schema.prisma && npm run build-fdb && jest --runInBand --coverage"
22
+ "test": "npm run build && npm run --workspaces test && npx prisma generate --schema tests/prisma/schema.prisma && jest --coverage --collectCoverageFrom='src/**/*' --collectCoverageFrom='!src/foundationdb/**/*' --detectOpenHandles --testPathIgnorePatterns=examples/* --testPathIgnorePatterns=packages/* --testPathIgnorePatterns=tests/foundationdb/*",
23
+ "test-fdb": "npm run build-fdb && npm run --workspaces test && npx prisma generate --schema tests/prisma/schema.prisma && jest --runInBand --coverage"
24
24
  },
25
25
  "bin": {
26
26
  "dbos": "./dist/src/dbos-runtime/cli.js",
@@ -65,6 +65,7 @@
65
65
  "axios": "1.6.7",
66
66
  "commander": "12.0.0",
67
67
  "fast-glob": "3.3.2",
68
+ "kafkajs": "^2.2.4",
68
69
  "knex": "3.1.0",
69
70
  "koa": "2.15.0",
70
71
  "lodash": "4.17.21",
@@ -1,7 +0,0 @@
1
- interface CopyOption {
2
- rename?: (basename: string) => string;
3
- }
4
- export declare const copy: (src: string, targets: string[], dest: string, { rename }?: CopyOption) => Promise<void[]>;
5
- export declare function init(appName: string): Promise<void>;
6
- export {};
7
- //# sourceMappingURL=init.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/dbos-runtime/init.ts"],"names":[],"mappings":"AAOA,UAAU,UAAU;IAClB,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAA;CACtC;AAID,eAAO,MAAM,IAAI,QACV,MAAM,WACF,MAAM,EAAE,QACX,MAAM,eACW,UAAU,oBA6BlC,CAAA;AASD,wBAAsB,IAAI,CAAC,OAAO,EAAE,MAAM,iBAuBzC"}
@@ -1,87 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.init = exports.copy = void 0;
30
- const fast_glob_1 = require("fast-glob");
31
- const path_1 = __importDefault(require("path"));
32
- const fs_1 = __importDefault(require("fs"));
33
- const child_process_1 = require("child_process");
34
- const error_1 = require("../error");
35
- const validator = __importStar(require("validator"));
36
- const identity = (x) => x;
37
- const copy = async (src, targets, dest, { rename = identity } = {}) => {
38
- if (targets.length === 0 || !dest) {
39
- throw new TypeError('`src` and `dest` are required');
40
- }
41
- const sourceFiles = await (0, fast_glob_1.async)(targets, {
42
- cwd: src,
43
- dot: true,
44
- absolute: false,
45
- stats: false,
46
- ignore: ['**/node_modules/**', '**/dist/**']
47
- });
48
- return Promise.all(sourceFiles.map(async (p) => {
49
- const dirname = path_1.default.dirname(p);
50
- const basename = rename(path_1.default.basename(p));
51
- const from = path_1.default.resolve(src, p);
52
- const to = path_1.default.join(dest, dirname, basename);
53
- // Ensure the destination directory exists
54
- await fs_1.default.promises.mkdir(path_1.default.dirname(to), { recursive: true });
55
- return fs_1.default.promises.copyFile(from, to);
56
- }));
57
- };
58
- exports.copy = copy;
59
- function isValidApplicationName(appName) {
60
- if (appName.length < 3 || appName.length > 30) {
61
- return false;
62
- }
63
- return validator.matches(appName, "^[a-z0-9-_]+$");
64
- }
65
- async function init(appName) {
66
- console.log("NOTE: This command is deprecated in favor of `npm create @dbos-inc` or `npx @dbos-inc/create`");
67
- if (!isValidApplicationName(appName)) {
68
- throw new error_1.DBOSError(`Invalid application name: ${appName}. Application name must be between 3 and 30 characters long and can only contain lowercase letters, numbers, hyphens and underscores. Exiting...`);
69
- }
70
- if (fs_1.default.existsSync(appName)) {
71
- throw new error_1.DBOSError(`Directory ${appName} already exists, exiting...`);
72
- }
73
- const templatePath = path_1.default.resolve(__dirname, '..', '..', '..', 'examples', 'hello');
74
- const targets = ["**"];
75
- await (0, exports.copy)(templatePath, targets, appName);
76
- const packageJsonName = path_1.default.resolve(appName, 'package.json');
77
- const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonName, 'utf-8'));
78
- packageJson.name = appName;
79
- fs_1.default.writeFileSync(packageJsonName, JSON.stringify(packageJson, null, 2), 'utf-8');
80
- (0, child_process_1.execSync)("npm ci --no-fund", { cwd: appName, stdio: 'inherit' });
81
- (0, child_process_1.execSync)("npm uninstall --no-fund @dbos-inc/dbos-sdk", { cwd: appName, stdio: 'inherit' });
82
- (0, child_process_1.execSync)("npm install --no-fund --save @dbos-inc/dbos-sdk@latest", { cwd: appName, stdio: 'inherit' });
83
- (0, child_process_1.execSync)("npm install --no-fund --save-dev @dbos-inc/dbos-cloud@latest", { cwd: appName, stdio: 'inherit' });
84
- console.log("Application initialized successfully!");
85
- }
86
- exports.init = init;
87
- //# sourceMappingURL=init.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/dbos-runtime/init.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAyC;AACzC,gDAAuB;AACvB,4CAAmB;AACnB,iDAAwC;AACxC,oCAAoC;AACpC,qDAAuC;AAMvC,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAA;AAE1B,MAAM,IAAI,GAAG,KAAK,EACvB,GAAW,EACX,OAAiB,EACjB,IAAY,EACZ,EAAE,MAAM,GAAG,QAAQ,KAAiB,EAAE,EACtC,EAAE;IAEF,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAClC,MAAM,IAAI,SAAS,C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,EAAE,KAAK,EAAE,SAAS,EAAC,CAAC,CAAA;IACpG,IAAA,wBAAQ,EAAC,8DAA8D,EAAE,EAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAC,CAAC,CAAA;IAC1G,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAA;AACtD,CAAC;AAvBD,oBAuBC"}
@@ -1,4 +0,0 @@
1
- dist
2
- *.test.ts
3
- jest.config.js
4
-
@@ -1,19 +0,0 @@
1
- {
2
- "root": true,
3
- "extends": [
4
- "plugin:@dbos-inc/dbosRecommendedConfig"
5
- ],
6
- "plugins": [
7
- "@dbos-inc"
8
- ],
9
- "env": {
10
- "node": true,
11
- "es6": true
12
- },
13
- "rules": {
14
- },
15
- "parser": "@typescript-eslint/parser",
16
- "parserOptions": {
17
- "project": "./tsconfig.json"
18
- }
19
- }
@@ -1,7 +0,0 @@
1
- {
2
- // See http://go.microsoft.com/fwlink/?LinkId=827846
3
- // for the documentation about the extensions.json format
4
- "recommendations": [
5
- "dbos-inc.dbos-ttdbg"
6
- ]
7
- }
@@ -1,22 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "type": "node-terminal",
9
- "request": "launch",
10
- "name": "Local Debug",
11
- "command": "npx dbos-sdk start",
12
- "preLaunchTask": "npm: build",
13
- },
14
- {
15
- "type": "node-terminal",
16
- "request": "launch",
17
- "name": "Time Travel Debug",
18
- "command": "npx dbos-sdk debug -x ${command:dbos-ttdbg.get-proxy-url} -u ${command:dbos-ttdbg.pick-workflow-id}",
19
- "preLaunchTask": "npm: build"
20
- }
21
- ]
22
- }
@@ -1,17 +0,0 @@
1
- {
2
- "version": "2.0.0",
3
- "tasks": [
4
- {
5
- "label": "npm: build",
6
- "type": "npm",
7
- "script": "build",
8
- "group": {
9
- "kind": "build",
10
- "isDefault": true
11
- },
12
- "problemMatcher": [
13
- "$tsc"
14
- ]
15
- }
16
- ]
17
- }
@@ -1,50 +0,0 @@
1
- # DBOS Hello
2
-
3
- This is a [DBOS app](https://docs.dbos.dev/) bootstrapped with `npx @dbos-inc/dbos-sdk init`.
4
-
5
- ## Getting Started
6
-
7
- Before you can launch your app, you need a database.
8
- DBOS works with any Postgres database, but to make things easier, we've provided a script that starts a Docker Postgres container and creates a database.
9
- On Linux or Mac, run:
10
-
11
- ```bash
12
- export PGPASSWORD=dbos
13
- ./start_postgres_docker.sh
14
- ```
15
-
16
- On Windows (cmd), run:
17
-
18
- ```cmd
19
- set PGPASSWORD=dbos
20
- start_postgres_docker.bat
21
- ```
22
-
23
- If successful, the script should print `Database started successfully!`.
24
-
25
- Then, let's run a schema migration to create some tables:
26
-
27
- ```bash
28
- npx dbos-sdk migrate
29
- ```
30
-
31
- If successful, the migration should print `Migration successful!`.
32
-
33
- Next, build and run the app:
34
-
35
- ```bash
36
- npm run build
37
- npx dbos-sdk start
38
- ```
39
-
40
- To see that it's working, visit this URL in your browser: [`http://localhost:3000/greeting/dbos`](http://localhost:3000/greeting/dbos).
41
- You should get this message: `Hello, dbos! You have been greeted 1 times.`
42
- Each time you refresh the page, the counter should go up by one!
43
-
44
- Congratulations! You just launched a DBOS application.
45
-
46
- ## Next Steps
47
-
48
- - To add more functionality to this application, modify `src/operations.ts`, then re-build and re-start it. For a detailed tutorial, check out our [programming quickstart](https://docs.dbos.dev/getting-started/quickstart-programming).
49
- - To learn how to deploy your application to DBOS Cloud, visit our [cloud quickstart](https://docs.dbos.dev/getting-started/quickstart-cloud/)
50
- - To learn more about DBOS, take a look at [our documentation](https://docs.dbos.dev/) or our [source code](https://github.com/dbos-inc/dbos-sdk).
@@ -1,15 +0,0 @@
1
- # To enable auto-completion and validation for this file in VSCode, install the RedHat YAML extension
2
- # https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml
3
-
4
- # yaml-language-server: $schema=https://raw.githubusercontent.com/dbos-inc/dbos-sdk/main/dbos-config.schema.json
5
-
6
- database:
7
- hostname: 'localhost'
8
- port: 5432
9
- username: 'postgres'
10
- password: ${PGPASSWORD}
11
- app_db_name: 'hello'
12
- connectionTimeoutMillis: 3000
13
- app_db_client: 'knex'
14
- migrate: ['npx knex migrate:latest']
15
- rollback: ['npx knex migrate:rollback']
@@ -1,8 +0,0 @@
1
- /** @type {import('ts-jest').JestConfigWithTsJest} */
2
- module.exports = {
3
- preset: 'ts-jest',
4
- testEnvironment: 'node',
5
- testRegex: '((\\.|/)(test|spec))\\.ts?$',
6
- moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
7
- modulePaths: ["./"],
8
- };
@@ -1,20 +0,0 @@
1
- const { parseConfigFile } = require('@dbos-inc/dbos-sdk/dist/src/dbos-runtime/config');
2
- const { DBOSConfig } = require('@dbos-inc/dbos-sdk/dist/src/dbos-executor');
3
-
4
- const [dbosConfig, ] = parseConfigFile();
5
-
6
- const config = {
7
- client: 'pg',
8
- connection: {
9
- host: dbosConfig.poolConfig.host,
10
- user: dbosConfig.poolConfig.user,
11
- password: dbosConfig.poolConfig.password,
12
- database: dbosConfig.poolConfig.database,
13
- ssl: dbosConfig.poolConfig.ssl,
14
- },
15
- migrations: {
16
- directory: './migrations'
17
- }
18
- };
19
-
20
- module.exports = config;
@@ -1,18 +0,0 @@
1
- const { Knex } = require("knex");
2
-
3
- exports.up = async function(knex) {
4
- await knex.schema.createTable('dbos_hello', table => {
5
- table.text('name').primary();
6
- table.integer('greet_count').defaultTo(0);
7
- });
8
-
9
- return knex.schema.createTable('dbos_greetings', table => {
10
- table.text('greeting_name');
11
- table.text('greeting_note_content');
12
- });
13
- };
14
-
15
- exports.down = async function(knex) {
16
- await knex.schema.dropTable('dbos_greetings');
17
- return knex.schema.dropTable('dbos_hello');
18
- };