Skip to content

Commit

Permalink
Merge pull request #2081 from undb-io/release/v1.0.0-96
Browse files Browse the repository at this point in the history
Release version v1.0.0-96
  • Loading branch information
nichenqin authored Oct 9, 2024
2 parents 4fb23df + 116bf75 commit 8bbdcdd
Show file tree
Hide file tree
Showing 17 changed files with 816 additions and 91,339 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## v1.0.0-96


### 🏡 Chore

- Hide hr template ([d9f220d](https://github.com/undb-io/undb/commit/d9f220d))

### ❤️ Contributors

- Nichenqin ([@nichenqin](http://github.com/nichenqin))

## v1.0.0-95


Expand Down
91,311 changes: 0 additions & 91,311 deletions apps/backend/assets/api-reference.js

This file was deleted.

36 changes: 36 additions & 0 deletions apps/backend/assets/api-reference@1.25.30.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/backend/src/modules/openapi/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class OpenAPI {
JSON.stringify(configuration)
</script>
<script src="/assets/api-reference.js"></script>
<script src="/assets/api-reference@1.25.30.js"></script>
</body>
</html>`
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,15 @@
</script>

{#if field.allowRichText}
<div class={cn("relative overflow-hidden", $$restProps.class)}>
<div class={cn("relative h-full overflow-hidden", $$restProps.class)}>
{#if isEditing || isSelected}
<div class="flex w-full items-center justify-between gap-1 overflow-hidden">
<button type="button" on:click={() => (open = true)} class="flex flex-1 items-center gap-1 truncate">
<span class="inline-flex flex-1 self-start truncate">
<div class="flex h-full w-full items-center justify-between gap-1 overflow-hidden">
<button
type="button"
on:click={() => (open = true)}
class="flex h-full flex-1 items-center gap-1 overflow-hidden"
>
<span class="inline-flex h-full flex-1 items-center truncate">
{@html value}
</span>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
{#each value as item}
{#if !!item}
<span
class="me-2 min-w-8 rounded bg-gray-100 px-2 py-1 text-xs font-medium text-gray-800 dark:bg-gray-700 dark:text-gray-300"
class="me-2 min-w-8 truncate rounded bg-gray-200 px-2 py-0.5 text-xs font-medium text-gray-800 dark:bg-gray-700 dark:text-gray-300"
>
{item}
</span>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "undb",
"version": "1.0.0-95",
"version": "1.0.0-96",
"private": true,
"scripts": {
"build": "NODE_ENV=production bun --bun turbo build",
Expand Down
2 changes: 1 addition & 1 deletion packages/persistence/src/record/record-query.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class RecordQueryHelper {
}
}

return qb.orderBy(`${s.fieldId} ${s.direction}`)
return qb.orderBy(`${table.id.value}.${s.fieldId} ${s.direction}`)
}, qb)
}
}
Expand Down
68 changes: 54 additions & 14 deletions packages/persistence/src/template/template-data.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { env } from "@undb/env"
import { templates, type IBaseTemplateDTO, type ITemplateDTO } from "@undb/template"
import { templates,type IBaseTemplateDTO,type ITemplateDTO } from "@undb/template"

function getTemplateImage(folder: string, file: string) {
return env.UNDB_BASE_URL + "/assets/templates/" + folder + "/" + file
Expand Down Expand Up @@ -236,18 +236,58 @@ export const templateData: ITemplateDTO[] = [
template: templates.socialMediaContent as IBaseTemplateDTO,
},
},
// {
// id: "6ba7b815-9dad-11d1-80b4-00c04fd430c8",
// icon: "👨‍👧‍👦",
// name: "Human Resource Management",
// categories: ["hr"],
// cover: getTemplateImage("hr", "cover.jpg"),
// images: [getTemplateImage("hr", "image1.png"), getTemplateImage("hr", "image2.png")],
// description: "A template for managing human resources, including employees, positions, and departments.",
// detail: `
// <h1>Streamline Your Human Resource Management with UnDB's HR Management Template</h1>
// <h2>Comprehensive HR Management Features</h2>
// <p>UnDB's HR Management template offers a powerful set of tools to enhance your human resource management:</p>
// <ul>
// <li>Employee Management: Easily create, assign, and monitor employee records</li>
// <li>Department Organization: Efficiently structure and manage company departments</li>
// <li>Payroll Administration: Track and manage employee compensation, including salaries, bonuses, and benefits</li>
// <li>Performance Evaluation: Set up and conduct regular performance reviews and goal-setting sessions</li>
// <li>Time Off Management: Streamline the process of requesting, approving, and tracking employee leave</li>
// <li>Recruitment and Onboarding: Manage job postings, applications, and new employee onboarding processes</li>
// <li>Training and Development: Plan and track employee training programs and career development initiatives</li>
// <li>Compliance Management: Ensure adherence to labor laws and company policies</li>
// <li>Reporting and Analytics: Generate insightful reports on various HR metrics for data-driven decision making</li>
// </ul>
// <h2>Benefits of Using UnDB's HR Management Template</h2>
// <p>Implementing our HR Management template can bring numerous advantages to your organization:</p>
// <ul>
// <li>Increased Efficiency: Automate routine HR tasks and streamline workflows</li>
// <li>Improved Data Accuracy: Centralize employee information and reduce errors in record-keeping</li>
// <li>Enhanced Employee Experience: Provide self-service options for employees to access their information</li>
// <li>Better Decision Making: Leverage HR analytics to make informed strategic decisions</li>
// <li>Scalability: Easily adapt the template to your growing organization's needs</li>
// <li>Cost Savings: Reduce administrative overhead and optimize resource allocation</li>
// </ul>
// <p>Start transforming your HR processes today with UnDB's comprehensive HR Management template!</p>
// `,
// template: {
// type: "base",
// template: templates.hr as IBaseTemplateDTO,
// },
// },
]

// if (env.NODE_ENV === "development") {
// templateData.unshift({
// id: "test",
// icon: "💼",
// name: "Test",
// categories: ["sales"],
// description: "A template for testing",
// template: {
// type: "base",
// template: templates.test as IBaseTemplateDTO,
// },
// })
// }
if (env.NODE_ENV === "development") {
templateData.unshift({
id: "test",
icon: "💼",
name: "Test",
categories: ["sales"],
description: "A template for testing",
template: {
type: "base",
template: templates.test as IBaseTemplateDTO,
},
})
}
3 changes: 2 additions & 1 deletion packages/table/src/methods/create-field.method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { None, Option, Some, andOptions, applyRules } from "@undb/domain"
import { FieldCreatedEvent } from "../events"
import { type Field, type ICreateFieldDTO } from "../modules"
import { FieldFactory } from "../modules/schema/fields/field.factory"
import { FieldIdShouldBeUnique } from "../modules/schema/rules/field-id-should-be-unique.rule"
import { FieldNameShouldBeUnique } from "../modules/schema/rules/field-name-should-be-unique.rule"
import type { TableComositeSpecification } from "../specifications"
import type { TableDo } from "../table.do"
Expand All @@ -18,7 +19,7 @@ export function $createFieldSpec(this: TableDo, field: Field): Option<TableComos
).unwrap()
spec.mutate(this)

applyRules(new FieldNameShouldBeUnique(this.schema))
applyRules(new FieldNameShouldBeUnique(this.schema), new FieldIdShouldBeUnique(this.schema))

const event = new FieldCreatedEvent({
tableId: this.id.value,
Expand Down
3 changes: 2 additions & 1 deletion packages/table/src/methods/update-field.method.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Option, Some, applyRules } from "@undb/domain"
import { FieldUpdatedEvent } from "../events"
import { type IUpdateFieldDTO } from "../modules"
import { FieldIdShouldBeUnique } from "../modules/schema/rules/field-id-should-be-unique.rule"
import { FieldNameShouldBeUnique } from "../modules/schema/rules/field-name-should-be-unique.rule"
import type { TableComositeSpecification } from "../specifications"
import type { TableDo } from "../table.do"
Expand All @@ -10,7 +11,7 @@ export function updateFieldMethod(this: TableDo, dto: IUpdateFieldDTO): Option<T
// TODO: update form
spec.mutate(this)

applyRules(new FieldNameShouldBeUnique(this.schema))
applyRules(new FieldNameShouldBeUnique(this.schema), new FieldIdShouldBeUnique(this.schema))

const event = new FieldUpdatedEvent({
tableId: this.id.value,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { DomainRules, ExceptionBase } from "@undb/domain"
import type { Schema } from "../schema.vo"

class FieldIdShouldBeUniqueError extends ExceptionBase {
code = "table:FIELD_ID_SHOULD_BE_UNIQUE"

constructor() {
super("Field id should be unique")
}
}

export class FieldIdShouldBeUnique extends DomainRules<FieldIdShouldBeUniqueError> {
constructor(private readonly schema: Schema) {
super()
}

override err = new FieldIdShouldBeUniqueError()

override isBroken(): boolean {
const ids = this.schema.fields.map((field) => field.id.value)
return new Set(ids).size !== ids.length
}
}
1 change: 1 addition & 0 deletions packages/table/src/modules/schema/rules/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./field-id-should-be-unique.rule"
export * from "./field-name-should-be-unique.rule"
4 changes: 2 additions & 2 deletions packages/table/src/table.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
type ICreateSchemaDTO,
type ICreateTablesReferenceFieldDTO,
} from "./modules"
import { FieldNameShouldBeUnique } from "./modules/schema/rules"
import { FieldIdShouldBeUnique, FieldNameShouldBeUnique } from "./modules/schema/rules"
import { TableIdVo } from "./table-id.vo"
import { TableBuilder } from "./table.builder"
import type { TableDo } from "./table.do"
Expand Down Expand Up @@ -65,7 +65,7 @@ export class TableFactory {
.createForms(dto.forms)
.build()

applyRules(new FieldNameShouldBeUnique(table.schema))
applyRules(new FieldNameShouldBeUnique(table.schema), new FieldIdShouldBeUnique(table.schema))

// @ts-ignore - TODO: fix this
table.addDomainEvent(new TableCreatedEvent({ table: table.toJSON() }))
Expand Down
Loading

0 comments on commit 8bbdcdd

Please sign in to comment.