Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move dependencies to devDependencies #3

Merged
merged 4 commits into from
Oct 7, 2024
Merged
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ npm install @dsnp/parquetjs
```

```typescript
import { AnnouncementType } from "@dsnp/schemas";
import { AnnouncementType } from "@dsnp/schemas";
import { parquet } from "@dsnp/schemas";
import { ParquetWriter } from "@dsnp/parquetjs";
import { ParquetWriter, ParquetSchema } from "@dsnp/parquetjs";

const [parquetSchema, writerOptions] = parquet.fromDSNPSchema(descriptorForAnnouncementType(AnnouncementType.Broadcast).parquetSchema);
const writer = await ParquetWriter.openFile(parquetSchema, "./file.parquet", writerOptions);
const writer = await ParquetWriter.openFile(new ParquetSchema(parquetSchema), "./file.parquet", writerOptions);
Copy link
Member

Choose a reason for hiding this comment

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

This is the change we should highlight in the changelog. Effectively instead of constructing this class object in here, we require devs to do it outside. Not a bad tradeoff for dropping the dependency.

writer.appendRow({
announcementType: AnnouncementType.Broadcast,
contentHash: "bciqdnu347gcfmxzbkhgoubiobphm6readngitfywktdtbdocgogop2q",
Expand Down
8 changes: 8 additions & 0 deletions __snapshots__/parquet.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ ParquetSchema {
"compression": "GZIP",
"dLevelMax": 0,
"encoding": "PLAIN",
"logicalType": undefined,
Copy link
Member

Choose a reason for hiding this comment

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

The latest version of Parquetjs also has this field

"name": "announcementType",
"originalType": "INT_32",
"path": [
Expand All @@ -89,6 +90,7 @@ ParquetSchema {
"compression": "GZIP",
"dLevelMax": 0,
"encoding": "PLAIN",
"logicalType": undefined,
"name": "contentHash",
"originalType": "UTF8",
"path": [
Expand All @@ -106,6 +108,7 @@ ParquetSchema {
"compression": "GZIP",
"dLevelMax": 0,
"encoding": "PLAIN",
"logicalType": undefined,
"name": "fromId",
"originalType": "UINT_64",
"path": [
Expand All @@ -123,6 +126,7 @@ ParquetSchema {
"compression": "GZIP",
"dLevelMax": 0,
"encoding": "PLAIN",
"logicalType": undefined,
"name": "url",
"originalType": "UTF8",
"path": [
Expand All @@ -142,6 +146,7 @@ ParquetSchema {
"compression": "GZIP",
"dLevelMax": 0,
"encoding": "PLAIN",
"logicalType": undefined,
"name": "announcementType",
"originalType": "INT_32",
"path": [
Expand All @@ -159,6 +164,7 @@ ParquetSchema {
"compression": "GZIP",
"dLevelMax": 0,
"encoding": "PLAIN",
"logicalType": undefined,
"name": "contentHash",
"originalType": "UTF8",
"path": [
Expand All @@ -176,6 +182,7 @@ ParquetSchema {
"compression": "GZIP",
"dLevelMax": 0,
"encoding": "PLAIN",
"logicalType": undefined,
"name": "fromId",
"originalType": "UINT_64",
"path": [
Expand All @@ -193,6 +200,7 @@ ParquetSchema {
"compression": "GZIP",
"dLevelMax": 0,
"encoding": "PLAIN",
"logicalType": undefined,
"name": "url",
"originalType": "UTF8",
"path": [
Expand Down
2 changes: 1 addition & 1 deletion announcements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import userAttributeSet from "./parquet/user-attribute-set.js";
import dsnpContentAttributeSet from "./parquet/dsnp-content-attribute-set.js";
import externalContentAttributeSet from "./parquet/external-content-attribute-set.js";

import { DSNPParquetSchema } from "./types/dsnp-parquet.js";
import type { DSNPParquetSchema } from "./types/dsnp-parquet.js";

export enum AnnouncementType {
Tombstone = 0,
Expand Down
5 changes: 3 additions & 2 deletions avro/GraphEdge.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import graphEdgeSchema from "./GraphEdge.js";
import avro from "avsc";
import type { Schema } from "avsc";

describe("Graph Edge Schema", () => {
it("Is Avro", () => {
const parsed = avro.Type.forSchema(graphEdgeSchema);
const parsed = avro.Type.forSchema(graphEdgeSchema as Schema);
expect(parsed).toBeDefined();
});

it("Encodes and decodes object", () => {
const parsed = avro.Type.forSchema(graphEdgeSchema);
const parsed = avro.Type.forSchema(graphEdgeSchema as Schema);
const encoded = parsed.toBuffer({ userId: 123456789, since: 1722524715 });
const decoded = parsed.fromBuffer(encoded);
expect(decoded.userId).toStrictEqual(123456789);
Expand Down
4 changes: 1 addition & 3 deletions avro/GraphEdge.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Schema } from "avsc";

const GraphEdge: Schema = {
const GraphEdge = {
namespace: "org.dsnp",
name: "GraphEdge",
type: "record",
Expand Down
5 changes: 3 additions & 2 deletions avro/PRId.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import pridSchema from "./PRId.js";
import avro from "avsc";
import type { Schema } from "avsc";

describe("PRId Schema", () => {
it("Is Avro", () => {
const parsed = avro.Type.forSchema(pridSchema);
const parsed = avro.Type.forSchema(pridSchema as Schema);
expect(parsed).toBeDefined();
});

it("Encodes and decodes buffer", () => {
const parsed = avro.Type.forSchema(pridSchema);
const parsed = avro.Type.forSchema(pridSchema as Schema);
const someBytes = Buffer.from([0, 1, 2, 3, 4, 5, 6, 7]);
const encoded = parsed.toBuffer(someBytes);
const decoded = parsed.fromBuffer(encoded);
Expand Down
4 changes: 1 addition & 3 deletions avro/PRId.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Schema } from "avsc";

const PRId: Schema = {
const PRId = {
namespace: "org.dsnp",
name: "PRId",
type: "fixed",
Expand Down
5 changes: 3 additions & 2 deletions avro/ProfileResource.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import profileResourceSchema from "./ProfileResource.js";
import { Type } from "avsc";
import type { Schema } from "avsc";

describe("Profile Resource Schema", () => {
it("Is Avro", () => {
const parsed = Type.forSchema(profileResourceSchema);
const parsed = Type.forSchema(profileResourceSchema as Schema);
expect(parsed).toBeDefined();
});

it("Encodes and decodes object", () => {
const parsed = Type.forSchema(profileResourceSchema);
const parsed = Type.forSchema(profileResourceSchema as Schema);
const exampleCid = "bafybeida7z24mig7j3oagjru7s2gw6xbfkh7fryvah6ho2ar77xb7aleom";
const encoded = parsed.toBuffer({
type: 1,
Expand Down
4 changes: 1 addition & 3 deletions avro/ProfileResource.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Schema } from "avsc";

const ProfileResource: Schema = {
const ProfileResource = {
namespace: "org.dsnp",
name: "ProfileResource",
type: "record",
Expand Down
5 changes: 3 additions & 2 deletions avro/PublicKey.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import publicKeySchema from "./PublicKey.js";
import avro from "avsc";
import type { Schema } from "avsc";

describe("Public Key Schema", () => {
it("Is Avro", () => {
const parsed = avro.Type.forSchema(publicKeySchema);
const parsed = avro.Type.forSchema(publicKeySchema as Schema);
expect(parsed).toBeDefined();
});

it("Encodes and decodes object", () => {
const parsed = avro.Type.forSchema(publicKeySchema);
const parsed = avro.Type.forSchema(publicKeySchema as Schema);
const someBytes = Buffer.from([0, 1, 2, 3]);
const encoded = parsed.toBuffer({ publicKey: someBytes });
const decoded = parsed.fromBuffer(encoded);
Expand Down
4 changes: 1 addition & 3 deletions avro/PublicKey.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Schema } from "avsc";

const PublicKey: Schema = {
const PublicKey = {
type: "record",
name: "PublicKey",
namespace: "org.dsnp",
Expand Down
2 changes: 2 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ export { AnnouncementDescriptor, AnnouncementType, descriptorForAnnouncementType
export { UserDataDescriptor, UserDataType, descriptorForUserDataType } from "./user-data.js";

export * as parquet from "./parquet.js";

export * from "./types/dsnp-parquet.js";
Loading