nesoi 3.3.7 → 3.3.9

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.
Files changed (31) hide show
  1. package/lib/bundler/distributed/stages/6_dump_cli_stage.js +0 -1
  2. package/lib/bundler/monolyth/stages/6_dump_cli_stage.js +0 -1
  3. package/lib/elements/blocks/resource/resource.js +9 -0
  4. package/lib/elements/entities/bucket/adapters/memory.bucket_adapter.js +19 -16
  5. package/lib/elements/entities/bucket/adapters/memory.nql.js +2 -4
  6. package/lib/elements/entities/bucket/bucket.js +10 -6
  7. package/lib/elements/entities/bucket/bucket.schema.d.ts +1 -1
  8. package/lib/elements/entities/bucket/graph/bucket_graph.js +27 -28
  9. package/lib/elements/entities/bucket/model/bucket_model.d.ts +4 -1
  10. package/lib/elements/entities/bucket/model/bucket_model.js +22 -2
  11. package/lib/engine/app/app.config.d.ts +7 -1
  12. package/lib/engine/app/app.config.js +20 -0
  13. package/lib/engine/app/app.d.ts +3 -1
  14. package/lib/engine/app/inline.app.d.ts +8 -2
  15. package/lib/engine/app/inline.app.js +33 -34
  16. package/lib/engine/app/native/browser.app.d.ts +1 -0
  17. package/lib/engine/app/native/browser.app.js +1 -1
  18. package/lib/engine/app/native/distributed_node.app.js +1 -6
  19. package/lib/engine/app/native/monolyth.app.d.ts +1 -0
  20. package/lib/engine/app/native/monolyth.app.js +1 -1
  21. package/lib/engine/app/service.d.ts +4 -10
  22. package/lib/engine/app/service.js +1 -3
  23. package/lib/engine/cli/script.d.ts +97 -0
  24. package/lib/engine/cli/script.js +422 -0
  25. package/lib/engine/transaction/nodes/bucket_query.trx_node.js +1 -1
  26. package/lib/engine/util/dotenv.d.ts +5 -6
  27. package/lib/engine/util/dotenv.js +14 -12
  28. package/package.json +1 -1
  29. package/tsconfig.build.tsbuildinfo +1 -1
  30. package/tools/dotenv.d.ts +0 -1
  31. package/tools/dotenv.js +0 -4
@@ -17,7 +17,7 @@ class BrowserApp extends inline_app_1.InlineApp {
17
17
  }
18
18
  // Override InlineApp abstract methods
19
19
  async daemon($) {
20
- return super.daemon();
20
+ return super.daemon($);
21
21
  }
22
22
  makeDaemon(trxEngines, services) {
23
23
  return new BrowserDaemon(this.name, trxEngines, services, this._config);
@@ -61,6 +61,7 @@ class DistributedNodeApp extends app_1.App {
61
61
  const services = {};
62
62
  for (const key in this._services) {
63
63
  const service = this._services[key];
64
+ service.config = service.configFn();
64
65
  await promise_1.default.solve(service.up({
65
66
  modules
66
67
  }));
@@ -117,12 +118,6 @@ class DistributedNodeApp extends app_1.App {
117
118
  const module = app.modules[m];
118
119
  module.daemon = this._daemon;
119
120
  }
120
- // Run init method of services
121
- for (const key in app.services) {
122
- await promise_1.default.solve(app.services[key].init({
123
- daemon: this._daemon
124
- }));
125
- }
126
121
  return this._daemon;
127
122
  }
128
123
  host(config) {
@@ -17,6 +17,7 @@ export declare class MonolythApp<S extends $Space, ModuleNames extends string =
17
17
  protected _packageJson?: Record<string, any>;
18
18
  daemon($?: {
19
19
  watch?: boolean;
20
+ dotenv?: string;
20
21
  }): Promise<Daemon<S, ModuleNames>>;
21
22
  protected makeDaemon(trxEngines: Record<ModuleNames, AnyTrxEngine>, services: Record<string, IService>): MonolythDaemon<$Space, ModuleNames>;
22
23
  remake(): Promise<void>;
@@ -75,7 +75,7 @@ class MonolythApp extends inline_app_1.InlineApp {
75
75
  });
76
76
  });
