node-firebird-native-api 3.1.2 → 3.1.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.
@@ -1,9 +1,9 @@
1
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
1
2
  require('source-map-support').install();
2
3
 
3
4
  import { generate, load } from 'node-cloop-gen';
4
5
  import { patch } from './patch';
5
6
 
6
-
7
7
  const root = process.cwd();
8
8
  const inputFile = `${root}/src/generate-files/firebird.cloop.json`;
9
9
  const outputCppNapi = `${root}/src/native/cloop-gen.h`;
@@ -14,8 +14,8 @@ const library = load(inputFile);
14
14
  patch(library);
15
15
 
16
16
  generate({
17
- library,
18
- outputCppNapi,
19
- outputTs,
20
- namespace: 'fb'
17
+ library,
18
+ outputCppNapi,
19
+ outputTs,
20
+ namespace: 'fb',
21
21
  });
@@ -1,229 +1,156 @@
1
1
  import { Library } from 'node-cloop-gen';
2
2
 
3
-
4
- interface InterfaceConfig
5
- {
6
- [intf: string]: {
7
- deleteMethods?: string[]
8
- };
9
- }
3
+ type InterfaceConfig = Record<string, { deleteMethods?: string[] }>;
10
4
 
11
5
  const interfaceConfig: InterfaceConfig = {
12
- Util: {
13
- deleteMethods: [
14
- 'dumpBlob',
15
- 'loadBlob',
16
- 'getPerfCounters',
17
- 'formatStatus'
18
- ]
19
- },
20
-
21
- Statement: {
22
- },
23
-
24
- Status: {
25
- deleteMethods: [
26
- 'getErrors',
27
- 'getWarnings',
28
- 'setErrors',
29
- 'setErrors2',
30
- 'setWarnings',
31
- 'setWarnings2'
32
- ]
33
- },
34
-
35
- Attachment: {
36
- deleteMethods: [
37
- 'getSlice',
38
- 'putSlice'
39
- ]
40
- },
41
-
42
- Transaction: {
43
- },
44
-
45
- Provider: {
46
- },
47
-
48
- CryptKey: {
49
- deleteMethods: [
50
- '*'
51
- ]
52
- },
53
-
54
- DbCryptPlugin: {
55
- deleteMethods: [
56
- '*'
57
- ]
58
- },
59
-
60
- ExternalEngine: {
61
- deleteMethods: [
62
- '*'
63
- ]
64
- },
65
-
66
- ExternalContext: {
67
- deleteMethods: [
68
- '*'
69
- ]
70
- },
71
-
72
- ExternalFunction: {
73
- deleteMethods: [
74
- '*'
75
- ]
76
- },
77
-
78
- ExternalProcedure: {
79
- deleteMethods: [
80
- '*'
81
- ]
82
- },
83
-
84
- ExternalTrigger: {
85
- deleteMethods: [
86
- '*'
87
- ]
88
- },
89
-
90
- TraceTransaction: {
91
- deleteMethods: [
92
- '*'
93
- ]
94
- },
95
-
96
- TraceParams: {
97
- deleteMethods: [
98
- '*'
99
- ]
100
- },
101
-
102
- TraceStatement: {
103
- deleteMethods: [
104
- '*'
105
- ]
106
- },
107
-
108
- TraceSQLStatement: {
109
- deleteMethods: [
110
- '*'
111
- ]
112
- },
113
-
114
- TraceBLRStatement: {
115
- deleteMethods: [
116
- '*'
117
- ]
118
- },
119
-
120
- TraceDYNRequest: {
121
- deleteMethods: [
122
- '*'
123
- ]
124
- },
125
-
126
- TraceContextVariable: {
127
- deleteMethods: [
128
- '*'
129
- ]
130
- },
131
-
132
- TraceProcedure: {
133
- deleteMethods: [
134
- '*'
135
- ]
136
- },
137
-
138
- TraceFunction: {
139
- deleteMethods: [
140
- '*'
141
- ]
142
- },
143
-
144
- TraceTrigger: {
145
- deleteMethods: [
146
- '*'
147
- ]
148
- },
149
-
150
- TraceServiceConnection: {
151
- deleteMethods: [
152
- '*'
153
- ]
154
- },
155
-
156
- TraceStatusVector: {
157
- deleteMethods: [
158
- '*'
159
- ]
160
- },
161
-
162
- TraceSweepInfo: {
163
- deleteMethods: [
164
- '*'
165
- ]
166
- },
167
-
168
- TraceLogWriter: {
169
- deleteMethods: [
170
- '*'
171
- ]
172
- },
173
-
174
- TraceInitInfo: {
175
- deleteMethods: [
176
- '*'
177
- ]
178
- },
179
-
180
- TracePlugin: {
181
- deleteMethods: [
182
- '*'
183
- ]
184
- },
185
-
186
- TraceFactory: {
187
- deleteMethods: [
188
- '*'
189
- ]
190
- }
191
- };
6
+ Util: {
7
+ deleteMethods: ['dumpBlob', 'loadBlob', 'getPerfCounters', 'formatStatus'],
8
+ },
9
+
10
+ Statement: {},
11
+
12
+ Status: {
13
+ deleteMethods: ['getErrors', 'getWarnings', 'setErrors', 'setErrors2', 'setWarnings', 'setWarnings2'],
14
+ },
15
+
16
+ Attachment: {
17
+ deleteMethods: ['getSlice', 'putSlice'],
18
+ },
19
+
20
+ Transaction: {},
21
+
22
+ Provider: {},
23
+
24
+ CryptKey: {
25
+ deleteMethods: ['*'],
26
+ },
27
+
28
+ DbCryptPlugin: {
29
+ deleteMethods: ['*'],
30
+ },
31
+
32
+ ExternalEngine: {
33
+ deleteMethods: ['*'],
34
+ },
35
+
36
+ ExternalContext: {
37
+ deleteMethods: ['*'],
38
+ },
39
+
40
+ ExternalFunction: {
41
+ deleteMethods: ['*'],
42
+ },
43
+
44
+ ExternalProcedure: {
45
+ deleteMethods: ['*'],
46
+ },
47
+
48
+ ExternalTrigger: {
49
+ deleteMethods: ['*'],
50
+ },
51
+
52
+ TraceTransaction: {
53
+ deleteMethods: ['*'],
54
+ },
192
55
 
