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.
- package/dist/DboBuilder.d.ts.map +1 -1
- package/dist/DboBuilder.js +13 -12
- package/dist/DboBuilder.js.map +1 -1
- package/dist/Prostgles.d.ts +1 -15
- package/dist/Prostgles.d.ts.map +1 -1
- package/dist/Prostgles.js +2 -2
- package/dist/Prostgles.js.map +1 -1
- package/dist/QueryBuilder.d.ts.map +1 -1
- package/dist/QueryBuilder.js +7 -3
- package/dist/QueryBuilder.js.map +1 -1
- package/dist/TableConfig.d.ts +10 -6
- package/dist/TableConfig.d.ts.map +1 -1
- package/lib/DboBuilder.ts +12 -11
- package/lib/Prostgles.ts +13 -14
- package/lib/QueryBuilder.ts +11 -3
- package/lib/TableConfig.ts +7 -7
- package/package.json +1 -1
- package/tests/client/PID.txt +1 -1
- package/tests/server/index.js +34 -28
- package/tests/server/index.ts +36 -28
- package/tests/server/media/{0abdd619-dfbd-473e-b176-2ece60602c65.txt → 58dd3a25-4911-4323-b3db-2dbecee232b3.txt} +0 -0
- package/tests/server/media/{3476c222-6348-4308-a57a-4090a9f33963.txt → 6654bd13-8c60-4613-884f-b4ee07897220.txt} +0 -0
- package/tests/server/media/{71cc5f6b-65d4-4741-a6eb-37b6109c08fc.txt → c4015a47-2a55-41f5-be12-c2a5cc3e91a1.txt} +0 -0
- package/tests/server/media/{792725ea-703f-4b64-b385-8d462d0efe60.txt → e8be50b2-c833-48f9-a320-a071bfe179c1.txt} +0 -0
- package/tests/server/package-lock.json +1 -1
package/lib/TableConfig.ts
CHANGED
|
@@ -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
|
|
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
package/tests/client/PID.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
19221
|
package/tests/server/index.js
CHANGED
|
@@ -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
|
{
|
package/tests/server/index.ts
CHANGED
|
@@ -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
|
{
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|