Skip to content

Commit 4cc6c87

Browse files
authored
Move from apex_core v0.1.3 to v0.1.5 (#50)
1 parent af12bf3 commit 4cc6c87

33 files changed

Lines changed: 125 additions & 60 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ bundle.js
99
!/testdata/*/actual/go.*
1010
!/testdata/*/actual/package.*
1111
!/testdata/*/actual/requirements.txt
12+
npm
File renamed without changes.

scripts/build_npm.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// ex. scripts/build_npm.ts
2+
import { build, emptyDir } from "https://deno.land/x/dnt@0.40.0/mod.ts";
3+
4+
await emptyDir("./npm");
5+
6+
await build({
7+
entryPoints: [
8+
"./src/cs/mod.ts",
9+
"./src/go/mod.ts",
10+
"./src/json-schema/mod.ts",
11+
"./src/markdown/mod.ts",
12+
"./src/openapiv3/mod.ts",
13+
"./src/proto/mod.ts",
14+
"./src/python/mod.ts",
15+
"./src/rest/mod.ts",
16+
"./src/rust/mod.ts",
17+
"./src/typescript/mod.ts",
18+
"./src/utils/mod.ts",
19+
],
20+
outDir: "./npm",
21+
test: false,
22+
shims: {
23+
// see JS docs for overview and more options
24+
deno: true,
25+
},
26+
package: {
27+
// package.json properties
28+
name: "@apexlang/core",
29+
version: Deno.args[0],
30+
description: "Apex language JavaScript support",
31+
keywords: ["apex", "idl", "codegen"],
32+
license: "Apache-2.0",
33+
repository: {
34+
type: "git",
35+
url: "https://www.github.com/apexlang/apex-js",
36+
},
37+
bugs: {
38+
url: "https://www.github.com/apexlang/apex-js/issues",
39+
},
40+
},
41+
postBuild() {
42+
// steps to run after building and before running the tests
43+
Deno.copyFileSync("LICENSE", "npm/LICENSE");
44+
Deno.copyFileSync("README.md", "npm/README.md");
45+
},
46+
});

src/cs/union_visitor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export class UnionVisitor extends BaseVisitor {
2323
const { union } = context;
2424
this.write(` ${formatComment("// ", union.description)}`);
2525
this.write(`public record ${union.name} {\n`);
26-
union.types.forEach((t) => {
27-
const typeName = expandType(t);
26+
union.members.forEach((member) => {
27+
const typeName = expandType(member.type);
2828
this.write(` public ${pascalCase(typeName)} ${typeName};`);
2929
this.triggerCallbacks(context, "UnionStructTags");
3030
this.write(`\n`);

src/deps/core/ast.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from "https://deno.land/x/apex_core@v0.1.3/ast/mod.ts";
1+
export * from "https://deno.land/x/apex_core@v0.1.5/ast/mod.ts";

src/deps/core/model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from "https://deno.land/x/apex_core@v0.1.3/model/mod.ts";
1+
export * from "https://deno.land/x/apex_core@v0.1.5/model/mod.ts";

src/go/grpc_visitor.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,8 @@ func New${iface.name}GRPCWrapper(service ${iface.name}) *${iface.name}GRPCWrappe
621621
}
622622
switch {\n`,
623623
);
624-
union.types.forEach((ut) => {
624+
union.members.forEach((member) => {
625+
const ut = member.type;
625626
this.write(`case from.${pascalCase(expandType(ut))} != nil:
626627
return &pb.${union.name}{\n`);
627628
switch (ut.kind) {
@@ -844,7 +845,8 @@ func New${iface.name}GRPCWrapper(service ${iface.name}) *${iface.name}GRPCWrappe
844845
}
845846
switch v := from.Value.(type) {\n`,
846847
);
847-
union.types.forEach((ut) => {
848+
union.members.forEach((member) => {
849+
const ut = member.type;
848850
if (ut.kind == Kind.Type) {
849851
const t = ut as Named;
850852
this.write(`case *pb.${union.name}_${pascalCase(expandType(ut))}Value:
@@ -919,7 +921,9 @@ func New${iface.name}GRPCWrapper(service ${iface.name}) *${iface.name}GRPCWrappe
919921
case Kind.Union: {
920922
const u = a as Union;
921923
m[u.name] = u;
922-
u.types.forEach((t) => this.checkType(context, t, m, types));
924+
u.members.forEach((member) =>
925+
this.checkType(context, member.type, m, types)
926+
);
923927
break;
924928
}
925929
case Kind.Alias: {

src/go/union_visitor.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,14 @@ export class UnionVisitor extends GoVisitor {
3030
const imports = getImports(context);
3131
this.write(formatComment("// ", union.description));
3232
this.write(`type ${union.name} struct {\n`);
33-
union.types.forEach((t) => {
34-
let tname = typeName(t);
35-
const annotated = t as Annotated;
36-
if (annotated.annotation) {
37-
annotated.annotation("unionKey", (a) => {
38-
tname = a.convert<UnionKey>().value;
39-
});
40-
}
33+
union.members.forEach((member) => {
34+
let tname = typeName(member.type);
35+
member.annotation("unionKey", (a) => {
36+
tname = a.convert<UnionKey>().value;
37+
});
4138

42-
imports.type(t);
43-
const expandedName = expandType(t);
39+
imports.type(member.type);
40+
const expandedName = expandType(member.type);
4441
this.write(
4542
`${
4643
fieldName(

src/json-schema/json-schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class UnionVisitor extends BaseVisitor {
167167
const { union } = context;
168168
const arr: SchemaObject[] = [];
169169
convertArrayToObject(
170-
union.types,
170+
union.members.map((m) => m.type),
171171
(t: AnyType) => {
172172
switch (t.kind) {
173173
case Kind.Union:

src/markdown/markdown-visitor.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ export class MarkdownVisitor extends BaseVisitor {
107107
visitUnion(context: Context): void {
108108
const u = context.union;
109109
this.writeDefinitionName(u.name);
110-
this.writeLn(`\`${u.name} = ${u.types.map(expandType).join(" | ")}\``);
110+
this.writeLn(
111+
`\`${u.name} = ${
112+
u.members.map((m) => m.type).map(expandType).join(" | ")
113+
}\``,
114+
);
111115
}
112116
}

0 commit comments

Comments
 (0)