@dforge-core/dforge-cli 0.2.6 → 0.2.8

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.
package/dist/cli.js CHANGED
@@ -909,13 +909,25 @@ function buildManifest(opts, moduleId) {
909
909
  }
910
910
  function buildEntity(entity) {
911
911
  const traits = entity.traits === "identity+audit" ? ["identity", "audit"] : ["identity"];
912
- return {
912
+ const built = {
913
913
  description: entity.label,
914
914
  dbObject: entity.name,
915
915
  toString: "{id}",
916
916
  traits,
917
917
  fields: {}
918
918
  };
919
+ if (entity.constraints?.length) {
920
+ built.constraints = Object.fromEntries(
921
+ entity.constraints.map((c) => {
922
+ const def = { type: c.type ?? "check" };
923
+ if (c.expression !== void 0) def.expression = c.expression;
924
+ if (c.fields !== void 0) def.fields = c.fields;
925
+ def.message = c.message;
926
+ return [c.name, def];
927
+ })
928
+ );
929
+ }
930
+ return built;
919
931
  }
920
932
  function buildDataViews(entities) {
921
933
  const views = {};
@@ -983,15 +995,50 @@ function buildSettings() {
983
995
  return {};
984
996
  }
985
997
  function buildTranslations(opts) {
986
- const t = {};
987
- t[`module.${opts.code}.label`] = opts.displayName;
988
- if (opts.description) t[`module.${opts.code}.description`] = opts.description;
998
+ const entities = {};
989
999
  for (const e2 of opts.entities) {
990
- t[`entity.${e2.name}.label`] = e2.label;
991
- t[`view.${e2.name}.label`] = e2.label;
992
- t[`menu.${e2.name}.label`] = e2.label;
1000
+ const fields = {
1001
+ // identity trait → primary key column
1002
+ [`${e2.name}_id`]: { label: `${e2.label} ID` }
1003
+ };
1004
+ if (e2.traits === "identity+audit") {
1005
+ fields.created_date = { label: "Created Date" };
1006
+ fields.last_updated = { label: "Last Updated" };
1007
+ }
1008
+ const entityEntry = { label: e2.label };
1009
+ if (opts.description && opts.entities.length === 1) {
1010
+ entityEntry.desc = opts.description;
1011
+ }
1012
+ entityEntry.fields = fields;
1013
+ if (e2.constraints?.length) {
1014
+ entityEntry.constraints = Object.fromEntries(
1015
+ e2.constraints.map((c) => [c.name, { message: c.message }])
1016
+ );
1017
+ }
1018
+ entities[e2.name] = entityEntry;
993
1019
  }
994
- return t;
1020
+ return {
1021
+ entities,
1022
+ folders: {
1023
+ // folders.json root folder key is the module code (see buildFolders).
1024
+ [opts.code]: { label: opts.displayName }
1025
+ },
1026
+ roles: {
1027
+ // Role labels are completeness-enforced in every locale incl. en-US.
1028
+ [`${opts.code}.admin`]: { label: `${opts.displayName} Administrator` }
1029
+ },
1030
+ views: Object.fromEntries(
1031
+ opts.entities.map((e2) => [e2.name, { label: e2.label }])
1032
+ ),
1033
+ menus: {
1034
+ [`${opts.code}_menu`]: {
1035
+ label: opts.displayName,
1036
+ items: Object.fromEntries(
1037
+ opts.entities.map((e2) => [e2.name, { label: e2.label }])
1038
+ )
1039
+ }
1040
+ }
1041
+ };
995
1042
  }
996
1043
  function buildSeedData() {
997
1044
  return [];
package/dist/lib.d.mts CHANGED
@@ -1,9 +1,17 @@
1
1
  type Preset = "minimal" | "minimal-plus" | "full";
2
2
  type Traits = "identity" | "identity+audit";
3
+ interface ConstraintSpec {
4
+ name: string;
5
+ type?: "check" | "unique";
6
+ expression?: string;
7
+ fields?: string[];
8
+ message: string;
9
+ }
3
10
  interface EntitySpec {
4
11
  name: string;
5
12
  label: string;
6
13
  traits: Traits;
14
+ constraints?: ConstraintSpec[];
7
15
  }
8
16
  interface ScaffoldOpts {
9
17
  path: string;
@@ -41,6 +49,7 @@ interface Entity {
41
49
  toString: string;
42
50
  traits: string[];
43
51
  fields: Record<string, unknown>;
52
+ constraints?: Record<string, unknown>;
44
53
  }
45
54
  interface DataView {
46
55
  viewType: string;
@@ -59,10 +68,10 @@ declare function buildMenus(opts: ScaffoldOpts): Record<string, unknown>;
59
68
  declare function buildRoles(opts: ScaffoldOpts): Record<string, unknown>;
60
69
  declare function buildActions(): Record<string, unknown>;
61
70
  declare function buildSettings(): Record<string, unknown>;
62
- declare function buildTranslations(opts: ScaffoldOpts): Record<string, string>;
71
+ declare function buildTranslations(opts: ScaffoldOpts): Record<string, unknown>;
63
72
  declare function buildSeedData(): unknown[];
64
73
  declare function buildGitignore(): string;
65
74
  declare function buildVscodeSettings(): Record<string, unknown>;
66
75
  declare function buildZedSettings(): Record<string, unknown>;
67
76
 
68
- export { type DataView, type Entity, type EntitySpec, type Manifest, type Preset, type ScaffoldOpts, type Traits, buildActions, buildDataViews, buildEntity, buildFolders, buildGitignore, buildManifest, buildMenus, buildRoles, buildSeedData, buildSettings, buildTranslations, buildVscodeSettings, buildZedSettings };
77
+ export { type ConstraintSpec, type DataView, type Entity, type EntitySpec, type Manifest, type Preset, type ScaffoldOpts, type Traits, buildActions, buildDataViews, buildEntity, buildFolders, buildGitignore, buildManifest, buildMenus, buildRoles, buildSeedData, buildSettings, buildTranslations, buildVscodeSettings, buildZedSettings };
package/dist/lib.d.ts CHANGED
@@ -1,9 +1,17 @@
1
1
  type Preset = "minimal" | "minimal-plus" | "full";
2
2
  type Traits = "identity" | "identity+audit";
3
+ interface ConstraintSpec {
4
+ name: string;
5
+ type?: "check" | "unique";
6
+ expression?: string;
7
+ fields?: string[];
8
+ message: string;
9
+ }
3
10
  interface EntitySpec {
4
11
  name: string;
5
12
  label: string;
6
13
  traits: Traits;
14
+ constraints?: ConstraintSpec[];
7
15
  }
8
16
  interface ScaffoldOpts {
9
17
  path: string;
@@ -41,6 +49,7 @@ interface Entity {
41
49
  toString: string;
42
50
  traits: string[];
43
51
  fields: Record<string, unknown>;
52
+ constraints?: Record<string, unknown>;
44
53
  }
45
54
  interface DataView {
46
55
  viewType: string;
@@ -59,10 +68,10 @@ declare function buildMenus(opts: ScaffoldOpts): Record<string, unknown>;
59
68
  declare function buildRoles(opts: ScaffoldOpts): Record<string, unknown>;
60
69
  declare function buildActions(): Record<string, unknown>;
61
70
  declare function buildSettings(): Record<string, unknown>;
62
- declare function buildTranslations(opts: ScaffoldOpts): Record<string, string>;
71
+ declare function buildTranslations(opts: ScaffoldOpts): Record<string, unknown>;
63
72
  declare function buildSeedData(): unknown[];
64
73
  declare function buildGitignore(): string;
65
74
  declare function buildVscodeSettings(): Record<string, unknown>;
66
75
  declare function buildZedSettings(): Record<string, unknown>;
67
76
 
68
- export { type DataView, type Entity, type EntitySpec, type Manifest, type Preset, type ScaffoldOpts, type Traits, buildActions, buildDataViews, buildEntity, buildFolders, buildGitignore, buildManifest, buildMenus, buildRoles, buildSeedData, buildSettings, buildTranslations, buildVscodeSettings, buildZedSettings };
77
+ export { type ConstraintSpec, type DataView, type Entity, type EntitySpec, type Manifest, type Preset, type ScaffoldOpts, type Traits, buildActions, buildDataViews, buildEntity, buildFolders, buildGitignore, buildManifest, buildMenus, buildRoles, buildSeedData, buildSettings, buildTranslations, buildVscodeSettings, buildZedSettings };
package/dist/lib.js CHANGED
@@ -64,13 +64,25 @@ function buildManifest(opts, moduleId) {
64
64
  }
65
65
  function buildEntity(entity) {
66
66
  const traits = entity.traits === "identity+audit" ? ["identity", "audit"] : ["identity"];
67
- return {
67
+ const built = {
68
68
  description: entity.label,
69
69
  dbObject: entity.name,
70
70
  toString: "{id}",
71
71
  traits,
72
72
  fields: {}
73
73
  };
74
+ if (entity.constraints?.length) {
75
+ built.constraints = Object.fromEntries(
76
+ entity.constraints.map((c) => {
77
+ const def = { type: c.type ?? "check" };
78
+ if (c.expression !== void 0) def.expression = c.expression;
79
+ if (c.fields !== void 0) def.fields = c.fields;
80
+ def.message = c.message;
81
+ return [c.name, def];
82
+ })
83
+ );
84
+ }
85
+ return built;
74
86
  }
75
87
  function buildDataViews(entities) {
76
88
  const views = {};
@@ -138,15 +150,50 @@ function buildSettings() {
138
150
  return {};
139
151
  }
140
152
  function buildTranslations(opts) {
141
- const t = {};
142
- t[`module.${opts.code}.label`] = opts.displayName;
143
- if (opts.description) t[`module.${opts.code}.description`] = opts.description;
153
+ const entities = {};
144
154
  for (const e of opts.entities) {
145
- t[`entity.${e.name}.label`] = e.label;
146
- t[`view.${e.name}.label`] = e.label;
147
- t[`menu.${e.name}.label`] = e.label;
155
+ const fields = {
156
+ // identity trait → primary key column
157
+ [`${e.name}_id`]: { label: `${e.label} ID` }
158
+ };
159
+ if (e.traits === "identity+audit") {
160
+ fields.created_date = { label: "Created Date" };
161
+ fields.last_updated = { label: "Last Updated" };
162
+ }
163
+ const entityEntry = { label: e.label };
164
+ if (opts.description && opts.entities.length === 1) {
165
+ entityEntry.desc = opts.description;
166
+ }
167
+ entityEntry.fields = fields;
168
+ if (e.constraints?.length) {
169
+ entityEntry.constraints = Object.fromEntries(
170
+ e.constraints.map((c) => [c.name, { message: c.message }])
171
+ );
172
+ }
173
+ entities[e.name] = entityEntry;
148
174
  }
149
- return t;
175
+ return {
176
+ entities,
177
+ folders: {
178
+ // folders.json root folder key is the module code (see buildFolders).
179
+ [opts.code]: { label: opts.displayName }
180
+ },
181
+ roles: {
182
+ // Role labels are completeness-enforced in every locale incl. en-US.
183
+ [`${opts.code}.admin`]: { label: `${opts.displayName} Administrator` }
184
+ },
185
+ views: Object.fromEntries(
186
+ opts.entities.map((e) => [e.name, { label: e.label }])
187
+ ),
188
+ menus: {
189
+ [`${opts.code}_menu`]: {
190
+ label: opts.displayName,
191
+ items: Object.fromEntries(
192
+ opts.entities.map((e) => [e.name, { label: e.label }])
193
+ )
194
+ }
195
+ }
196
+ };
150
197
  }
151
198
  function buildSeedData() {
152
199
  return [];
package/dist/lib.mjs CHANGED
@@ -26,13 +26,25 @@ function buildManifest(opts, moduleId) {
26
26
  }
27
27
  function buildEntity(entity) {
28
28
  const traits = entity.traits === "identity+audit" ? ["identity", "audit"] : ["identity"];
29
- return {
29
+ const built = {
30
30
  description: entity.label,
31
31
  dbObject: entity.name,
32
32
  toString: "{id}",
33
33
  traits,
34
34
  fields: {}
35
35
  };
36
+ if (entity.constraints?.length) {
37
+ built.constraints = Object.fromEntries(
38
+ entity.constraints.map((c) => {
39
+ const def = { type: c.type ?? "check" };
40
+ if (c.expression !== void 0) def.expression = c.expression;
41
+ if (c.fields !== void 0) def.fields = c.fields;
42
+ def.message = c.message;
43
+ return [c.name, def];
44
+ })
45
+ );
46
+ }
47
+ return built;
36
48
  }
37
49
  function buildDataViews(entities) {
38
50
  const views = {};
@@ -100,15 +112,50 @@ function buildSettings() {
100
112
  return {};
101
113
  }
102
114
  function buildTranslations(opts) {
103
- const t = {};
104
- t[`module.${opts.code}.label`] = opts.displayName;
105
- if (opts.description) t[`module.${opts.code}.description`] = opts.description;
115
+ const entities = {};
106
116
  for (const e of opts.entities) {
107
- t[`entity.${e.name}.label`] = e.label;
108
- t[`view.${e.name}.label`] = e.label;
109
- t[`menu.${e.name}.label`] = e.label;
117
+ const fields = {
118
+ // identity trait → primary key column
119
+ [`${e.name}_id`]: { label: `${e.label} ID` }
120
+ };
121
+ if (e.traits === "identity+audit") {
122
+ fields.created_date = { label: "Created Date" };
123
+ fields.last_updated = { label: "Last Updated" };
124
+ }
125
+ const entityEntry = { label: e.label };
126
+ if (opts.description && opts.entities.length === 1) {
127
+ entityEntry.desc = opts.description;
128
+ }
129
+ entityEntry.fields = fields;
130
+ if (e.constraints?.length) {
131
+ entityEntry.constraints = Object.fromEntries(
132
+ e.constraints.map((c) => [c.name, { message: c.message }])
133
+ );
134
+ }
135
+ entities[e.name] = entityEntry;
110
136
  }
111
- return t;
137
+ return {
138
+ entities,
139
+ folders: {
140
+ // folders.json root folder key is the module code (see buildFolders).
141
+ [opts.code]: { label: opts.displayName }
142
+ },
143
+ roles: {
144
+ // Role labels are completeness-enforced in every locale incl. en-US.
145
+ [`${opts.code}.admin`]: { label: `${opts.displayName} Administrator` }
146
+ },
147
+ views: Object.fromEntries(
148
+ opts.entities.map((e) => [e.name, { label: e.label }])
149
+ ),
150
+ menus: {
151
+ [`${opts.code}_menu`]: {
152
+ label: opts.displayName,
153
+ items: Object.fromEntries(
154
+ opts.entities.map((e) => [e.name, { label: e.label }])
155
+ )
156
+ }
157
+ }
158
+ };
112
159
  }
113
160
  function buildSeedData() {
114
161
  return [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dforge-core/dforge-cli",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "dForge CLI - validate, pack, publish, and install dForge modules. Distributes a single-file native binary per platform via optionalDependencies (esbuild-style).",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/iash44/dForge-core",
@@ -41,11 +41,11 @@
41
41
  "typescript": "^6.0.3"
42
42
  },
43
43
  "optionalDependencies": {
44
- "@dforge-core/dforge-cli-darwin-arm64": "0.2.6",
45
- "@dforge-core/dforge-cli-darwin-x64": "0.2.6",
46
- "@dforge-core/dforge-cli-linux-arm64": "0.2.6",
47
- "@dforge-core/dforge-cli-linux-x64": "0.2.6",
48
- "@dforge-core/dforge-cli-win32-arm64": "0.2.6",
49
- "@dforge-core/dforge-cli-win32-x64": "0.2.6"
44
+ "@dforge-core/dforge-cli-darwin-arm64": "0.2.8",
45
+ "@dforge-core/dforge-cli-darwin-x64": "0.2.8",
46
+ "@dforge-core/dforge-cli-linux-arm64": "0.2.8",
47
+ "@dforge-core/dforge-cli-linux-x64": "0.2.8",
48
+ "@dforge-core/dforge-cli-win32-arm64": "0.2.8",
49
+ "@dforge-core/dforge-cli-win32-x64": "0.2.8"
50
50
  }
51
51
  }