@temporalio/create
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -88,4 +88,4 @@ #!/usr/bin/env node | ||
await copySample(path_1.default.join(sampleDir, 'activity.ts'), path_1.default.join(targetDir, 'activities.ts')); | ||
await copySample(path_1.default.join(sampleDir, 'workflow.ts'), path_1.default.join(targetDir, 'workflows', 'example.ts')); | ||
await copySample(path_1.default.join(sampleDir, 'interface.ts'), path_1.default.join(targetDir, 'interfaces', 'workflows.ts')); | ||
await copySample(path_1.default.join(sampleDir, 'workflow.ts'), path_1.default.join(targetDir, 'workflows', 'index.ts')); | ||
await copySample(path_1.default.join(sampleDir, 'interface.ts'), path_1.default.join(targetDir, 'interfaces.ts')); | ||
} | ||
@@ -110,3 +110,2 @@ } | ||
await (0, fs_extra_1.mkdir)(src); | ||
await (0, fs_extra_1.mkdir)(path_1.default.join(src, 'interfaces')); | ||
await (0, fs_extra_1.mkdir)(path_1.default.join(src, 'workflows')); | ||
@@ -113,0 +112,0 @@ await writePrettyJson(path_1.default.join(root, 'tsconfig.json'), tsConfig); |
{ | ||
"name": "@temporalio/create", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Create a Temporal project from template", | ||
@@ -29,3 +29,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "254e9f5793afc11cb5fb64a9829b1c55190092f0" | ||
"gitHead": "23da8507a90049774cc6ddd28a8ec3dfc37d345f" | ||
} |
// @@@SNIPSTART nodejs-mtls-client | ||
import fs from 'fs'; | ||
import { Connection, WorkflowClient } from '@temporalio/client'; | ||
import { Example } from './interfaces/workflows'; | ||
import { example } from './workflows'; | ||
import { getEnv, Env } from './mtls-env'; | ||
@@ -37,4 +37,4 @@ | ||
const client = new WorkflowClient(connection.service, { namespace }); | ||
// Create a typed client using the Example Workflow interface, | ||
const workflow = client.stub<Example>('example', { taskQueue }); | ||
// Create a typed handle for the example Workflow. | ||
const workflow = client.createWorkflowHandle(example, { taskQueue }); | ||
const result = await workflow.execute('Temporal'); | ||
@@ -41,0 +41,0 @@ console.log(result); // Hello, Temporal! |
// @@@SNIPSTART nodejs-hello-client | ||
import { Connection, WorkflowClient } from '@temporalio/client'; | ||
import { Example } from './interfaces/workflows'; | ||
import { example } from './workflows'; | ||
@@ -12,5 +12,5 @@ async function run() { | ||
const client = new WorkflowClient(connection.service); | ||
// Create a typed client using the Example Workflow interface, | ||
const example = client.stub<Example>('example', { taskQueue: 'tutorial' }); | ||
const result = await example.execute('Temporal'); | ||
// Create a typed handle for the example Workflow. | ||
const workflow = client.createWorkflowHandle(example, { taskQueue: 'tutorial' }); | ||
const result = await workflow.execute('Temporal'); | ||
console.log(result); // Hello, Temporal! | ||
@@ -17,0 +17,0 @@ } |
// @@@SNIPSTART nodejs-hello-workflow-interface | ||
import { Workflow } from '@temporalio/workflow'; | ||
// Extend the generic Workflow interface to check that Example is a valid workflow interface | ||
// Workflow interfaces are useful for generating type safe workflow clients | ||
export interface Example extends Workflow { | ||
main(name: string): Promise<string>; | ||
} | ||
// Define our Example Workflow type (this step is optional). | ||
// Workflow types are useful for generating type safe workflow clients | ||
// in environments where the Workflow implemetations are unavailable. | ||
export type Example = (name: string) => { | ||
execute(): Promise<string>; | ||
}; | ||
// @@@SNIPEND |
// @@@SNIPSTART nodejs-hello-workflow | ||
import { Context } from '@temporalio/workflow'; | ||
import { Example } from '../interfaces/workflows'; | ||
import * as activities from '../activities'; | ||
import { createActivityHandle } from '@temporalio/workflow'; | ||
import { Example } from '../interfaces'; | ||
// Only import the activity types | ||
import type * as activities from '../activities'; | ||
const { greet } = Context.configureActivities<typeof activities>({ | ||
type: 'remote', | ||
startToCloseTimeout: '30 minutes', | ||
const { greet } = createActivityHandle<typeof activities>({ | ||
startToCloseTimeout: '1 minute', | ||
}); | ||
// A workflow that simply calls an activity | ||
async function main(name: string): Promise<string> { | ||
return greet(name); | ||
} | ||
export const workflow = { main }; | ||
/** A workflow that simply calls an activity */ | ||
export const example: Example = (name: string) => { | ||
return { | ||
async execute(): Promise<string> { | ||
return await greet(name); | ||
}, | ||
}; | ||
}; | ||
// @@@SNIPEND |
Sorry, the diff of this file is not supported yet
395
22931