backend-plus 2.7.0-beta.1 → 2.7.0-beta.3

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.
@@ -188,3 +188,14 @@ animation-time = 2s
188
188
  font-color gray
189
189
  margin-right 2px
190
190
  min-width 4em
191
+
192
+ .point
193
+ &::before
194
+ content '('
195
+ opacity 0.5
196
+ &::after
197
+ content ')'
198
+ opacity 0.5
199
+ .comma
200
+ opacity 0.5
201
+ padding-right 0.2em
@@ -2266,7 +2266,9 @@ myOwn.TableGrid.prototype.createRowInsertElements = function createRowInsertElem
2266
2266
  }
2267
2267
  if(value!==null){
2268
2268
  depotForInsert.row[fieldDef.name] = value;
2269
- depotForInsert.rowPendingForUpdate[fieldDef.name] = value;
2269
+ if (fieldDef.inTable) {
2270
+ depotForInsert.rowPendingForUpdate[fieldDef.name] = value;
2271
+ }
2270
2272
  }
2271
2273
  });
2272
2274
  //TODO: mejorar la posición dentro del splice o concluir que no sirve el splice
@@ -1,5 +1,7 @@
1
1
  declare module "backend-plus"{
2
2
 
3
+ type RequireSome<T, K extends keyof T> = T & Required<Pick<T, K>>;
4
+
3
5
  import * as net from "net";
4
6
  import * as express from "express";
5
7
  import {Client} from "pg-promise-strict";
@@ -167,7 +169,7 @@ export interface TableContext extends Context{
167
169
  superuser?:true
168
170
  forDump?:boolean
169
171
  }
170
- export type PgKnownTypes='decimal'|'text'|'boolean'|'integer'|'bigint'|'date'|'interval'|'timestamp'|'jsonb'|'double'|'bytea'|'jsona'|'time'|'tsrange'|'time_range'|'daterange'|'time_multirange';
172
+ export type PgKnownTypes='decimal'|'text'|'boolean'|'integer'|'bigint'|'date'|'interval'|'timestamp'|'jsonb'|'double'|'bytea'|'jsona'|'time'|'tsrange'|'time_range'|'daterange'|'time_multirange'|'gpoint'|'point';
171
173
  export type PgKnownDbValues='current_timestamp'|'current_user'|'session_user';
172
174
  export type SequenceDefinition = {
173
175
  name:string
@@ -227,6 +229,11 @@ export interface FieldDefinition extends EditableDbDefinition {
227
229
  sequence?: SequenceDefinition|SequenceMadMaxDefinition
228
230
  format?: string
229
231
  }
232
+ export type FieldDefinitionInternal = RequireSome<FieldDefinition, 'allow'> & {
233
+ isPk:number|null
234
+ tableName:string
235
+ table:string
236
+ }
230
237
  export interface EditableDbDefinition {
231
238
  editable?:boolean
232
239
  allow?:{
@@ -344,8 +351,14 @@ export type TableDefinition = EditableDbDefinition & {
344
351
  parameters?:ProcedureParameter[]
345
352
  }
346
353
  }
354
+ export type TableDefinitionInternal = RequireSome<TableDefinition,
355
+ 'allow'|'sql'
356
+ > & {
357
+ field:Record<string, FieldDefinitionInternal>
358
+ otherTableDefs:Record<string, TableDefinitionInternal>
359
+ }
347
360
  export interface DetailTable { table?: string, fields: FieldsForConnectDetailTable, abr: string, label?: string, refreshParent?:boolean, refreshFromParent?:boolean, wScreen?:string, condition?:string }
348
- export type TableDefinitionFunction = (context: ContextForDump, opts?:any) => TableDefinition;
361
+ export type TableDefinitionFunction = (context: ContextForDump, opts?:any) => TableDefinitionInternal;
349
362
  export type TableItemDef=string|{name:string, path?:string, tableGenerator?:(context:TableContext)=>TableDefinition}
350
363
  // {{name: string; path?:string; fileName?: string; source?: string; tableGenerator?:()=>void; title?:string; mixin?:any[]}} TableItem
351
364
  export interface TableDefinitions {
@@ -602,6 +615,8 @@ export class AppBackend{
602
615
  setLog(opts:{until:string, results?:boolean}):void
603
616
  getDataDumpTransformations(rawData:string):Promise<{rawData:string, prepareTransformationSql:string[], endTransformationSql:string[]}>
604
617
  activeSkinFiles: Set<string>
618
+ /****** internals: */
619
+ transformInput:<T>(fieldDefinition: FieldDefinitionInternal, value:T) => T
605
620
  }
606
621
 
607
622
  }
@@ -1032,6 +1032,7 @@ AppBackend.prototype.start = function start(opts){
1032
1032
  console.log(err);
1033
1033
  throw err;
1034
1034
  }
1035
+ await pg.setAllTypes(client);
1035
1036
  var data = await client.query("SELECT current_timestamp as cts").fetchUniqueRow();
1036
1037
  if(verboseStartup){
1037
1038
  console.log('NOW in Database',data.row.cts);
@@ -3611,9 +3612,12 @@ AppBackend.prototype.dumpDbSchema = async function dumpDbSchema(opts){
3611
3612
  )
3612
3613
  mainSql=be.config.install.dump.db.extensions.map(function(extension){
3613
3614
  return ({
3614
- gist: "create extension if not exists btree_gist;",
3615
- pg_trgm: "create extension if not exists pg_trgm;",
3616
- pgcrypto: "create extension if not exists pgcrypto;"
3615
+ cube : "create extension if not exists cube ;",
3616
+ earthdistance : "create extension if not exists earthdistance ;",
3617
+ gist : "create extension if not exists btree_gist ;",
3618
+ pg_trgm : "create extension if not exists pg_trgm ;",
3619
+ pgcrypto : "create extension if not exists pgcrypto ;",
3620
+ postgis : "create extension if not exists postgis ;",
3617
3621
  }[extension]||('--unknown exension '+extension))+'\n';
3618
3622
  }).join('')+mainSql;
3619
3623
  await fs.writeFile('local-db-dump.sql', mainSql);
@@ -13,6 +13,9 @@ const bestGlobals = require('best-globals');
13
13
 
14
14
  const PANIC_IMPORT = true;
15
15
 
16
+ /** @import { TableDefinitionInternal, ProcedureContext } from './in-backend-plus' */
17
+
18
+
16
19
  var ProcedureTables;
17
20
 
18
21
  /** @type {<T>(x:T)=>NonNullable<T>} */
@@ -21,6 +24,9 @@ var notnull = x =>{
21
24
  return x;
22
25
  };
23
26
 
27
+ /**
28
+ * @param {any} mmm
29
+ */
24
30
  function inlineLog(mmm){ console.log(mmm); return mmm; }
25
31
 
26
32
  ProcedureTables = [
@@ -189,9 +195,18 @@ ProcedureTables = [
189
195
  {name: 'oldRow'},
190
196
  {name: 'status', encoding:'plain'},
191
197
  ],
198
+ /**
199
+ *
200
+ * @param {ProcedureContext} context
201
+ * @param {*} parameters
202
+ * @param {*} files
203
+ * @param {*} opts
204
+ * @returns
205
+ */
192
206
  coreFunction:async function(context, parameters, files, opts){
193
207
  var be=context.be;
194
208
  var mainDefTable=be.tableStructures[parameters.table](context);
209
+ /** @type {'insert'|'update'} */
195
210
  var action=parameters.status=='new'?'insert':'update';
196
211
  if(!mainDefTable.allow[action] && (!opts || !opts.forImport)){
197
212
  throw changing(new Error(action+" not allowed"),{status:403});
@@ -254,6 +269,7 @@ ProcedureTables = [
254
269
  var updates = updatesOthers.filter(u => !u.defTable.saveAfter)
255
270
  .concat(plainUpdate.values.length?[changing({defTable:mainDefTable,main:true},plainUpdate)]:[])
256
271
  .concat(updatesOthers.filter(u => u.defTable.saveAfter));
272
+ /** @type {Record<string, any>} */
257
273
  var globalPrimaryKeyValue={}
258
274
  mainDefTable.primaryKey.forEach(function(name,i){
259
275
  globalPrimaryKeyValue[name]=parameters.primaryKeyValues[i];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "backend-plus",
3
3
  "description": "Backend for the anti Pareto rule",
4
- "version": "2.7.0-beta.1",
4
+ "version": "2.7.0-beta.3",
5
5
  "author": "Codenautas <codenautas@googlegroups.com>",
6
6
  "license": "MIT",
7
7
  "repository": "codenautas/backend-plus",
@@ -46,9 +46,9 @@
46
46
  "ensure-login": "^0.1.6-beta.0",
47
47
  "express": "^5.2.1",
48
48
  "express-useragent": "^2.2.1",
49
- "fs-extra": "^11.3.6",
49
+ "fs-extra": "^11.4.0",
50
50
  "js-to-html": "^1.3.6",
51
- "js-yaml": "^5.2.1",
51
+ "js-yaml": "^5.2.2",
52
52
  "json4all": "^1.4.4",
53
53
  "lazy-some": "^0.1.0",
54
54
  "like-ar": "^0.5.3",
@@ -59,7 +59,7 @@
59
59
  "multiparty": "^4.3.0",
60
60
  "nodemailer": "^9.0.3",
61
61
  "numeral": "^2.0.6",
62
- "pg-promise-strict": "^1.4.6",
62
+ "pg-promise-strict": "^1.5.0",
63
63
  "pg-triggers": "0.4.6",
64
64
  "pikaday": "^1.8.2",
65
65
  "require-bro": "^0.3.6",
@@ -68,46 +68,46 @@
68
68
  "simple-git": "^3.36.0",
69
69
  "sql-tools": "^0.1.7",
70
70
  "stack-trace": "^1.0.0",
71
- "type-store": "^0.5.2",
72
- "typed-controls": "^0.12.6",
71
+ "type-store": "^0.6.0",
72
+ "typed-controls": "^0.12.7",
73
73
  "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@types/big.js": "^7.0.0",
77
- "@types/expect.js": "~0.3.32",
77
+ "@types/expect.js": "^0.3.32",
78
78
  "@types/express": "^5.0.6",
79
79
  "@types/express-useragent": "^1.0.5",
80
80
  "@types/fs-extra": "^11.0.4",
81
81
  "@types/js-yaml": "^4.0.9",
82
82
  "@types/mocha": "^10.0.10",
83
- "@types/multiparty": "~4.2.1",
84
- "@types/node": "^26.1.0",
83
+ "@types/multiparty": "^4.2.1",
84
+ "@types/node": "^26.1.1",
85
85
  "@types/nodemailer": "^8.0.1",
86
86
  "@types/numeral": "~2.0.5",
87
87
  "@types/session-file-store": "^1.2.6",
88
- "@types/stack-trace": "~0.0.33",
88
+ "@types/stack-trace": "^0.0.33",
89
89
  "@types/websql": "~0.0.30",
90
90
  "backend-skins": "^0.1.34",
91
91
  "discrepances": "^0.2.14",
92
92
  "esprima": "^4.0.1",
93
- "expect.js": "~0.3.1",
93
+ "expect.js": "^0.3.1",
94
94
  "karma": "6.4.4",
95
95
  "karma-chrome-launcher": "^3.2.0",
96
96
  "karma-expect": "^1.1.3",
97
97
  "karma-firefox-launcher": "^2.1.3",
98
98
  "karma-ie-launcher": "^1.0.0",
99
99
  "karma-mocha": "^2.0.1",
100
- "kill-9": "~0.4.3",
100
+ "kill-9": "^0.4.3",
101
101
  "mocha": "^11.7.6",
102
102
  "nyc": "^18.0.0",
103
103
  "puppeteer": "^25.3.0",
104
104
  "qa-control": "0.7.5",
105
105
  "regexplicit": "^0.1.3",
106
106
  "self-explain": "^0.11.0",
107
- "sinon": "^22.0.0",
107
+ "sinon": "^22.1.0",
108
108
  "supertest": "^7.2.2",
109
- "types.d.ts": "~0.6.22",
110
- "typescript": "^5.9.3",
109
+ "types.d.ts": "^0.6.22",
110
+ "typescript": "^7.0.2",
111
111
  "why-is-node-running": "^3.2.2"
112
112
  },
113
113
  "engines": {