77
77
  }
78
- return super.daemon();
78
+ return super.daemon($);
79
79
  }
80
80
  makeDaemon(trxEngines, services) {
81
81
  return new MonolythDaemon(this.name, trxEngines, services, this._config);
@@ -1,26 +1,23 @@
1
- import { AnyDaemon } from '../daemon';
2
1
  import { AnyModule } from '../module';
3
2
  /**
4
3
  * Service
5
4
  */
6
- type Optional<T> = (T extends undefined ? [] : never) | [cfg: T];
5
+ type OptionalFn<T> = (T extends undefined ? [] : never) | [cfg: () => T];
7
6
  export declare abstract class Service<out Name extends string, Config = never> {
8
7
  /**
9
8
  * This property MUST be set on the implementation class.
10
9
  */
11
10
  static defaultName: string;
12
11
  name: Name;
12
+ private configFn;
13
13
  config: Config;
14
14
  libPaths?: string[];
15
15
  abstract up($: {
16
16
  modules: Record<string, AnyModule>;
17
17
  }): void | Promise<void>;
18
18
  abstract down(): void | Promise<void>;
19
- init($: {
20
- daemon: AnyDaemon;
21
- }): void | Promise<void>;
22
- constructor(...cfg: Optional<Config>);
23
- constructor(name: Name, ...cfg: Optional<Config>);
19
+ constructor(...cfg: OptionalFn<Config>);
20
+ constructor(name: Name, ...cfg: OptionalFn<Config>);
24
21
  }
25
22
  export type AnyService = Service<any, any>;
26
23
  export interface IService {
@@ -29,9 +26,6 @@ export interface IService {
29
26
  up(this: IService, $: {
30
27
  modules: Record<string, AnyModule>;
31
28
  }): void | Promise<void>;
32
- init(this: IService, $: {
33
- daemon: AnyDaemon;
34
- }): void | Promise<void>;
35
29
  down(this: IService): void | Promise<void>;
36
30
  }
37
31
  export {};
@@ -2,8 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Service = void 0;
4
4
  class Service {
5
- init($) {
6
- }
7
5
  constructor(arg1, arg2) {
8
6
  if (typeof arg1 === 'string') {
9
7
  this.name = arg1;
@@ -11,7 +9,7 @@ class Service {
11
9
  else {
12
10
  this.name = this.constructor.defaultName;
13
11
  }
14
- this.config = arg2 || arg1;
12
+ this.configFn = arg2 || arg1;
15
13
  }
16
14
  }
17
15
  exports.Service = Service;
@@ -0,0 +1,97 @@
1
+ /**
2
+ * @category Engine
3
+ * @subcategory CLI
4
+ */
5
+ export default function script<Def extends ScriptDef, T = ReturnType<Def> extends ScriptBuilder<infer X> ? X : never>(name: string, def: Def): Script<{ [K in keyof T]: T[K]; }>;
6
+ declare class Script<T> {
7
+ private schema;
8
+ args: T;
9
+ constructor(schema: $Script<any>);
10
+ init(): T;
11
+ log_help(): void;
12
+ log_header(): void;
13
+ log_syntax(): void;
14
+ log_flags(): void;
15
+ error(error: string, type: 'syntax' | 'flag'): void;
16
+ parse(): void;
17
+ private parse_argv;
18
+ private validate;
19
+ }
20
+ type $Script<T> = {
21
+ name: string;
22
+ description?: string;
23
+ args: $ScriptArg[];
24
+ };
25
+ type $ScriptArg = {
26
+ name: string;
27
+ short?: string;
28
+ description?: string;
29
+ type: 'pos' | 'key';
30
+ values: $ScriptValue[];
31
+ };
32
+ type $ScriptValue = {
33
+ name: string;
34
+ description?: string;
35
+ type: 'string' | 'boolean' | 'enum';
36
+ amount: '1' | '1?' | '0+' | '1+';
37
+ meta: {
38
+ enum?: {
39
+ options: {
40
+ [x: string]: {
41
+ name: string;
42
+ description?: string;
43
+ };
44
+ };
45
+ };
46
+ };
47
+ };
48
+ type ArgName<T> = T extends `--${infer X}` ? X : T extends `-${infer X}` ? X : T;
49
+ type ArgValue<T> = T extends Record<string, any> ? {
50
+ [K in keyof T]: T[K];
51
+ } : T;
52
+ declare class ScriptBuilder<T> {
53
+ private schema;
54
+ constructor(name: string);
55
+ d(description: string): this;
56
+ arg<Name extends string, Def extends ScriptArgDef<Name extends `-${string}` ? 'key' : 'pos'>>(name: Name, short: Name extends `-${string}` ? `-${string}` : never, def: Def): ScriptBuilder<T & {
57
+ [K in Name as ArgName<K>]: ReturnType<Def> extends ScriptArgBuilder<infer X> ? ArgValue<X> : any;
58
+ }>;
59
+ arg<Name extends string, Def extends ScriptArgDef<Name extends `-${string}` ? 'key' : 'pos'>>(name: Name, def: Def): ScriptBuilder<T & {
60
+ [K in Name as ArgName<K>]: ReturnType<Def> extends ScriptArgBuilder<infer X> ? ArgValue<X> : any;
61
+ }>;
62
+ static build<T>(builder: ScriptBuilder<T>): $Script<{ [K in keyof T]: T[K]; }>;
63
+ }
64
+ declare class ScriptPosArgBuilder<T = string> {
65
+ private schema;
66
+ constructor(name: string);
67
+ d(description: string): this;
68
+ value<Def extends ScriptValueDef>(def: Def): ScriptPosArgBuilder<ReturnType<Def> extends ScriptValueBuilder<infer X> ? X : never>;
69
+ static build(builder: ScriptPosArgBuilder): $ScriptArg;
70
+ }
71
+ declare class ScriptKeyArgBuilder<T = boolean | undefined> {
72
+ private schema;
73
+ constructor(name: string, short?: string);
74
+ d(description: string): this;
75
+ value<N extends string, Def extends ScriptValueDef>(name: N, def: Def): ScriptKeyArgBuilder<T extends boolean ? {
76
+ [k in N]: ReturnType<Def> extends ScriptValueBuilder<infer X> ? X : never;
77
+ } | undefined : T & {
78
+ [k in N]: ReturnType<Def> extends ScriptValueBuilder<infer X> ? X : never;
79
+ } | undefined>;
80
+ static build(builder: ScriptKeyArgBuilder): $ScriptArg;
81
+ }
82
+ declare class ScriptValueBuilder<T = string> {
83
+ private schema;
84
+ constructor(name: string);
85
+ d(description: string): this;
86
+ get optional(): ScriptValueBuilder<T | undefined>;
87
+ get zero_or_more(): this;
88
+ get one_or_more(): this;
89
+ get boolean(): ScriptValueBuilder<boolean>;
90
+ enum<E extends string>(options: E[] | Record<E, string>): ScriptValueBuilder<undefined extends T ? E | undefined : E>;
91
+ private build;
92
+ }
93
+ type ScriptArgBuilder<T> = ScriptPosArgBuilder<T> | ScriptKeyArgBuilder<T>;
94
+ type ScriptDef = (builder: ScriptBuilder<{}>) => ScriptBuilder<any>;
95
+ type ScriptValueDef = (builder: ScriptValueBuilder<string>) => ScriptValueBuilder<any>;
96
+ type ScriptArgDef<Type extends 'key' | 'pos'> = (factory: Type extends 'pos' ? ScriptPosArgBuilder : ScriptKeyArgBuilder) => ScriptArgBuilder<any>;
97
+ export {};
@@ -0,0 +1,422 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = script;
4
+ const string_1 = require("../util/string");
5
+ /**
6
+ * @category Engine
7
+ * @subcategory CLI
8
+ */
9
+ function script(name, def) {
10
+ const builder = def(new ScriptBuilder(name));
11
+ const schema = ScriptBuilder.build(builder);
12
+ return new Script(schema);
13
+ }
14
+ //
15
+ class Script {
16
+ constructor(schema) {
17
+ this.schema = schema;
18
+ this.args = {};
19
+ }
20
+ init() {
21
+ if (process.argv.includes('-h') || process.argv.includes('--help')) {
22
+ this.log_help();
23
+ process.exit();
24
+ }
25
+ this.parse();
26
+ return this.args;
27
+ }
28
+ log_help() {
29
+ this.log_header();
30
+ this.log_syntax();
31
+ const pos_args = this.schema.args.filter(arg => arg.type === 'pos');
32
+ if (pos_args.length) {
33
+ console.log('Positional Arguments:\n');
34
+ for (const arg of pos_args) {
35
+ let str = ' ';
36
+ str += (0, string_1.colored)(arg.name, 'brown');
37
+ str += '\n ';
38
+ if (arg.values[0].amount === '1?') {
39
+ str += (0, string_1.colored)('(optional) ', 'blue');
40
+ }
41
+ else if (arg.values[0].amount === '0+') {
42
+ str += (0, string_1.colored)('(zero or more) ', 'blue');
43
+ }
44
+ else if (arg.values[0].amount === '1+') {
45
+ str += (0, string_1.colored)('(one or more) ', 'blue');
46
+ }
47
+ str += (0, string_1.colored)(arg.description ?? '', 'blue');
48
+ str += '\n';
49
+ if (arg.values[0].type === 'enum') {
50
+ for (const opt in arg.values[0].meta.enum.options) {
51
+ const option = arg.values[0].meta.enum.options[opt];
52
+ str += ' - ' + (0, string_1.colored)(opt, 'lightblue') + ' ' + (0, string_1.colored)(option.description ? (': ' + option.description) : '', 'blue');
53
+ str += '\n';
54
+ }
55
+ }
56
+ console.log(str);
57
+ }
58
+ }
59
+ this.log_flags();
60
+ }
61
+ log_header() {
62
+ console.log();
63
+ console.log((0, string_1.colored)(this.schema.name, 'lightpurple'));
64
+ if (this.schema.description) {
65
+ console.log((0, string_1.colored)(this.schema.description, 'purple'));
66
+ }
67
+ console.log();
68
+ }
69
+ log_syntax() {
70
+ const syntax = this.schema.args.map(arg => {
71
+ const values = [];
72
+ for (const val of arg.values) {
73
+ switch (val.amount) {
74
+ case '1':
75
+ values.push(val.name);
76
+ break;
77
+ case '1?':
78
+ values.push(val.name + '?');
79
+ break;
80
+ case '0+':
81
+ values.push(val.name + '0..' + val.name + '+');
82
+ break;
83
+ case '1+':
84
+ values.push(val.name + '1..' + val.name + '+');
85
+ break;
86
+ }
87
+ }
88
+ let p = arg.name;
89
+ if (arg.type === 'pos') {
90
+ p = `{${values[0]}}`;
91
+ }
92
+ else if (arg.type === 'key') {
93
+ p = `[${p}${values.length ? (' ' + values.join(' ')) : ''}]`;
94
+ }
95
+ return p;
96
+ }).join(' ');
97
+ console.log(`Syntax:\n\n${(0, string_1.colored)(this.schema.name + ' ' + syntax, 'brown')}`);
98
+ console.log();
99
+ }
100
+ log_flags() {
101
+ const key_args = this.schema.args.filter(arg => arg.type === 'key');
102
+ console.log('Keyword Arguments:\n');
103
+ console.log(` ${(0, string_1.colored)('-h --help', 'cyan')}?\n ${(0, string_1.colored)('Show this help info', 'blue')}\n`);
104
+ for (const arg of key_args) {
105
+ const values = [];
106
+ for (const val of arg.values) {
107
+ switch (val.amount) {
108
+ case '1':
109
+ values.push(val.name);
110
+ break;
111
+ case '1?':
112
+ values.push(val.name + '?');
113
+ break;
114
+ case '0+':
115
+ values.push(val.name + '0..' + val.name + '+');
116
+ break;
117
+ case '1+':
118
+ values.push(val.name + '1..' + val.name + '+');
119
+ break;
120
+ }
121
+ }
122
+ let str = ' ';
123
+ if (arg.short) {
124
+ str += (0, string_1.colored)(arg.short + ' ' + arg.name, 'brown');
125
+ }
126
+ else {
127
+ str += (0, string_1.colored)(arg.name, 'brown');
128
+ }
129
+ for (const value of values) {
130
+ str += ' ' + (0, string_1.colored)(value, 'green');
131
+ }
132
+ str += '\n ';
133
+ str += (0, string_1.colored)(arg.description ?? '', 'blue');
134
+ str += '\n ';
135
+ for (let i = 0; i < values.length; i++) {
136
+ str += (0, string_1.colored)(values[i], 'green');
137
+ if (arg.values[i].amount === '1?') {
138
+ str += (0, string_1.colored)(': (optional)', 'cyan');
139
+ }
140
+ else if (arg.values[i].amount === '0+') {
141
+ str += (0, string_1.colored)(': (zero or more)', 'cyan');
142
+ }
143
+ else if (arg.values[i].amount === '1+') {
144
+ str += (0, string_1.colored)(': (one or more)', 'cyan');
145
+ }
146
+ if (arg.values[i].description) {
147
+ str += (0, string_1.colored)(` ${arg.values[i].description}`, 'cyan');
148
+ }
149
+ str += '\n ';
150
+ }
151
+ console.log(str);
152
+ }
153
+ console.log();
154
+ }
155
+ error(error, type) {
156
+ this.log_header();
157
+ if (type === 'syntax') {
158
+ this.log_syntax();
159
+ }
160
+ else {
161
+ this.log_flags();
162
+ }
163
+ console.log((0, string_1.colored)('---\n' + error + '\n---', 'red'));
164
+ console.log();
165
+ process.exit();
166
+ }
167
+ parse() {
168
+ const argv = process.argv;
169
+ let i = 2;
170
+ // Positional
171
+ for (const arg of this.schema.args) {
172
+ if (arg.type !== 'pos')
173
+ break;
174
+ const { i: j, value } = this.parse_argv(arg, arg.values[0], i);
175
+ this.args[arg.name] = value;
176
+ i = j;
177
+ }
178
+ // Keyword
179
+ let arg;
180
+ while (i < argv.length) {
181
+ if (!argv[i].startsWith('-')) {
182
+ this.error(`Error: Unexpected argument(s) at the end '${argv.slice(i).join(' ')}'`, 'syntax');
183
+ }
184
+ arg = this.schema.args.find(arg => arg.name === argv[i] || arg.short === argv[i]);
185
+ if (!arg) {
186
+ this.error(`Error: Unknown keyword argument '${argv[i]}'`, 'flag');
187
+ break;
188
+ }
189
+ const name = arg.name.replace(/-+(.*)/, '$1');
190
+ if (arg.values.length) {
191
+ this.args[name] = {};
192
+ i++;
193
+ for (const val of arg.values) {
194
+ const { i: j, value } = this.parse_argv(arg, val, i);
195
+ i = j;
196
+ this.args[name][val.name] = value;
197
+ }
198
+ }
199
+ else {
200
+ this.args[name] = true;
201
+ i++;
202
+ }
203
+ }
204
+ // for (const arg of this.schema.args) {
205
+ // if (arg.type !== 'key') continue;
206
+ // if (i >= argv.length) break;
207
+ // }
208
+ }
209
+ parse_argv(arg, value, i) {
210
+ const argv = process.argv;
211
+ const values = [];
212
+ // Single
213
+ if (value.amount === '1' || value.amount === '1?') {
214
+ if (argv[i] && !argv[i].startsWith('-')) {
215
+ values.push(argv[i]);
216
+ i++;
217
+ }
218
+ }
219
+ // Many
220
+ else {
221
+ while (i < argv.length) {
222
+ if (argv[i].startsWith('-'))
223
+ break;
224
+ values.push(argv[i]);
225
+ i++;
226
+ }
227
+ }
228
+ if (values.length === 0 && (value.amount === '1' || value.amount === '1+')) {
229
+ this.error(`Error: Missing required ${arg.type === 'pos' ? 'positional argument' : ('value from arg \'' + arg.name + '\' named')} '${value.name}'`, 'syntax');
230
+ }
231
+ const validated = values.map(val => this.validate(value, val));
232
+ // Single
233
+ if (value.amount === '1' || value.amount === '1?') {
234
+ return { value: validated[0], i };
235
+ }
236
+ else {
237
+ return { value: validated, i };
238
+ }
239
+ }
240
+ validate(schema, value) {
241
+ switch (schema.type) {
242
+ case 'string':
243
+ return value;
244
+ break;
245
+ case 'boolean':
246
+ if (value.toLowerCase() === 'true' || value === '1' || value.toLowerCase() === 'yes')
247
+ return true;
248
+ return false;
249
+ break;
250
+ case 'enum':
251
+ if (!(value in schema.meta.enum.options)) {
252
+ this.error(`Error: Value '${schema.name}=${value}' doesn't match any of the options: ${Object.keys(schema.meta.enum.options).join(', ')}`, 'syntax');
253
+ }
254
+ return value;
255
+ break;
256
+ }
257
+ }
258
+ }
259
+ class ScriptBuilder {
260
+ constructor(name) {
261
+ this.schema = {
262
+ args: []
263
+ };
264
+ this.schema.name = name;
265
+ }
266
+ d(description) {
267
+ this.schema.description = description;
268
+ return this;
269
+ }
270
+ arg(name, arg1, arg2) {
271
+ const def = arg2 || arg1;
272
+ const short = typeof arg1 === 'string' ? arg1 : undefined;
273
+ let schema;
274
+ if (name.startsWith('-')) {
275
+ const builder = new ScriptKeyArgBuilder(name, short);
276
+ def(builder);
277
+ schema = ScriptKeyArgBuilder.build(builder);
278
+ }
279
+ else {
280
+ const builder = new ScriptPosArgBuilder(name);
281
+ def(builder);
282
+ schema = ScriptPosArgBuilder.build(builder);
283
+ }
284
+ this.schema.args?.push(schema);
285
+ return this;
286
+ }
287
+ static build(builder) {
288
+ const args = builder.schema.args;
289
+ for (let i = 1; i < args.length; i++) {
290
+ if (args[i].type !== 'pos')
291
+ break;
292
+ const lastArg = args[i - 1];
293
+ if (lastArg.values[0].amount === '0+' || lastArg.values[0].amount === '1+') {
294
+ throw new Error('Only a single 0+/1+ positional argument is allowed, as the last one.');
295
+ }
296
+ }
297
+ builder.schema.args = [
298
+ ...args.filter(arg => arg.type === 'pos' && arg.values[0].amount === '1'),
299
+ ...args.filter(arg => arg.type === 'pos' && arg.values[0].amount !== '1'),
300
+ ...args.filter(arg => arg.type === 'key')
301
+ ];
302
+ return builder.schema;
303
+ }
304
+ }
305
+ class ScriptPosArgBuilder {
306
+ constructor(name) {
307
+ this.schema = {};
308
+ this.schema.name = name;
309
+ this.schema.type = 'pos';
310
+ this.schema.values = [{
311
+ name,
312
+ type: 'string',
313
+ amount: '1',
314
+ meta: {}
315
+ }];
316
+ }
317
+ d(description) {
318
+ this.schema.description = description;
319
+ return this;
320
+ }
321
+ value(def) {
322
+ const builder = new ScriptValueBuilder(this.schema.name);
323
+ def(builder);
324
+ const value = builder.build();
325
+ this.schema.values = [value];
326
+ return this;
327
+ }
328
+ static build(builder) {
329
+ return builder.schema;
330
+ }
331
+ }
332
+ class ScriptKeyArgBuilder {
333
+ constructor(name, short) {
334
+ this.schema = {};
335
+ this.schema.name = name;
336
+ this.schema.short = short;
337
+ this.schema.type = 'key';
338
+ this.schema.values = [];
339
+ }
340
+ d(description) {
341
+ this.schema.description = description;
342
+ return this;
343
+ }
344
+ value(name, def) {
345
+ const lastValue = this.schema.values.at(-1);
346
+ if (lastValue?.amount === '0+' || lastValue?.amount === '1+') {
347
+ throw new Error('Only a single 0+/1+ value is allowed, as the last one.');
348
+ }
349
+ const builder = new ScriptValueBuilder(name);
350
+ def(builder);
351
+ const value = builder.build();
352
+ this.schema.values.push(value);
353
+ return this;
354
+ }
355
+ static build(builder) {
356
+ builder.schema.values = [
357
+ ...builder.schema.values.filter(value => value.amount === '1'),
358
+ ...builder.schema.values.filter(value => value.amount !== '1'),
359
+ ];
360
+ return builder.schema;
361
+ }
362
+ }
363
+ class ScriptValueBuilder {
364
+ constructor(name) {
365
+ this.schema = {
366
+ name,
367
+ type: 'string',
368
+ amount: '1',
369
+ meta: {}
370
+ };
371
+ }
372
+ d(description) {
373
+ this.schema.description = description;
374
+ return this;
375
+ }
376
+ get optional() {
377
+ if (this.schema.amount === '1') {
378
+ this.schema.amount = '1?';
379
+ }
380
+ return this;
381
+ }
382
+ get zero_or_more() {
383
+ this.schema.amount = '0+';
384
+ return this;
385
+ }
386
+ get one_or_more() {
387
+ this.schema.amount = '1+';
388
+ return this;
389
+ }
390
+ get boolean() {
391
+ this.schema = {
392
+ ...this.schema,
393
+ type: 'boolean',
394
+ meta: {}
395
+ };
396
+ return this;
397
+ }
398
+ enum(options) {
399
+ const opts = {};
400
+ if (Array.isArray(options)) {
401
+ for (const opt of options) {
402
+ opts[opt] = { name: opt };
403
+ }
404
+ }
405
+ else {
406
+ for (const name in options) {
407
+ opts[name] = { name, description: options[name] };
408
+ }
409
+ }
410
+ this.schema = {
411
+ ...this.schema,
412
+ type: 'enum',
413
+ meta: {
414
+ enum: {
415
+ options: opts
416
+ }
417
+ }
418
+ };
419
+ return this;
420
+ }
421
+ build() { return this.schema; }
422
+ }
@@ -72,7 +72,7 @@ class BucketQueryTrxNode {
72
72
  }
73
73
  async first() {
74
74
  const results = await this.wrap('queryFirst', { schema: this.query, view: this.view }, (trx, bucket) => {
75
- return bucket.query(this.trx, this.query, {
75
+ return bucket.query(trx, this.query, {
76
76
  perPage: 1
77
77
  }, this.view, {
78
78
  no_tenancy: !this.enableTenancy,
@@ -1,9 +1,8 @@
1
1
  export type DotEnvFile = Record<string, string>;
2
2
  export declare class DotEnv {
3
- static path: string;
4
- static load(): void;
5
- static parse(): DotEnvFile;
6
- static save(dotenv: DotEnvFile): void;
7
- static get(key: string): string;
8
- static set(key: string, value: string): void;
3
+ static load(filename?: string): void;
4
+ static parse(filename?: string): DotEnvFile;
5
+ static save(dotenv: DotEnvFile, filename?: string): void;
6
+ static get(key: string, filename?: string): string;
7
+ static set(key: string, value: string, filename?: string): void;
9
8
  }