Skip to content

Commit f41a1e5

Browse files
author
Wes Biggs
committed
Syntax tweaks
1 parent 6efb02c commit f41a1e5

7 files changed

+25
-13
lines changed

dsnp/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ApiPromise } from "@polkadot/api";
22

3-
import { Schema } from "avsc";
3+
import type { Schema } from "avsc";
44
import { DSNPParquetSchema } from "@dsnp/schemas/types/dsnp-parquet.js";
55
import {
66
AnnouncementType,
@@ -137,7 +137,7 @@ export const schemas = new Map<SchemaName, Deploy>([
137137
[
138138
"public-key-key-agreement",
139139
{
140-
model: publicKey as Schema,
140+
model: publicKey,
141141
modelType: "AvroBinary",
142142
payloadLocation: "Itemized",
143143
settings: ["AppendOnly", "SignatureRequired"],
@@ -147,7 +147,7 @@ export const schemas = new Map<SchemaName, Deploy>([
147147
[
148148
"public-follows",
149149
{
150-
model: userPublicFollows as Schema,
150+
model: userPublicFollows,
151151
modelType: "AvroBinary",
152152
payloadLocation: "Paginated",
153153
settings: [],
@@ -157,7 +157,7 @@ export const schemas = new Map<SchemaName, Deploy>([
157157
[
158158
"private-follows",
159159
{
160-
model: userPrivateFollows as Schema,
160+
model: userPrivateFollows,
161161
modelType: "AvroBinary",
162162
payloadLocation: "Paginated",
163163
settings: [],
@@ -167,7 +167,7 @@ export const schemas = new Map<SchemaName, Deploy>([
167167
[
168168
"private-connections",
169169
{
170-
model: userPrivateConnections as Schema,
170+
model: userPrivateConnections,
171171
modelType: "AvroBinary",
172172
payloadLocation: "Paginated",
173173
settings: [],
@@ -177,7 +177,7 @@ export const schemas = new Map<SchemaName, Deploy>([
177177
[
178178
"public-key-assertion-method",
179179
{
180-
model: publicKey as Schema,
180+
model: publicKey,
181181
modelType: "AvroBinary",
182182
payloadLocation: "Itemized",
183183
settings: ["AppendOnly", "SignatureRequired"],
@@ -187,7 +187,7 @@ export const schemas = new Map<SchemaName, Deploy>([
187187
[
188188
"profile-resources",
189189
{
190-
model: profile as Schema,
190+
model: profile,
191191
modelType: "AvroBinary",
192192
payloadLocation: "Itemized",
193193
settings: [],

dsnp/userPrivateConnections.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import privateConnectionsSchema from "./userPrivateConnections.js";
22
import avro from "avro-js";
3+
import type { Schema } from "avsc";
34

45
describe("Private Connections Schema", () => {
56
it("Is Avro", () => {
@@ -11,7 +12,7 @@ describe("Private Connections Schema", () => {
1112
// Parse the inside and outside types.
1213
// The inside type must be self contained.
1314
const outsideType = avro.parse(privateConnectionsSchema);
14-
const insideType = avro.parse(privateConnectionsSchema.types[0]);
15+
const insideType = avro.parse((privateConnectionsSchema as Schema & { types: Schema[] }).types[0]);
1516

1617
// Generate a random inside type
1718
const inside = insideType.random();

dsnp/userPrivateConnections.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { UserDataType, descriptorForUserDataType } from "@dsnp/schemas";
2+
import type { Schema } from "avsc";
23

34
// Paginated Chunk with PRIds
4-
export default {
5+
const schema: Schema = {
56
type: "record",
67
name: "UserPrivateConnectionsChunk",
78
namespace: "org.dsnp",
@@ -35,3 +36,5 @@ export default {
3536
},
3637
],
3738
};
39+
40+
export default schema;

dsnp/userPrivateFollows.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import privateFollowsSchema from "./userPrivateFollows.js";
22
import avro from "avro-js";
3+
import type { Schema } from "avsc";
34

45
describe("Private Follows Schema", () => {
56
it("Is Avro", () => {
@@ -11,7 +12,7 @@ describe("Private Follows Schema", () => {
1112
// Parse the inside and outside types.
1213
// The inside type must be self contained.
1314
const outsideType = avro.parse(privateFollowsSchema);
14-
const insideType = avro.parse(privateFollowsSchema.types[0]);
15+
const insideType = avro.parse((privateFollowsSchema as Schema & { types: Schema[] }).types[0]);
1516

1617
// Generate a random inside type
1718
const inside = insideType.random();

dsnp/userPrivateFollows.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { UserDataType, descriptorForUserDataType } from "@dsnp/schemas";
2+
import type { Schema } from "avsc";
23

34
// Paginated Chunks
4-
export default {
5+
const schema: Schema = {
56
type: "record",
67
name: "UserPrivateFollowsChunk",
78
namespace: "org.dsnp",
@@ -27,3 +28,5 @@ export default {
2728
},
2829
],
2930
};
31+
32+
export default schema;

dsnp/userPublicFollows.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import publicFollowsSchema from "./userPublicFollows.js";
22
import avro from "avro-js";
3+
import type { Schema } from "avsc";
34

45
describe("Public Follows Schema", () => {
56
it("Is Avro", () => {
@@ -11,7 +12,7 @@ describe("Public Follows Schema", () => {
1112
// Parse the inside and outside types.
1213
// The inside type must be self contained.
1314
const outsideType = avro.parse(publicFollowsSchema);
14-
const insideType = avro.parse(publicFollowsSchema.types[0]);
15+
const insideType = avro.parse((publicFollowsSchema as Schema & { types: Schema[] }).types[0]);
1516

1617
// Generate a random inside type
1718
const inside = insideType.random();

dsnp/userPublicFollows.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { UserDataType, descriptorForUserDataType } from "@dsnp/schemas";
2+
import type { Schema } from "avsc";
23

34
// Paginated Chunk of compressed data with a type defined for the data post decompression
4-
export default {
5+
const schema: Schema = {
56
type: "record",
67
name: "UserPublicFollowsChunk",
78
namespace: "org.dsnp",
@@ -21,3 +22,5 @@ export default {
2122
},
2223
],
2324
};
25+
26+
export default schema;

0 commit comments

Comments
 (0)