@dbos-inc/create 1.2.9-preview → 1.2.11-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/init.js CHANGED
@@ -46,13 +46,13 @@ export async function init(appName, templateName) {
46
46
  }
47
47
  const targets = ["**"];
48
48
  await copy(templatePath, targets, appName);
49
+ fs.renameSync(path.resolve(appName, 'gitignore.template'), path.resolve(appName, '.gitignore'));
49
50
  const packageJsonName = path.resolve(appName, 'package.json');
50
51
  const packageJson = JSON.parse(fs.readFileSync(packageJsonName, 'utf-8'));
51
52
  packageJson.name = appName;
52
53
  fs.writeFileSync(packageJsonName, JSON.stringify(packageJson, null, 2), 'utf-8');
53
- execSync("npm ci --no-fund", { cwd: appName, stdio: 'inherit' });
54
- execSync("npm uninstall --no-fund @dbos-inc/dbos-sdk", { cwd: appName, stdio: 'inherit' });
55
54
  execSync("npm install --no-fund --save @dbos-inc/dbos-sdk@latest", { cwd: appName, stdio: 'inherit' });
55
+ execSync("npm ci --no-fund", { cwd: appName, stdio: 'inherit' });
56
56
  execSync("npm install --no-fund --save-dev @dbos-inc/dbos-cloud@latest", { cwd: appName, stdio: 'inherit' });
57
57
  console.log("Application initialized successfully!");
58
58
  }
package/dist/init.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../init.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAMpC,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAA;AAEjC,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,EACvB,GAA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KAAK,EAAE,SAAS,EAAC,CAAC,CAAA;IACpG,QAAQ,CAAC,kBAAkB,EAAE,EAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAC,CAAC,CAAA;IAC9D,QAAQ,CAAC,8DAA8D,EAAE,EAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAC,CAAC,CAAA;IAC1G,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAA;AACtD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dbos-inc/create",
3
- "version": "1.2.9-preview",
3
+ "version": "1.2.11-preview",
4
4
  "description": "Tool for performing project initialization from template",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -0,0 +1,144 @@
1
+ # DBOS-specific
2
+ .dbos
3
+
4
+ # Logs
5
+ **/.DS_Store
6
+ **/prisma/migrations/*
7
+
8
+ logs
9
+ *.log
10
+ npm-debug.log*
11
+ yarn-debug.log*
12
+ yarn-error.log*
13
+ lerna-debug.log*
14
+ .pnpm-debug.log*
15
+ dbos_deploy/
16
+
17
+ # Diagnostic reports (https://nodejs.org/api/report.html)
18
+ report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
19
+
20
+ # Runtime data
21
+ pids
22
+ *.pid
23
+ *.seed
24
+ *.pid.lock
25
+
26
+ # Directory for instrumented libs generated by jscoverage/JSCover
27
+ lib-cov
28
+
29
+ # Coverage directory used by tools like istanbul
30
+ coverage
31
+ *.lcov
32
+
33
+ # nyc test coverage
34
+ .nyc_output
35
+
36
+ # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
37
+ .grunt
38
+
39
+ # Bower dependency directory (https://bower.io/)
40
+ bower_components
41
+
42
+ # node-waf configuration
43
+ .lock-wscript
44
+
45
+ # Compiled binary addons (https://nodejs.org/api/addons.html)
46
+ build/Release
47
+
48
+ # Dependency directories
49
+ node_modules/
50
+ jspm_packages/
51
+
52
+ # Snowpack dependency directory (https://snowpack.dev/)
53
+ web_modules/
54
+
55
+ # TypeScript cache
56
+ *.tsbuildinfo
57
+
58
+ # Optional npm cache directory
59
+ .npm
60
+
61
+ # Optional eslint cache
62
+ .eslintcache
63
+
64
+ # Optional stylelint cache
65
+ .stylelintcache
66
+
67
+ # Microbundle cache
68
+ .rpt2_cache/
69
+ .rts2_cache_cjs/
70
+ .rts2_cache_es/
71
+ .rts2_cache_umd/
72
+
73
+ # Optional REPL history
74
+ .node_repl_history
75
+
76
+ # Output of 'npm pack'
77
+ *.tgz
78
+
79
+ # Yarn Integrity file
80
+ .yarn-integrity
81
+
82
+ # dotenv environment variable files
83
+ .env
84
+ .env.development.local
85
+ .env.test.local
86
+ .env.production.local
87
+ .env.local
88
+
89
+ # parcel-bundler cache (https://parceljs.org/)
90
+ .cache
91
+ .parcel-cache
92
+
93
+ # Next.js build output
94
+ .next
95
+ out
96
+
97
+ # Nuxt.js build / generate output
98
+ .nuxt
99
+ dist
100
+
101
+ # Gatsby files
102
+ .cache/
103
+ # Comment in the public line in if your project uses Gatsby and not Next.js
104
+ # https://nextjs.org/blog/next-9-1#public-directory-support
105
+ # public
106
+
107
+ # vuepress build output
108
+ .vuepress/dist
109
+
110
+ # vuepress v2.x temp and cache directory
111
+ .temp
112
+ .cache
113
+
114
+ # Docusaurus cache and generated files
115
+ .docusaurus
116
+
117
+ # Serverless directories
118
+ .serverless/
119
+
120
+ # FuseBox cache
121
+ .fusebox/
122
+
123
+ # DynamoDB Local files
124
+ .dynamodb/
125
+
126
+ # TernJS port file
127
+ .tern-port
128
+
129
+ # Stores VSCode versions used for testing VSCode extensions
130
+ .vscode-test
131
+
132
+ # VSCode settings
133
+ .vscode/settings.json
134
+
135
+ # yarn v2
136
+ .yarn/cache
137
+ .yarn/unplugged
138
+ .yarn/build-state.yml
139
+ .yarn/install-state.gz
140
+ .pnp.*
141
+
142
+ # Editor temp/recovery files
143
+ *.swp
144
+ *.swo
@@ -0,0 +1,38 @@
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
+ });
@@ -0,0 +1,21 @@
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
+ }
@@ -0,0 +1,24 @@
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
+ }