@dbos-inc/create 1.20.4-preview → 1.20.7-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.
- package/dist/cli.js +11 -19
- package/dist/cli.js.map +1 -1
- package/package.json +2 -3
- package/templates/hello/README.md +1 -1
- package/templates/hello/src/operations.ts +7 -7
- package/templates/hello-drizzle/README.md +1 -1
- package/templates/hello-drizzle/drizzle/0000_hello.sql +2 -2
- package/templates/hello-drizzle/drizzle/meta/0000_snapshot.json +9 -10
- package/templates/hello-drizzle/drizzle/meta/_journal.json +2 -2
- package/templates/hello-drizzle/src/operations.test.ts +4 -4
- package/templates/hello-drizzle/src/operations.ts +14 -22
- package/templates/hello-drizzle/src/schema.ts +4 -4
- package/templates/hello-prisma/src/operations.ts +6 -6
- package/templates/hello-typeorm/src/operations.ts +6 -6
package/dist/cli.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Command } from 'commander';
|
|
|
3
3
|
import { init } from './init.js';
|
|
4
4
|
import fs from 'fs';
|
|
5
5
|
import path from "path";
|
|
6
|
-
import
|
|
6
|
+
import { input } from "@inquirer/prompts";
|
|
7
7
|
const program = new Command();
|
|
8
8
|
////////////////////////
|
|
9
9
|
/* LOCAL DEVELOPMENT */
|
|
@@ -26,24 +26,16 @@ program
|
|
|
26
26
|
template = template || 'hello';
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
name: 'appName',
|
|
40
|
-
message: 'What is the application/directory name to create?',
|
|
41
|
-
// Providing a default value
|
|
42
|
-
default: 'dbos-hello-app',
|
|
43
|
-
},
|
|
44
|
-
]);
|
|
45
|
-
appName = res.appName;
|
|
46
|
-
template = res.template;
|
|
29
|
+
appName = await input({
|
|
30
|
+
message: 'What is the template to use for the application?',
|
|
31
|
+
// Providing a default value
|
|
32
|
+
default: 'hello',
|
|
33
|
+
});
|
|
34
|
+
template = await input({
|
|
35
|
+
message: 'What is the application/directory name to create?',
|
|
36
|
+
// Providing a default value
|
|
37
|
+
default: 'dbos-hello-app',
|
|
38
|
+
});
|
|
47
39
|
}
|
|
48
40
|
await init(appName, template);
|
|
49
41
|
})
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,wBAAwB;AACxB,wBAAwB;AACxB,wBAAwB;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/D,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAY,CAAC;AAClH,OAAO,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description": "Tool for performing project initialization from template",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
"create": "./dist/cli.js"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@types/inquirer": "^9.0.7",
|
|
22
21
|
"@types/node": "^20.6.3",
|
|
23
22
|
"@types/prompt-sync": "^4.2.3",
|
|
24
23
|
"@types/update-notifier": "^6.0.8",
|
|
@@ -26,11 +25,11 @@
|
|
|
26
25
|
"typescript": "^5.4.5"
|
|
27
26
|
},
|
|
28
27
|
"dependencies": {
|
|
28
|
+
"@inquirer/prompts": "^5.3.8",
|
|
29
29
|
"axios": "^1.6.7",
|
|
30
30
|
"chalk": "4.1.2",
|
|
31
31
|
"commander": "^12.0.0",
|
|
32
32
|
"fast-glob": "^3.3.2",
|
|
33
|
-
"inquirer": "^9.2.16",
|
|
34
33
|
"open": "^10.1.0",
|
|
35
34
|
"prompt-sync": "^4.2.0",
|
|
36
35
|
"update-notifier": "^7.0.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# DBOS Hello
|
|
2
2
|
|
|
3
|
-
This is a [DBOS app](https://docs.dbos.dev/) bootstrapped with `npx @dbos-inc/create
|
|
3
|
+
This is a [DBOS app](https://docs.dbos.dev/) bootstrapped with `npx @dbos-inc/create` and using [Knex](https://docs.dbos.dev/tutorials/using-knex).
|
|
4
4
|
|
|
5
5
|
## Getting Started
|
|
6
6
|
|
|
@@ -11,13 +11,13 @@ export class Hello {
|
|
|
11
11
|
|
|
12
12
|
@GetApi('/') // Serve a quick readme for the app
|
|
13
13
|
static async readme(_ctxt: HandlerContext) {
|
|
14
|
-
const readme =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
const readme = `<html><body><p>
|
|
15
|
+
Welcome to the DBOS Hello App!<br><br>
|
|
16
|
+
Visit the route /greeting/:name to be greeted!<br>' +
|
|
17
|
+
For example, visit <a href="/greeting/dbos">/greeting/dbos</a>.<br>
|
|
18
|
+
The counter increments with each page visit.<br>
|
|
19
|
+
If you visit a new name like <a href="/greeting/alice">/greeting/alice</a>, the counter starts at 1.
|
|
20
|
+
</p></body></html>`;
|
|
21
21
|
return Promise.resolve(readme);
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# DBOS Hello with Drizzle
|
|
2
2
|
|
|
3
|
-
This is a [DBOS app](https://docs.dbos.dev/) bootstrapped with `npx @dbos-inc/create
|
|
3
|
+
This is a [DBOS app](https://docs.dbos.dev/) bootstrapped with `npx @dbos-inc/create` and using [Drizzle](https://docs.dbos.dev/tutorials/using-drizzle).
|
|
4
4
|
|
|
5
5
|
## Getting Started
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "
|
|
2
|
+
"id": "78b956ed-8f92-4ee4-aa24-2afbd7e51647",
|
|
3
3
|
"prevId": "00000000-0000-0000-0000-000000000000",
|
|
4
4
|
"version": "7",
|
|
5
5
|
"dialect": "postgresql",
|
|
@@ -8,18 +8,17 @@
|
|
|
8
8
|
"name": "dbos_hello",
|
|
9
9
|
"schema": "",
|
|
10
10
|
"columns": {
|
|
11
|
-
"
|
|
12
|
-
"name": "
|
|
13
|
-
"type": "
|
|
11
|
+
"greet_count": {
|
|
12
|
+
"name": "greet_count",
|
|
13
|
+
"type": "serial",
|
|
14
14
|
"primaryKey": true,
|
|
15
15
|
"notNull": true
|
|
16
16
|
},
|
|
17
|
-
"
|
|
18
|
-
"name": "
|
|
19
|
-
"type": "
|
|
17
|
+
"greeting": {
|
|
18
|
+
"name": "greeting",
|
|
19
|
+
"type": "text",
|
|
20
20
|
"primaryKey": false,
|
|
21
|
-
"notNull": false
|
|
22
|
-
"default": 0
|
|
21
|
+
"notNull": false
|
|
23
22
|
}
|
|
24
23
|
},
|
|
25
24
|
"indexes": {},
|
|
@@ -36,4 +35,4 @@
|
|
|
36
35
|
"schemas": {},
|
|
37
36
|
"tables": {}
|
|
38
37
|
}
|
|
39
|
-
}
|
|
38
|
+
}
|
|
@@ -18,11 +18,11 @@ describe("operations-test", () => {
|
|
|
18
18
|
*/
|
|
19
19
|
test("test-transaction", async () => {
|
|
20
20
|
const res = await testRuntime.invoke(Hello).helloTransaction("dbos");
|
|
21
|
-
expect(res).toMatch("Hello, dbos!
|
|
21
|
+
expect(res).toMatch("Hello, dbos! We have made");
|
|
22
22
|
|
|
23
23
|
// Check the greet count.
|
|
24
|
-
const rows = await testRuntime.queryUserDB("SELECT * FROM dbos_hello WHERE
|
|
25
|
-
expect(rows
|
|
24
|
+
const rows = await testRuntime.queryUserDB("SELECT * FROM dbos_hello WHERE greet_count=1");
|
|
25
|
+
expect(rows.length).toEqual(1);
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
/**
|
|
@@ -33,6 +33,6 @@ describe("operations-test", () => {
|
|
|
33
33
|
"/greeting/dbos"
|
|
34
34
|
);
|
|
35
35
|
expect(res.statusCode).toBe(200);
|
|
36
|
-
expect(res.text).toMatch("Hello, dbos!
|
|
36
|
+
expect(res.text).toMatch("Hello, dbos! We have made");
|
|
37
37
|
});
|
|
38
38
|
});
|
|
@@ -1,33 +1,25 @@
|
|
|
1
|
-
import { HandlerContext, TransactionContext, Transaction, GetApi
|
|
2
|
-
import {
|
|
3
|
-
import { sql } from 'drizzle-orm';
|
|
1
|
+
import { HandlerContext, TransactionContext, Transaction, GetApi } from '@dbos-inc/dbos-sdk';
|
|
2
|
+
import { dbosHello } from './schema';
|
|
4
3
|
import { NodePgDatabase } from 'drizzle-orm/node-postgres';
|
|
5
4
|
|
|
6
5
|
export class Hello {
|
|
7
6
|
|
|
8
7
|
@GetApi('/') // Serve a quick readme for the app
|
|
9
8
|
static async readme(_ctxt: HandlerContext) {
|
|
10
|
-
const readme =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
'</p></body></html>';
|
|
9
|
+
const readme = `<html><body><p>
|
|
10
|
+
Welcome to the DBOS Hello App!<br><br>
|
|
11
|
+
Visit the route /greeting/:name to be greeted!<br>
|
|
12
|
+
For example, visit <a href="/greeting/dbos">/greeting/dbos</a>.<br>
|
|
13
|
+
The counter increments with each page visit.<br>
|
|
14
|
+
</p></body></html>`;
|
|
17
15
|
return Promise.resolve(readme);
|
|
18
16
|
}
|
|
19
17
|
|
|
20
|
-
@GetApi('/greeting/:user')
|
|
21
|
-
@Transaction()
|
|
22
|
-
static async helloTransaction(ctxt: TransactionContext<NodePgDatabase>,
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
ON CONFLICT (name) DO UPDATE
|
|
27
|
-
SET greet_count = ${DBOSHello.greet_count} + 1
|
|
28
|
-
RETURNING greet_count
|
|
29
|
-
`);
|
|
30
|
-
const greet_count = output.rows[0].greet_count as number;
|
|
31
|
-
return `Hello, ${user}! You have been greeted ${greet_count} times.\n`;
|
|
18
|
+
@GetApi('/greeting/:user')
|
|
19
|
+
@Transaction()
|
|
20
|
+
static async helloTransaction(ctxt: TransactionContext<NodePgDatabase>, user: string) {
|
|
21
|
+
const greeting = `Hello, ${user}!`;
|
|
22
|
+
const greetings_output = await ctxt.client.insert(dbosHello).values({greeting}).returning({greet_count: dbosHello.greet_count});
|
|
23
|
+
return `${greeting} We have made ${greetings_output[0].greet_count} greetings.\n`;
|
|
32
24
|
}
|
|
33
25
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { serial } from "drizzle-orm/pg-core";
|
|
2
2
|
import { pgTable, text } from "drizzle-orm/pg-core";
|
|
3
3
|
|
|
4
|
-
export const
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export const dbosHello = pgTable('dbos_hello', {
|
|
5
|
+
greet_count: serial('greet_count').primaryKey(),
|
|
6
|
+
greeting: text('greeting'),
|
|
7
7
|
});
|
|
@@ -5,12 +5,12 @@ export class Hello {
|
|
|
5
5
|
|
|
6
6
|
@GetApi('/') // Serve a quick readme for the app
|
|
7
7
|
static async readme(_ctxt: HandlerContext) {
|
|
8
|
-
const readme =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const readme = `<html><body><p>
|
|
9
|
+
Welcome to the DBOS Hello App!<br><br>
|
|
10
|
+
Visit the route /greeting/:name to be greeted!<br>
|
|
11
|
+
For example, visit <a href="/greeting/dbos">/greeting/dbos</a>.<br>
|
|
12
|
+
The counter increments with each page visit.<br>
|
|
13
|
+
</p></body></html>`;
|
|
14
14
|
return Promise.resolve(readme);
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -7,12 +7,12 @@ export class Hello {
|
|
|
7
7
|
|
|
8
8
|
@GetApi('/') // Serve a quick readme for the app
|
|
9
9
|
static async readme(_ctxt: HandlerContext) {
|
|
10
|
-
const readme =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
const readme = `<html><body><p>
|
|
11
|
+
Welcome to the DBOS Hello App!<br><br>
|
|
12
|
+
Visit the route /greeting/:name to be greeted!<br>
|
|
13
|
+
For example, visit <a href="/greeting/dbos">/greeting/dbos</a>.<br>
|
|
14
|
+
The counter increments with each page visit.<br>
|
|
15
|
+
</p></body></html>`;
|
|
16
16
|
return Promise.resolve(readme);
|
|
17
17
|
}
|
|
18
18
|
|