56
+ TraceParams: {
57
+ deleteMethods: ['*'],
58
+ },
59
+
60
+ TraceStatement: {
61
+ deleteMethods: ['*'],
62
+ },
63
+
64
+ TraceSQLStatement: {
65
+ deleteMethods: ['*'],
66
+ },
67
+
68
+ TraceBLRStatement: {
69
+ deleteMethods: ['*'],
70
+ },
71
+
72
+ TraceDYNRequest: {
73
+ deleteMethods: ['*'],
74
+ },
75
+
76
+ TraceContextVariable: {
77
+ deleteMethods: ['*'],
78
+ },
79
+
80
+ TraceProcedure: {
81
+ deleteMethods: ['*'],
82
+ },
83
+
84
+ TraceFunction: {
85
+ deleteMethods: ['*'],
86
+ },
87
+
88
+ TraceTrigger: {
89
+ deleteMethods: ['*'],
90
+ },
91
+
92
+ TraceServiceConnection: {
93
+ deleteMethods: ['*'],
94
+ },
95
+
96
+ TraceStatusVector: {
97
+ deleteMethods: ['*'],
98
+ },
99
+
100
+ TraceSweepInfo: {
101
+ deleteMethods: ['*'],
102
+ },
103
+
104
+ TraceLogWriter: {
105
+ deleteMethods: ['*'],
106
+ },
107
+
108
+ TraceInitInfo: {
109
+ deleteMethods: ['*'],
110
+ },
111
+
112
+ TracePlugin: {
113
+ deleteMethods: ['*'],
114
+ },
115
+
116
+ TraceFactory: {
117
+ deleteMethods: ['*'],
118
+ },
119
+ };
193
120
 
194
121
  export function patch(library: Library) {
195
- for (const intfName in interfaceConfig) {
196
- if (!interfaceConfig.hasOwnProperty(intfName))
197
- continue;
198
-
199
- const intf = library.interfacesByName[intfName];
200
- const config = interfaceConfig[intfName];
201
-
202
- for (const deleteMethod of config.deleteMethods || []) {
203
- const methods = intf.methods;
204
- let found = false;
205
-
206
- for (const [index, method] of methods.entries()) {
207
- if (deleteMethod == '*') {
208
- methods.splice(0);
209
- found = true;
210
- }
211
- else if (method.name == deleteMethod) {
212
- methods.splice(index, 1);
213
- found = true;
214
- break;
215
- }
216
- }
217
-
218
- if (!found) {
219
- console.error(`Method '${intfName}#${deleteMethod}' not found for deletion.`);
220
- process.exit(1);
221
- }
222
- }
223
- }
224
-
225
- library.interfacesByName.Util.methodsByName.decodeDate.parameters[0].type.name = 'int';
226
- library.interfacesByName.Util.methodsByName.decodeTime.parameters[0].type.name = 'int';
227
- library.interfacesByName.Util.methodsByName.encodeDate.returnType.name = 'int';
228
- library.interfacesByName.Util.methodsByName.encodeTime.returnType.name = 'int';
122
+ for (const intfName in interfaceConfig) {
123
+ if (!Object.prototype.hasOwnProperty.call(interfaceConfig, intfName)) {
124
+ continue;
125
+ }
126
+
127
+ const intf = library.interfacesByName[intfName];
128
+ const config = interfaceConfig[intfName];
129
+
130
+ for (const deleteMethod of config.deleteMethods || []) {
131
+ const methods = intf.methods;
132
+ let found = false;
133
+
134
+ for (const [index, method] of methods.entries()) {
135
+ if (deleteMethod == '*') {
136
+ methods.splice(0);
137
+ found = true;
138
+ } else if (method.name == deleteMethod) {
139
+ methods.splice(index, 1);
140
+ found = true;
141
+ break;
142
+ }
143
+ }
144
+
145
+ if (!found) {
146
+ console.error(`Method '${intfName}#${deleteMethod}' not found for deletion.`);
147
+ process.exit(1);
148
+ }
149
+ }
150
+ }
151
+
152
+ library.interfacesByName.Util.methodsByName.decodeDate.parameters[0].type.name = 'int';
153
+ library.interfacesByName.Util.methodsByName.decodeTime.parameters[0].type.name = 'int';
154
+ library.interfacesByName.Util.methodsByName.encodeDate.returnType.name = 'int';
155
+ library.interfacesByName.Util.methodsByName.encodeTime.returnType.name = 'int';
229
156
  }