prostgles-server 2.0.57 → 2.0.61

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.
@@ -25,13 +25,13 @@ type LookupTableDefinition<LANG_IDS> = {
25
25
  }
26
26
  }
27
27
 
28
- type BaseColumn = {
28
+ type BaseColumn<LANG_IDS> = {
29
29
  /**
30
30
  * Will add these values to .getColumns() result
31
31
  */
32
32
  info?: ColExtraInfo;
33
33
 
34
-
34
+ label?: string | Partial<{ [lang_id in keyof LANG_IDS]: string; }>;
35
35
  }
36
36
 
37
37
  type SQLDefColumn = {
@@ -79,11 +79,11 @@ type NamedJoinColumn = {
79
79
  joinDef: JoinDef[];
80
80
  }
81
81
 
82
- type ColumnConfig = NamedJoinColumn | (BaseColumn & (SQLDefColumn | ReferencedColumn))
82
+ type ColumnConfig<LANG_IDS= { en: 1 }> = NamedJoinColumn | (BaseColumn<LANG_IDS> & (SQLDefColumn | ReferencedColumn))
83
83
 
84
- type TableDefinition = {
84
+ type TableDefinition<LANG_IDS> = {
85
85
  columns: {
86
- [column_name: string]: ColumnConfig
86
+ [column_name: string]: ColumnConfig<LANG_IDS>
87
87
  },
88
88
  constraints?: {
89
89
  [constraint_name: string]: string
@@ -93,8 +93,8 @@ type TableDefinition = {
93
93
  /**
94
94
  * Helper utility to create lookup tables for TEXT columns
95
95
  */
96
- export type TableConfig<LANG_IDS = { en: 1, ro: 1 }> = {
97
- [table_name: string]: BaseTableDefinition & (TableDefinition | LookupTableDefinition<LANG_IDS>);
96
+ export type TableConfig<LANG_IDS = { en: 1 }> = {
97
+ [table_name: string]: BaseTableDefinition & (TableDefinition<LANG_IDS> | LookupTableDefinition<LANG_IDS>);
98
98
  }
99
99
 
100
100
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prostgles-server",
3
- "version": "2.0.57",
3
+ "version": "2.0.61",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1 +1 @@
1
- 10092
1
+ 19221
@@ -60,6 +60,39 @@ const dbConnection = {
60
60
  }
61
61
  };
62
62
  log("created prostgles");
63
+ const tableConfig = {
64
+ tr2: {
65
+ columns: {
66
+ t1: { label: { fr: "fr_t1" } },
67
+ t2: { label: { en: "en_t2" } },
68
+ }
69
+ },
70
+ lookup_col1: {
71
+ dropIfExists: true,
72
+ isLookupTable: {
73
+ values: {
74
+ a: {},
75
+ b: {}
76
+ },
77
+ }
78
+ },
79
+ uuid_text: {
80
+ columns: {
81
+ col1: {
82
+ references: {
83
+ tableName: "lookup_col1",
84
+ nullable: true,
85
+ }
86
+ },
87
+ col2: {
88
+ references: {
89
+ tableName: "lookup_col1",
90
+ nullable: true,
91
+ }
92
+ }
93
+ }
94
+ }
95
+ };
63
96
  let prgl = await (0, prostgles_server_1.default)({
64
97
  dbConnection,
65
98
  sqlFilePath: path_1.default.join(__dirname + '/init.sql'),
@@ -69,33 +102,7 @@ const dbConnection = {
69
102
  transactions: true,
70
103
  // DEBUG_MODE: true,
71
104
  // onNotice: console.log,
72
- tableConfig: {
73
- lookup_col1: {
74
- dropIfExists: true,
75
- isLookupTable: {
76
- values: {
77
- a: {},
78
- b: {}
79
- },
80
- }
81
- },
82
- uuid_text: {
83
- columns: {
84
- col1: {
85
- references: {
86
- tableName: "lookup_col1",
87
- nullable: true,
88
- }
89
- },
90
- col2: {
91
- references: {
92
- tableName: "lookup_col1",
93
- nullable: true,
94
- }
95
- }
96
- }
97
- }
98
- },
105
+ tableConfig,
99
106
  fileTable: {
100
107
  // awsS3Config: {
101
108
  // accessKeyId: process.env.S3_KEY,
@@ -268,7 +275,6 @@ const dbConnection = {
268
275
  // }
269
276
  // };
270
277
  },
271
- i18n,
272
278
  // joins: "inferred",
273
279
  joins: [
274
280
  {
@@ -18,6 +18,7 @@ import server_only_queries from "../server_only_queries";
18
18
  import { DBObj, I18N_DBO_CONFIG } from "./DBoGenerated";
19
19
  // type DBObj = any;
20
20
  import { DB, DbHandler } from 'prostgles-server/dist/Prostgles';
21
+ import { TableConfig } from '../../dist/TableConfig';
21
22
 
22
23
  const log = (msg: string, extra?: any, trace?: boolean) => {
23
24
  const msgs = ["(server): " + msg, extra].filter(v => v);
@@ -75,6 +76,40 @@ const dbConnection = {
75
76
  }
76
77
 
77
78
  log("created prostgles")
79
+ const tableConfig: TableConfig<{ en: 1, fr: 1 }> = {
80
+
81
+ tr2: {
82
+ columns: {
83
+ t1: { label: { fr: "fr_t1" } },
84
+ t2: { label: { en: "en_t2" } },
85
+ }
86
+ },
87
+ lookup_col1: {
88
+ dropIfExists: true,
89
+ isLookupTable: {
90
+ values: {
91
+ a: {},
92
+ b: {}
93
+ },
94
+ }
95
+ },
96
+ uuid_text: {
97
+ columns: {
98
+ col1: {
99
+ references: {
100
+ tableName: "lookup_col1",
101
+ nullable: true,
102
+ }
103
+ },
104
+ col2: {
105
+ references: {
106
+ tableName: "lookup_col1",
107
+ nullable: true,
108
+ }
109
+ }
110
+ }
111
+ }
112
+ }
78
113
  let prgl = await prostgles({
79
114
  dbConnection,
80
115
  sqlFilePath: path.join(__dirname+'/init.sql'),
@@ -85,33 +120,7 @@ const dbConnection = {
85
120
 
86
121
  // DEBUG_MODE: true,
87
122
  // onNotice: console.log,
88
- tableConfig: {
89
- lookup_col1: {
90
- dropIfExists: true,
91
- isLookupTable: {
92
- values: {
93
- a: {},
94
- b: {}
95
- },
96
- }
97
- },
98
- uuid_text: {
99
- columns: {
100
- col1: {
101
- references: {
102
- tableName: "lookup_col1",
103
- nullable: true,
104
- }
105
- },
106
- col2: {
107
- references: {
108
- tableName: "lookup_col1",
109
- nullable: true,
110
- }
111
- }
112
- }
113
- }
114
- },
123
+ tableConfig,
115
124
  fileTable: {
116
125
  // awsS3Config: {
117
126
  // accessKeyId: process.env.S3_KEY,
@@ -289,7 +298,6 @@ const dbConnection = {
289
298
  // }
290
299
  // };
291
300
  },
292
- i18n,
293
301
  // joins: "inferred",
294
302
  joins: [
295
303
  {
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "../..": {
25
25
  "name": "prostgles-server",
26
- "version": "2.0.56",
26
+ "version": "2.0.60",
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
29
  "@aws-sdk/client-s3": "^3.32.0",