Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/run_typescript.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (p *Preparer) BuildTypeScriptProgram(ctx context.Context) (sdkbuild.Program
DirName: p.config.DirName,
Version: version,
TSConfigPaths: map[string][]string{
"@temporalio/harness": {"./tslib/harness/ts/harness.js", "../harness/ts/harness.ts"},
"@temporalio/harness": {"./tslib/harness/ts/harness.js", "./harness/ts/harness.ts"},
},
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion features/data_converter/binary/feature.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as assert from 'assert';
import { JSONToPayload } from '@temporalio/common/lib/proto-utils';
import { JSONToPayload } from '@temporalio/common/proto-utils';
import { Feature } from '@temporalio/harness';
import expectedPayload from './payload.json';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as proto from '@temporalio/proto';
import {
DefaultPayloadConverterWithProtobufsOptions,
ProtobufBinaryPayloadConverter,
} from '@temporalio/common/lib/protobufs';
} from '@temporalio/common/protobufs';

import { CompositePayloadConverter } from '@temporalio/common';

Expand Down
2 changes: 1 addition & 1 deletion features/data_converter/codec/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as assert from 'assert';
import { Feature } from '@temporalio/harness';
import { METADATA_ENCODING_KEY, Payload, PayloadCodec, ValueError } from '@temporalio/common';
import * as proto from '@temporalio/proto';
import { decode, encode } from '@temporalio/common/lib/encoding';
import { decode, encode } from '@temporalio/common/encoding';

const toBase64 = (inArray: Uint8Array): Uint8Array => {
const buf = Buffer.from(inArray);
Expand Down
2 changes: 1 addition & 1 deletion features/data_converter/empty/feature.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as assert from 'assert';
import { JSONToPayload } from '@temporalio/common/lib/proto-utils';
import { JSONToPayload } from '@temporalio/common/proto-utils';
import { Feature } from '@temporalio/harness';
import { ApplicationFailure } from '@temporalio/common';
import * as wf from '@temporalio/workflow';
Expand Down
4 changes: 2 additions & 2 deletions features/data_converter/json_protobuf/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import * as assert from 'assert';
import * as protojson from 'protobufjs/ext/protojson';
import { Feature } from '@temporalio/harness';
import * as proto from '@temporalio/proto';
import { patchProtobufRoot } from '@temporalio/proto/lib/patch-protobuf-root';
import { decode } from '@temporalio/common/lib/encoding';
import { patchProtobufRoot } from '@temporalio/common/protobufs';
import { decode } from '@temporalio/common/encoding';

// Cast to `any` because the generated proto module types are missing the `lookupType` method
const patched = patchProtobufRoot(proto) as any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as proto from '@temporalio/proto';
import {
DefaultPayloadConverterWithProtobufsOptions,
ProtobufJsonPayloadConverter,
} from '@temporalio/common/lib/protobufs';
} from '@temporalio/common/protobufs';

import { CompositePayloadConverter } from '@temporalio/common';

Expand Down
2 changes: 1 addition & 1 deletion features/serialization_context/sercontext/sercontext.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Payload, PayloadCodec, SerializationContext } from '@temporalio/common';
import { decode, encode } from '@temporalio/common/lib/encoding';
import { decode, encode } from '@temporalio/common/encoding';

export const METADATA_KEY = 'ctx-signature';
export const NO_CONTEXT = 'none';
Expand Down
2 changes: 1 addition & 1 deletion harness/ts/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as path from 'path';
import * as fs from 'fs';
import { Command } from 'commander';
import { Runtime, DefaultLogger } from '@temporalio/worker';
import pkg from '@temporalio/worker/lib/pkg';
import pkg from '@temporalio/worker/internal/pkg';
import { TLSConfig } from '@temporalio/client';
import { FeatureSource, Runner } from './harness';

Expand Down
39 changes: 19 additions & 20 deletions sdkbuild/typescript.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sdkbuild

import (
"context"
"encoding/json"
"fmt"
"os"
"os/exec"
Expand Down Expand Up @@ -163,21 +164,24 @@ func BuildTypeScriptProgram(ctx context.Context, options BuildTypeScriptProgramO
}

// Create tsconfig
var tsConfigPathStr string
// Compile sources inside the prepared project so package resolution can find
// its node_modules and honor package exports/typesVersions. A wildcard paths
// mapping to node_modules only resolves physical files, not package subpaths.
for _, sourceDir := range []string{"features", "harness/ts"} {
if err := os.CopyFS(filepath.Join(dir, sourceDir), os.DirFS(filepath.Join(options.BaseDir, sourceDir))); err != nil {
return nil, fmt.Errorf("failed copying TypeScript sources from %s: %w", sourceDir, err)
}
}
for name, paths := range options.TSConfigPaths {
if len(paths) == 0 {
return nil, fmt.Errorf("harness path slice is empty")
return nil, fmt.Errorf("tsconfig path slice for %s is empty", name)
}
tsConfigPathStr += fmt.Sprintf("%q: [", name)
for i, path := range paths {
if i > 0 {
tsConfigPathStr += ", "
}
tsConfigPathStr += strconv.Quote(path)
}
tsConfigPathStr += "],\n "
}
includes := []string{"../features/**/*.ts", "../harness/ts/**/*.ts"}
tsConfigPaths, err := json.Marshal(options.TSConfigPaths)
if err != nil {
return nil, fmt.Errorf("failed encoding tsconfig paths: %w", err)
}
includes := []string{"features/**/*.ts", "harness/ts/**/*.ts"}
if len(options.Includes) > 0 {
includes = options.Includes
}
Expand All @@ -186,10 +190,8 @@ func BuildTypeScriptProgram(ctx context.Context, options BuildTypeScriptProgramO
// are versioned independently of the SDK under test. They are type-checked by
// the root tsconfig.json in the `build-typescript` CI job instead.
excludes := []string{
"../node_modules",
"../harness/go",
"../harness/java",
Comment on lines -190 to -191

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to exclude these if they're outside the project root

"../features/snippets/external_storage",
"node_modules",
"features/snippets/external_storage",
}
if len(options.Excludes) > 0 {
excludes = options.Excludes
Expand All @@ -208,11 +210,8 @@ func BuildTypeScriptProgram(ctx context.Context, options BuildTypeScriptProgramO
"compilerOptions": {
"baseUrl": ".",
"outDir": "./tslib",
"rootDirs": ["../", "."],
"paths": {
` + tsConfigPathStr + `
"*": ["node_modules/*", "node_modules/@types/*"]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was how a all of the lib paths worked previously

},
"rootDir": ".",
"paths": ` + string(tsConfigPaths) + `,
"typeRoots": ["node_modules/@types"],
"module": "commonjs",
"moduleResolution": "node",
Expand Down
Loading