@dwtechs/antity-pgsql 0.9.1 → 0.10.0

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/README.md CHANGED
@@ -62,11 +62,11 @@ const entity = new SQLEntity("consumers", [
62
62
  type: "integer",
63
63
  min: 0,
64
64
  max: 120,
65
- typeCheck: true,
66
- filter: true,
67
- need: ["PUT"],
65
+ isTypeChecked: true,
66
+ isFilterable: true,
67
+ requiredFor: ["PUT"],
68
68
  operations: ["SELECT", "UPDATE"],
69
- send: true,
69
+ isPrivate: false,
70
70
  sanitizer: null,
71
71
  normalizer: null,
72
72
  validator: null,
@@ -76,11 +76,11 @@ const entity = new SQLEntity("consumers", [
76
76
  type: "string",
77
77
  min: 0,
78
78
  max: 255,
79
- typeCheck: true,
80
- filter: false,
81
- need: ["POST", "PUT"],
79
+ isTypeChecked: true,
80
+ isFilterable: false,
81
+ requiredFor: ["POST", "PUT"],
82
82
  operations: ["SELECT", "UPDATE"],
83
- send: true,
83
+ isPrivate: false,
84
84
  sanitizer: null,
85
85
  normalizer: normalizeName,
86
86
  validator: null,
@@ -90,11 +90,11 @@ const entity = new SQLEntity("consumers", [
90
90
  type: "string",
91
91
  min: 0,
92
92
  max: 255,
93
- typeCheck: true,
94
- filter: false,
95
- need: ["POST", "PUT"],
93
+ isTypeChecked: true,
94
+ isFilterable: false,
95
+ requiredFor: ["POST", "PUT"],
96
96
  operations: ["SELECT", "UPDATE"],
97
- send: true,
97
+ isPrivate: false,
98
98
  sanitizer: null,
99
99
  normalizer: normalizeName,
100
100
  validator: null,
@@ -104,11 +104,11 @@ const entity = new SQLEntity("consumers", [
104
104
  type: "string",
105
105
  min: 0,
106
106
  max: 255,
107
- typeCheck: true,
108
- filter: true,
109
- need: ["POST", "PUT"],
107
+ isTypeChecked: true,
108
+ isFilterable: true,
109
+ requiredFor: ["POST", "PUT"],
110
110
  operations: ["SELECT", "UPDATE"],
111
- send: true,
111
+ isPrivate: false,
112
112
  sanitizer: null,
113
113
  normalizer: normalizeNickname,
114
114
  validator: null,
@@ -125,10 +125,10 @@ router.put("/", ...entity.updateArraySubstack);
125
125
  router.post("/manual", entity.normalizeArray, entity.validateArray, ..., entity.add);
126
126
  router.put("/manual", entity.normalizeArray, entity.validateArray, ..., entity.update);
127
127
 
128
- router.put("/archive", ..., entity.archive);
128
+ router.patch("/archive", ..., entity.archive);
129
129
  router.delete("/", ..., entity.delete);
130
130
  router.delete("/archived", ..., entity.deleteArchive);
131
- router.get("/history", ..., entity.getHistory);
131
+ router.get("/:id/history", ..., entity.getHistory);
132
132
 
133
133
  ```
134
134
 
@@ -175,7 +175,7 @@ class SQLEntity {
175
175
  get name(): string;
176
176
  get table(): string;
177
177
  get schema(): string;
178
- get unsafeProps(): string[];
178
+ get privateProps(): string[];
179
179
  get properties(): Property[];
180
180
  set name(name: string);
181
181
  set table(table: string);
@@ -360,10 +360,10 @@ Any of these can be passed into the options object for each function.
360
360
  | type | Type | Type of the property |
361
361
  | min | number \| Date | Minimum value | 0 \| 1900-01-01
362
362
  | max | number \| Date | Maximum value | 999999999 \| 2200-12-31
363
- | need | Method[] | property is validated for the listed methods only | ["PATCH", "PUT", "POST"]
364
- | send | boolean | Property is sent in the response | true
365
- | typeCheck | boolean | Type is checked during validation | false
366
- | filter | boolean | property is filterable in a SELECT operation | true
363
+ | requiredFor | Method[] | property is required for the listed methods only | ["PATCH", "PUT", "POST"]
364
+ | isPrivate | boolean | Property is unsafe to send in the response | true
365
+ | isTypeChecked | boolean | Type is checked during validation | false
366
+ | isFilterable | boolean | property is filterable in a SELECT operation | true
367
367
  | operations | Operation[] | Property is used for the DML operations only | ["SELECT", "INSERT", "UPDATE"]
368
368
  | sanitizer | ((v:any) => any) \| null | Custom sanitizer function if sanitize is true | null
369
369
  | normalizer | ((v:any) => any) \| null | Custom Normalizer function if normalize is true | null
@@ -49,10 +49,10 @@ export declare class Property extends BaseProperty {
49
49
  type: Type,
50
50
  min: number | Date | null,
51
51
  max: number | Date | null,
52
- need: Method[],
53
- send: boolean,
54
- typeCheck: boolean,
55
- filter: boolean,
52
+ requiredFor: Method[],
53
+ isPrivate: boolean,
54
+ isTypeChecked: boolean,
55
+ isFilterable: boolean,
56
56
  operations: Operation[] | undefined,
57
57
  sanitizer: ((v: unknown) => unknown) | null,
58
58
  normalizer: ((v: unknown) => unknown) | null,
@@ -459,7 +459,7 @@ function cleanFilters(filters, properties) {
459
459
  delete filters[k];
460
460
  continue;
461
461
  }
462
- if (!prop.filter) {
462
+ if (!prop.isFilterable) {
463
463
  log.warn(`${LOGS_PREFIX}Filters: skipping unfilterable property: ${k}`);
464
464
  delete filters[k];
465
465
  continue;
@@ -497,10 +497,10 @@ function generateSummary(name, table, properties) {
497
497
  lines.push(`│ │ ├─ Type: ${p.type}`);
498
498
  lines.push(`│ │ ├─ Min: ${p.min}`);
499
499
  lines.push(`│ │ ├─ Max: ${p.max}`);
500
- lines.push(`│ │ ├─ need: ${p.need}`);
501
- lines.push(`│ │ ├─ Safe: ${p.safe}`);
502
- lines.push(`│ │ ├─ TypeCheck: ${p.typeCheck}`);
503
- lines.push(`│ │ ├─ Filter: ${p.filter}`);
500
+ lines.push(`│ │ ├─ RequiredFor: ${p.requiredFor}`);
501
+ lines.push(`│ │ ├─ IsPrivate: ${p.isPrivate}`);
502
+ lines.push(`│ │ ├─ IsTypeChecked: ${p.isTypeChecked}`);
503
+ lines.push(`│ │ ├─ IsFilterable: ${p.isFilterable}`);
504
504
  lines.push(`│ │ ├─ Operations: [${p.operations.join(', ')}]`);
505
505
  lines.push(`│ │ ├─ Sanitize: ${p.sanitize}`);
506
506
  lines.push(`│ │ ├─ Normalize: ${p.normalize}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dwtechs/antity-pgsql",
3
- "version": "0.9.1",
3
+ "version": "0.10.0",
4
4
  "description": "Open source library to add PostgreSQL support to @dwtechs/Antity entities.",
5
5
  "keywords": [
6
6
  "entities"
@@ -38,7 +38,7 @@
38
38
  "dependencies": {
39
39
  "@dwtechs/checkard": "3.6.0",
40
40
  "@dwtechs/winstan": "0.5.0",
41
- "@dwtechs/antity": "0.15.0",
41
+ "@dwtechs/antity": "0.16.0",
42
42
  "@dwtechs/sparray": "0.2.1",
43
43
  "pg": "8.13.1"
44
44
  },