@nestjs-dash/core 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { compactObject } from '@nestjs-dash/support';
1
+ import { compactObject } from "@nestjs-dash/support";
2
2
  export class ComponentBuilder {
3
3
  props = {};
4
4
  children = [];
@@ -17,7 +17,7 @@ export class ComponentBuilder {
17
17
  }
18
18
  }
19
19
  export class Schema extends ComponentBuilder {
20
- kind = 'schema';
20
+ kind = "schema";
21
21
  static make() {
22
22
  return new Schema();
23
23
  }
@@ -27,11 +27,11 @@ export class Schema extends ComponentBuilder {
27
27
  }
28
28
  }
29
29
  export class Section extends ComponentBuilder {
30
- kind = 'section';
30
+ kind = "section";
31
31
  static make(heading) {
32
32
  const section = new Section();
33
33
  if (heading) {
34
- section.setProp('heading', heading);
34
+ section.setProp("heading", heading);
35
35
  }
36
36
  return section;
37
37
  }
@@ -40,13 +40,13 @@ export class Section extends ComponentBuilder {
40
40
  return this;
41
41
  }
42
42
  collapsible(value = true) {
43
- return this.setProp('collapsible', value);
43
+ return this.setProp("collapsible", value);
44
44
  }
45
45
  }
46
46
  export class Grid extends ComponentBuilder {
47
- kind = 'grid';
47
+ kind = "grid";
48
48
  static make(columns = 2) {
49
- return new Grid().setProp('columns', columns);
49
+ return new Grid().setProp("columns", columns);
50
50
  }
51
51
  components(components) {
52
52
  this.children = components.map((component) => component.toSchema());
@@ -56,20 +56,20 @@ export class Grid extends ComponentBuilder {
56
56
  function slugifyTabId(label) {
57
57
  const slug = label
58
58
  .toLowerCase()
59
- .replace(/[^a-z0-9]+/g, '-')
60
- .replace(/^-+|-+$/g, '');
61
- return slug.length > 0 ? slug : 'tab';
59
+ .replace(/[^a-z0-9]+/g, "-")
60
+ .replace(/^-+|-+$/g, "");
61
+ return slug.length > 0 ? slug : "tab";
62
62
  }
63
63
  export class Tab extends ComponentBuilder {
64
- kind = 'tab';
64
+ kind = "tab";
65
65
  static make(label) {
66
- return new Tab().setProp('label', label).setProp('id', slugifyTabId(label));
66
+ return new Tab().setProp("label", label).setProp("id", slugifyTabId(label));
67
67
  }
68
68
  id(value) {
69
- return this.setProp('id', value);
69
+ return this.setProp("id", value);
70
70
  }
71
71
  icon(value) {
72
- return this.setProp('icon', value);
72
+ return this.setProp("icon", value);
73
73
  }
74
74
  components(components) {
75
75
  this.children = components.map((component) => component.toSchema());
@@ -77,7 +77,7 @@ export class Tab extends ComponentBuilder {
77
77
  }
78
78
  }
79
79
  export class Tabs extends ComponentBuilder {
80
- kind = 'tabs';
80
+ kind = "tabs";
81
81
  static make() {
82
82
  return new Tabs();
83
83
  }
@@ -98,29 +98,29 @@ export function resolveHtmlContent(key) {
98
98
  return htmlContentRegistry.get(key);
99
99
  }
100
100
  export class Html extends ComponentBuilder {
101
- kind = 'html';
101
+ kind = "html";
102
102
  static make(content) {
103
103
  const html = new Html();
104
- if (typeof content === 'string') {
105
- html.setProp('html', content);
104
+ if (typeof content === "string") {
105
+ html.setProp("html", content);
106
106
  return html;
107
107
  }
108
108
  const key = hashString(content.toString());
109
109
  htmlContentRegistry.set(key, content);
110
- html.setProp('htmlKey', key);
110
+ html.setProp("htmlKey", key);
111
111
  return html;
112
112
  }
113
113
  key(value) {
114
114
  const previous = this.props.htmlKey;
115
- if (typeof previous === 'string') {
115
+ if (typeof previous === "string") {
116
116
  const fn = htmlContentRegistry.get(previous);
117
117
  if (fn) {
118
118
  htmlContentRegistry.delete(previous);
119
119
  htmlContentRegistry.set(value, fn);
120
120
  }
121
121
  }
122
- return this.setProp('htmlKey', value);
122
+ return this.setProp("htmlKey", value);
123
123
  }
124
124
  }
125
- export {} from '@nestjs-dash/support';
125
+ export {} from "@nestjs-dash/support";
126
126
  //# sourceMappingURL=index.js.map
@@ -1,24 +1,24 @@
1
- import type { FilterOperator } from '@nestjs-dash/adapter';
2
- import type { BadgeColor, SchemaNode } from '@nestjs-dash/support';
3
- import type { Action } from '../actions/index.js';
4
- export type { FilterOperator } from '@nestjs-dash/adapter';
5
- export * from './list-query-config.js';
1
+ import type { FilterOperator } from "@nestjs-dash/adapter";
2
+ import type { BadgeColor, SchemaNode } from "@nestjs-dash/support";
3
+ import type { Action } from "../actions/index.js";
4
+ export type { FilterOperator } from "@nestjs-dash/adapter";
5
+ export * from "./list-query-config.js";
6
6
  export interface TableSchema {
7
- kind: 'table';
7
+ kind: "table";
8
8
  columns: SchemaNode[];
9
9
  filters: SchemaNode[];
10
10
  actions: SchemaNode[];
11
11
  toolbarActions: SchemaNode[];
12
12
  bulkActions: SchemaNode[];
13
13
  props: {
14
- defaultSortBy?: Array<[string, 'ASC' | 'DESC']>;
14
+ defaultSortBy?: Array<[string, "ASC" | "DESC"]>;
15
15
  defaultLimit?: number;
16
16
  };
17
17
  }
18
18
  declare abstract class ColumnBuilder {
19
- protected readonly kind: SchemaNode['kind'];
19
+ protected readonly kind: SchemaNode["kind"];
20
20
  protected props: Record<string, unknown>;
21
- constructor(kind: SchemaNode['kind'], name: string);
21
+ constructor(kind: SchemaNode["kind"], name: string);
22
22
  label(value: string): this;
23
23
  sortable(value?: boolean): this;
24
24
  searchable(value?: boolean): this;
@@ -36,7 +36,7 @@ export declare class IconColumn extends ColumnBuilder {
36
36
  export declare class ImageColumn extends ColumnBuilder {
37
37
  constructor(name: string);
38
38
  static make(name: string): ImageColumn;
39
- shape(value: 'circle' | 'square'): this;
39
+ shape(value: "circle" | "square"): this;
40
40
  collection(name: string): this;
41
41
  disk(name: string): this;
42
42
  }
@@ -102,7 +102,7 @@ export declare class Table {
102
102
  actions(actions: Action[]): this;
103
103
  toolbarActions(actions: Action[]): this;
104
104
  bulkActions(actions: Action[]): this;
105
- defaultSortBy(sortBy: Array<[string, 'ASC' | 'DESC']>): this;
105
+ defaultSortBy(sortBy: Array<[string, "ASC" | "DESC"]>): this;
106
106
  defaultLimit(limit: number): this;
107
107
  toSchema(): TableSchema;
108
108
  columnCapabilities(): ColumnCapabilities;
@@ -110,7 +110,7 @@ export declare class Table {
110
110
  sortableColumns: string[];
111
111
  searchableColumns: string[];
112
112
  filterableColumns: Record<string, FilterOperator[] | true>;
113
- defaultSortBy?: Array<[string, 'ASC' | 'DESC']>;
113
+ defaultSortBy?: Array<[string, "ASC" | "DESC"]>;
114
114
  defaultLimit?: number;
115
115
  };
116
116
  }
@@ -1,5 +1,5 @@
1
- import { compactObject } from '@nestjs-dash/support';
2
- export * from './list-query-config.js';
1
+ import { compactObject } from "@nestjs-dash/support";
2
+ export * from "./list-query-config.js";
3
3
  class ColumnBuilder {
4
4
  kind;
5
5
  props;
@@ -33,7 +33,7 @@ class ColumnBuilder {
33
33
  }
34
34
  export class TextColumn extends ColumnBuilder {
35
35
  constructor(name) {
36
- super('text-column', name);
36
+ super("text-column", name);
37
37
  }
38
38
  static make(name) {
39
39
  return new TextColumn(name);
@@ -41,7 +41,7 @@ export class TextColumn extends ColumnBuilder {
41
41
  }
42
42
  export class IconColumn extends ColumnBuilder {
43
43
  constructor(name) {
44
- super('icon-column', name);
44
+ super("icon-column", name);
45
45
  }
46
46
  static make(name) {
47
47
  return new IconColumn(name);
@@ -49,7 +49,7 @@ export class IconColumn extends ColumnBuilder {
49
49
  }
50
50
  export class ImageColumn extends ColumnBuilder {
51
51
  constructor(name) {
52
- super('image-column', name);
52
+ super("image-column", name);
53
53
  }
54
54
  static make(name) {
55
55
  return new ImageColumn(name);
@@ -69,7 +69,7 @@ export class ImageColumn extends ColumnBuilder {
69
69
  }
70
70
  export class BadgeColumn extends ColumnBuilder {
71
71
  constructor(name) {
72
- super('badge-column', name);
72
+ super("badge-column", name);
73
73
  }
74
74
  static make(name) {
75
75
  return new BadgeColumn(name);
@@ -81,7 +81,7 @@ export class BadgeColumn extends ColumnBuilder {
81
81
  }
82
82
  export class BooleanColumn extends ColumnBuilder {
83
83
  constructor(name) {
84
- super('boolean-column', name);
84
+ super("boolean-column", name);
85
85
  }
86
86
  static make(name) {
87
87
  return new BooleanColumn(name);
@@ -89,7 +89,7 @@ export class BooleanColumn extends ColumnBuilder {
89
89
  }
90
90
  export class DateColumn extends ColumnBuilder {
91
91
  constructor(name) {
92
- super('date-column', name);
92
+ super("date-column", name);
93
93
  }
94
94
  static make(name) {
95
95
  return new DateColumn(name);
@@ -104,7 +104,7 @@ export class SelectFilter {
104
104
  constructor(name) {
105
105
  this.props = {
106
106
  name,
107
- operators: ['$eq'],
107
+ operators: ["$eq"],
108
108
  };
109
109
  }
110
110
  static make(name) {
@@ -132,7 +132,7 @@ export class SelectFilter {
132
132
  }
133
133
  toSchema() {
134
134
  return {
135
- kind: 'select-filter',
135
+ kind: "select-filter",
136
136
  name: String(this.props.name),
137
137
  props: { ...this.props },
138
138
  };
@@ -143,7 +143,7 @@ export class TextFilter {
143
143
  constructor(name) {
144
144
  this.props = {
145
145
  name,
146
- operators: ['$ilike'],
146
+ operators: ["$ilike"],
147
147
  };
148
148
  }
149
149
  static make(name) {
@@ -163,7 +163,7 @@ export class TextFilter {
163
163
  }
164
164
  toSchema() {
165
165
  return {
166
- kind: 'text-filter',
166
+ kind: "text-filter",
167
167
  name: String(this.props.name),
168
168
  props: { ...this.props },
169
169
  };
@@ -174,7 +174,7 @@ export class DateFilter {
174
174
  constructor(name) {
175
175
  this.props = {
176
176
  name,
177
- operators: ['$eq'],
177
+ operators: ["$eq"],
178
178
  };
179
179
  }
180
180
  static make(name) {
@@ -190,7 +190,7 @@ export class DateFilter {
190
190
  }
191
191
  toSchema() {
192
192
  return {
193
- kind: 'date-filter',
193
+ kind: "date-filter",
194
194
  name: String(this.props.name),
195
195
  props: { ...this.props },
196
196
  };
@@ -236,7 +236,7 @@ export class Table {
236
236
  }
237
237
  toSchema() {
238
238
  return {
239
- kind: 'table',
239
+ kind: "table",
240
240
  columns: this.columnBuilders.map((column) => column.toSchema()),
241
241
  filters: this.filterBuilders.map((filter) => filter.toSchema()),
242
242
  actions: this.actionBuilders.map((action) => action.toSchema()),
@@ -1,6 +1,6 @@
1
- import { type EntityConstructor, type ListQueryConfig, type PropertyAdapter } from '@nestjs-dash/adapter';
2
- import type { ResourceClass } from '../index.js';
3
- import { type ColumnCapabilities } from './index.js';
1
+ import { type EntityConstructor, type ListQueryConfig, type PropertyAdapter } from "@nestjs-dash/adapter";
2
+ import type { ResourceClass } from "../index.js";
3
+ import { type ColumnCapabilities } from "./index.js";
4
4
  export declare function resolveListQueryConfig(resource: ResourceClass, propertyNames: string[], computeFromEntity?: (tableDefaults: Partial<ListQueryConfig>, columnCapabilities: ColumnCapabilities) => ListQueryConfig, propertyDefaults?: PropertyAdapter[]): ListQueryConfig;
5
5
  export declare function listQueryConfigFromEntity(entity: EntityConstructor, defaults?: Partial<ListQueryConfig>, explicit?: ColumnCapabilities, properties?: PropertyAdapter[]): ListQueryConfig;
6
6
  //# sourceMappingURL=list-query-config.d.ts.map
@@ -1,9 +1,9 @@
1
- import { getEntityColumnMeta, resolveCapability, } from '@nestjs-dash/adapter';
2
- import { Table } from './index.js';
1
+ import { getEntityColumnMeta, resolveCapability, } from "@nestjs-dash/adapter";
2
+ import { Table } from "./index.js";
3
3
  export function resolveListQueryConfig(resource, propertyNames, computeFromEntity, propertyDefaults) {
4
4
  let tableDefaults = { defaultLimit: 20 };
5
5
  let columnCapabilities = {};
6
- if (typeof resource.table === 'function') {
6
+ if (typeof resource.table === "function") {
7
7
  const table = resource.table(Table.make());
8
8
  const fromTable = table.toListQueryConfig();
9
9
  tableDefaults = {
@@ -28,7 +28,7 @@ export function resolveListQueryConfig(resource, propertyNames, computeFromEntit
28
28
  }
29
29
  return {
30
30
  ...resolved,
31
- sortableColumns: propertyNames.length ? propertyNames : ['id'],
31
+ sortableColumns: propertyNames.length ? propertyNames : ["id"],
32
32
  };
33
33
  }
34
34
  export function listQueryConfigFromEntity(entity, defaults = {}, explicit = {}, properties = []) {
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@nestjs-dash/core",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "description": "Panel, Resource, Table/Form/Action/Schema builders for nestjs-dash (the NestJS host module lives in @nestjs-dash/nestjs; ORM adapters in @nestjs-dash/{typeorm,mikroorm,prisma,in-memory})",
5
+ "homepage": "https://github.com/nestjs-dash/core/tree/main/packages/core#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/nestjs-dash/core/issues"
8
+ },
5
9
  "license": "MIT",
6
10
  "repository": {
7
11
  "type": "git",
8
12
  "url": "git+https://github.com/nestjs-dash/core.git",
9
13
  "directory": "packages/core"
10
14
  },
11
- "bugs": {
12
- "url": "https://github.com/nestjs-dash/core/issues"
13
- },
14
- "homepage": "https://github.com/nestjs-dash/core/tree/main/packages/core#readme",
15
15
  "files": [
16
16
  "dist"
17
17
  ],
@@ -25,31 +25,21 @@
25
25
  "publishConfig": {
26
26
  "access": "public"
27
27
  },
28
- "scripts": {
29
- "build": "tsc -p tsconfig.json",
30
- "check-types": "tsc -p tsconfig.json --noEmit",
31
- "format": "oxfmt",
32
- "lint": "oxlint src",
33
- "test": "vitest run",
34
- "test:coverage": "vitest run --coverage",
35
- "release": "release-it",
36
- "dev": "tsc -p tsconfig.json --watch"
37
- },
38
28
  "dependencies": {
39
- "@nestjs-dash/adapter": "workspace:*",
29
+ "@nestjs-dash/adapter": "0.0.3",
40
30
  "@nestjs-dash/support": "^0.3.0",
41
31
  "lucide": "^1.45.0",
42
32
  "zod": "^4.6.2"
43
33
  },
44
34
  "devDependencies": {
45
- "typescript": "7.0.2",
46
- "vitest": "^5.0.0",
35
+ "@release-it/conventional-changelog": "^12.0.0",
36
+ "@types/node": "^26.5.1",
47
37
  "@vitest/coverage-v8": "5.0.0",
48
38
  "oxfmt": "^0.67.0",
49
39
  "oxlint": "^1.82.0",
50
- "@types/node": "^26.5.1",
51
40
  "release-it": "^21.0.2",
52
- "@release-it/conventional-changelog": "^12.0.0"
41
+ "typescript": "7.0.2",
42
+ "vitest": "^5.0.0"
53
43
  },
54
44
  "peerDependencies": {
55
45
  "vitest": "^5.0.0"
@@ -58,5 +48,15 @@
58
48
  "vitest": {
59
49
  "optional": true
60
50
  }
51
+ },
52
+ "scripts": {
53
+ "build": "tsc -p tsconfig.json",
54
+ "check-types": "tsc -p tsconfig.json --noEmit",
55
+ "format": "oxfmt",
56
+ "lint": "oxlint src",
57
+ "test": "vitest run",
58
+ "test:coverage": "vitest run --coverage",
59
+ "release": "release-it",
60
+ "dev": "tsc -p tsconfig.json --watch"
61
61
  }
62
- }
62
+ }