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

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.
@@ -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";
@@ -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
  }
@@ -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.2",
5
5
  "author": "Codenautas <codenautas@googlegroups.com>",
6
6
  "license": "MIT",
7
7
  "repository": "codenautas/backend-plus",