Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions apps/events/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export class User extends Entity.Class<User>('User')({

export class Todo extends Entity.Class<Todo>('Todo')({
name: Type.Text,
completed: Type.Checkbox,
completed: Type.Boolean,
assignees: Type.Relation(User),
}) {}

export class Todo2 extends Entity.Class<Todo2>('Todo2')({
name: Type.Text,
checked: Type.Checkbox,
checked: Type.Boolean,
assignees: Type.Relation(User),
due: Type.Date,
amount: Type.Number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class RelationTypeOption extends Schema.Class<RelationTypeOption>('/hypergraph/t
const typeOptions: Array<TypeOption> = [
TypeOption.make({ id: 'DefaultEntityText', name: 'Text' }),
TypeOption.make({ id: 'DefaultEntityNumber', name: 'Number' }),
TypeOption.make({ id: 'DefaultEntityCheckbox', name: 'Checkbox' }),
TypeOption.make({ id: 'DefaultEntityBoolean', name: 'Boolean' }),
TypeOption.make({ id: 'DefaultEntityDate', name: 'Date' }),
TypeOption.make({ id: 'DefaultEntityUrl', name: 'Url' }),
TypeOption.make({ id: 'DefaultEntityPoint', name: 'Point' }),
Expand Down
8 changes: 4 additions & 4 deletions docs/docs/filtering-query-results.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Note: Filtering is not yet supported for public data.
```tsx
export class Event extends Entity.Class<Event>("Event")({
name: Type.Text,
cancelled: Type.Checkbox,
cancelled: Type.Boolean,
}) {}

// inside the React component
Expand All @@ -23,7 +23,7 @@ const { data } = useQuery(Event, {
The filter API supports different filters for different property types and offers a logical `or` and `not` operator.

```tsx
// checkbox filter
// boolean filter
{
is: true/false, // exact match
exists: true/false, // filter by existence of the property
Expand Down Expand Up @@ -132,7 +132,7 @@ const { data } = useQuery(Person, {
// schema
export class Todo extends Entity.Class<Todo2>('Todo')({
name: Type.Text,
checked: Type.Checkbox,
checked: Type.Boolean,
assignees: Type.Relation(User),
})
```
Expand Down Expand Up @@ -175,7 +175,7 @@ const { data } = useQuery(Person, {
// schema
export class Todo extends Entity.Class<Todo2>('Todo')({
name: Type.Text,
checked: Type.Checkbox,
checked: Type.Boolean,
assignees: Type.Relation(User, {
entity: {
assignedAt: Type.DateTime,
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class Event extends Entity.Class<Event>('Event')({
- `Type.Text` (string)
- `Type.Number` (number)
- `Type.Date` (date)
- `Type.Checkbox` (boolean)
- `Type.Boolean` (boolean)
- `Type.Point` (serialized to a string with a comma separated list of numbers)
- `Type.Relation` (relation to another Type)

Expand All @@ -51,7 +51,7 @@ export class Company extends Entity.Class<Company>('Company')({
name: Type.Text,
employees: Type.Number,
founded: Type.Date,
active: Type.Checkbox,
active: Type.Boolean,
location: Type.Point,
}) {}
```
Expand Down
32 changes: 16 additions & 16 deletions docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,24 @@ const config = {
content: '536FEAE3B63DD658',
},
},
{
tagName: 'link',
attributes: {
rel: 'icon',
type: 'image/png',
href: '/img/HypergraphLogoDark.png',
media: '(prefers-color-scheme: light)',
{
tagName: 'link',
attributes: {
rel: 'icon',
type: 'image/png',
href: '/img/HypergraphLogoDark.png',
media: '(prefers-color-scheme: light)',
},
},
},
{
tagName: 'link',
attributes: {
rel: 'icon',
type: 'image/png',
href: '/img/HypergraphLogo.png',
media: '(prefers-color-scheme: dark)',
{
tagName: 'link',
attributes: {
rel: 'icon',
type: 'image/png',
href: '/img/HypergraphLogo.png',
media: '(prefers-color-scheme: dark)',
},
},
},
],

plugins: [
Expand Down
4 changes: 2 additions & 2 deletions docs/legacy-files/archived/schema-graph-based.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ import * as S from "effect/Schema";
export const type = {
Text: S.String,
Number: S.Number,
Checkbox: S.Boolean,
Boolean: S.Boolean,
};
```

Expand All @@ -288,7 +288,7 @@ export const schema: Schema = {
attributes: {
name: type.Text,
age: type.Number,
isActive: type.Checkbox,
isActive: type.Boolean,
email: type.Text,
},
types: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function useCreateEntityPublic<const S extends Entity.AnyNoContext>(
throw new Error(`Value for ${key} is undefined`);
}
let serializedValue: string = data[key];
if (TypeUtils.isCheckboxOrOptionalCheckboxType(fields[key])) {
if (TypeUtils.isBooleanOrOptionalBooleanType(fields[key])) {
serializedValue = Graph.serializeCheckbox(data[key]);
} else if (TypeUtils.isDateOrOptionalDateType(fields[key])) {
serializedValue = Graph.serializeDate(data[key]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const convertPropertyValue = (
key: string,
type: Entity.AnyNoContext,
) => {
if (TypeUtils.isCheckboxOrOptionalCheckboxType(type.fields[key]) && property.value !== undefined) {
if (TypeUtils.isBooleanOrOptionalBooleanType(type.fields[key]) && property.value !== undefined) {
return Boolean(property.value);
}
if (TypeUtils.isPointOrOptionalPointType(type.fields[key]) && property.value !== undefined) {
Expand Down
4 changes: 2 additions & 2 deletions packages/hypergraph-react/src/prepare-publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const preparePublish = async <S extends Entity.AnyNoContext>({
throw new Error(`Value for ${key} is undefined`);
}
let serializedValue: string = entity[key];
if (TypeUtils.isCheckboxOrOptionalCheckboxType(fields[key])) {
if (TypeUtils.isBooleanOrOptionalBooleanType(fields[key])) {
serializedValue = Graph.serializeCheckbox(entity[key]);
} else if (TypeUtils.isDateOrOptionalDateType(fields[key])) {
serializedValue = Graph.serializeDate(entity[key]);
Expand Down Expand Up @@ -118,7 +118,7 @@ export const preparePublish = async <S extends Entity.AnyNoContext>({
throw new Error(`Value for ${key} is undefined`);
}
let serializedValue: string = entity[key];
if (TypeUtils.isCheckboxOrOptionalCheckboxType(fields[key])) {
if (TypeUtils.isBooleanOrOptionalBooleanType(fields[key])) {
serializedValue = Graph.serializeCheckbox(entity[key]);
} else if (TypeUtils.isDateOrOptionalDateType(fields[key])) {
serializedValue = Graph.serializeDate(entity[key]);
Expand Down
18 changes: 9 additions & 9 deletions packages/hypergraph-react/test/prepare-publish.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('preparePublish', () => {
name: Type.Text,
age: Type.Number,
email: Type.optional(Type.Text),
isActive: Type.Checkbox,
isActive: Type.Boolean,
birthDate: Type.Date,
location: Type.Point,
}) {}
Expand All @@ -38,7 +38,7 @@ describe('preparePublish', () => {
class OptionalFieldsEntity extends Entity.Class<OptionalFieldsEntity>('OptionalFieldsEntity')({
name: Type.Text, // required field
optionalNumber: Type.optional(Type.Number),
optionalCheckbox: Type.optional(Type.Checkbox),
optionalBoolean: Type.optional(Type.Boolean),
optionalDate: Type.optional(Type.Date),
optionalPoint: Type.optional(Type.Point),
}) {}
Expand Down Expand Up @@ -82,7 +82,7 @@ describe('preparePublish', () => {
properties: {
name: Id.Id('2a8b9c7d-4e5f-6a7b-8c9d-0e1f2a3b4c5d'),
optionalNumber: Id.Id('eaf9f4f8-5647-4228-aff5-8725368fc87c'),
optionalCheckbox: Id.Id('2742d8b6-3059-4adb-b439-fdfcd588dccb'),
optionalBoolean: Id.Id('2742d8b6-3059-4adb-b439-fdfcd588dccb'),
optionalDate: Id.Id('9b53690f-ea6d-4bd8-b4d3-9ea01e7f837f'),
optionalPoint: Id.Id('0c1d2e3f-4a5b-4c7d-8e9f-0a1b2c3d4e5f'),
},
Expand Down Expand Up @@ -405,7 +405,7 @@ describe('preparePublish', () => {
type: 'OptionalFieldsEntity',
name: 'Test Entity',
optionalNumber: 42.5,
optionalCheckbox: true,
optionalBoolean: true,
optionalDate: new Date('2024-01-15'),
optionalPoint: [12.34, 56.78],
__schema: OptionalFieldsEntity,
Expand All @@ -428,7 +428,7 @@ describe('preparePublish', () => {
type: 'OptionalFieldsEntity',
name: 'Test Entity',
optionalNumber: 25,
// optionalCheckbox is undefined
// optionalBoolean is undefined
optionalDate: new Date('2024-02-20'),
// optionalPoint is undefined
__schema: OptionalFieldsEntity,
Expand Down Expand Up @@ -492,7 +492,7 @@ describe('preparePublish', () => {
}
});

it('should handle optional Checkbox field variations', async () => {
it('should handle optional Boolean field variations', async () => {
const testCases = [
{ value: true, description: 'true' },
{ value: false, description: 'false' },
Expand All @@ -504,7 +504,7 @@ describe('preparePublish', () => {
id: 'e68aa940-8452-48de-8523-292ba3771f81',
type: 'OptionalFieldsEntity',
name: `Test ${testCase.description}`,
optionalCheckbox: testCase.value,
optionalBoolean: testCase.value,
__schema: OptionalFieldsEntity,
} as Entity.Entity<typeof OptionalFieldsEntity>;

Expand Down Expand Up @@ -605,7 +605,7 @@ describe('preparePublish', () => {
type: 'OptionalFieldsEntity',
name: 'Existing Entity',
optionalNumber: 100, // New field
optionalCheckbox: true, // New field
optionalBoolean: true, // New field
optionalDate: new Date('2024-03-15'), // New field
optionalPoint: [45.0, 90.0], // New field
__schema: OptionalFieldsEntity,
Expand Down Expand Up @@ -671,7 +671,7 @@ describe('preparePublish', () => {
type: 'OptionalFieldsEntity',
name: 'Existing Entity',
optionalNumber: 125, // Changed from 75
// optionalCheckbox: undefined (not present, will remain undefined)
// optionalBoolean: undefined (not present, will remain undefined)
optionalDate: new Date('2023-01-01'), // Same as existing (no change)
optionalPoint: [12.5, 25.0], // New field
__schema: OptionalFieldsEntity,
Expand Down
2 changes: 1 addition & 1 deletion packages/hypergraph/src/entity/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export type DocumentContent = {
relations?: Record<string, DocumentRelation>;
};

export type EntityCheckboxFilter = {
export type EntityBooleanFilter = {
is: boolean;
};

Expand Down
4 changes: 2 additions & 2 deletions packages/hypergraph/src/mapping/Mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export type SchemaDataTypeRelation = typeof SchemaDataTypeRelation.Type;
/**
* @since 0.2.0
*/
export const SchemaDataTypePrimitive = EffectSchema.Literal('Text', 'Number', 'Checkbox', 'Date', 'Point');
export const SchemaDataTypePrimitive = EffectSchema.Literal('Text', 'Number', 'Boolean', 'Date', 'Point');
/**
* @since 0.2.0
*/
Expand Down Expand Up @@ -749,7 +749,7 @@ export class RelationValueTypeDoesNotExistError extends Data.TaggedError(
*/
export function mapSchemaDataTypeToGRC20PropDataType(dataType: SchemaDataType): CreatePropertyParams['dataType'] {
switch (true) {
case dataType === 'Checkbox': {
case dataType === 'Boolean': {
return 'CHECKBOX';
}
case dataType === 'Date': {
Expand Down
6 changes: 3 additions & 3 deletions packages/hypergraph/src/type-utils/type-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ export const isDateOrOptionalDateType = (type: any) => {
};

// biome-ignore lint/suspicious/noExplicitAny: TODO
export const isCheckboxOrOptionalCheckboxType = (type: any) => {
export const isBooleanOrOptionalBooleanType = (type: any) => {
if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) {
return type.from === Type.Checkbox;
return type.from === Type.Boolean;
}
return type === Type.Checkbox;
return type === Type.Boolean;
};

// biome-ignore lint/suspicious/noExplicitAny: TODO
Expand Down
3 changes: 2 additions & 1 deletion packages/hypergraph/src/type/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import type { AnyNoContext, EntityWithRelation } from '../entity/types.js';
export const Text = Schema.String;
// biome-ignore lint/suspicious/noShadowRestrictedNames: is part of a namespaces module and therefor ok
export const Number = Schema.Number;
export const Checkbox = Schema.Boolean;
// biome-ignore lint/suspicious/noShadowRestrictedNames: is part of a namespaces module and therefor ok
export const Boolean = Schema.Boolean;
// biome-ignore lint/suspicious/noShadowRestrictedNames: is part of a namespaces module and therefor ok
export const Date = Schema.Date;
export const Point = Schema.transform(Schema.String, Schema.Array(Number), {
Expand Down
2 changes: 1 addition & 1 deletion packages/hypergraph/test/entity/findMany.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('findMany with filters', () => {
class Person extends Entity.Class<Person>('Person')({
name: Type.Text,
age: Type.Number,
isActive: Type.Checkbox,
isActive: Type.Boolean,
}) {}

class Product extends Entity.Class<Product>('Product')({
Expand Down
2 changes: 1 addition & 1 deletion packages/hypergraph/test/mapping/Mapping.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
describe('Mapping', () => {
describe('mapSchemaDataTypeToGRC20PropDataType', () => {
it('should be able to map the schema dataType to the correct GRC-20 dataType', () => {
expect(mapSchemaDataTypeToGRC20PropDataType('Checkbox')).toEqual('CHECKBOX');
expect(mapSchemaDataTypeToGRC20PropDataType('Boolean')).toEqual('CHECKBOX');
expect(mapSchemaDataTypeToGRC20PropDataType('Number')).toEqual('NUMBER');
expect(mapSchemaDataTypeToGRC20PropDataType('Date')).toEqual('TIME');
expect(mapSchemaDataTypeToGRC20PropDataType('Point')).toEqual('POINT');
Expand Down
Loading