nesoi 3.0.0 → 3.0.6

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 (186) hide show
  1. package/README.md +10 -0
  2. package/lib/adapters/postgres/src/migrator/bucket.d.ts +20 -0
  3. package/lib/adapters/postgres/src/migrator/bucket.js +184 -0
  4. package/lib/adapters/postgres/src/migrator/csv.d.ts +7 -0
  5. package/lib/adapters/postgres/src/migrator/csv.js +72 -0
  6. package/lib/adapters/postgres/src/migrator/migration.d.ts +2 -18
  7. package/lib/adapters/postgres/src/migrator/migration.js +10 -158
  8. package/lib/adapters/postgres/src/migrator/migrator.js +8 -5
  9. package/lib/adapters/postgres/src/migrator/runner.d.ts +16 -6
  10. package/lib/adapters/postgres/src/migrator/runner.js +103 -34
  11. package/lib/adapters/postgres/src/postgres.bucket_adapter.d.ts +19 -22
  12. package/lib/adapters/postgres/src/postgres.bucket_adapter.js +116 -100
  13. package/lib/adapters/postgres/src/postgres.cli.d.ts +23 -3
  14. package/lib/adapters/postgres/src/postgres.cli.js +70 -10
  15. package/lib/adapters/postgres/src/postgres.config.d.ts +5 -0
  16. package/lib/adapters/postgres/src/postgres.config.js +2 -0
  17. package/lib/adapters/postgres/src/postgres.nql.d.ts +7 -3
  18. package/lib/adapters/postgres/src/postgres.nql.js +86 -32
  19. package/lib/adapters/postgres/src/postgres.provider.d.ts +18 -0
  20. package/lib/adapters/postgres/src/postgres.provider.js +77 -0
  21. package/lib/adapters/postgres/test/postgres.bucket_adapter.test.js +76 -39
  22. package/lib/compiler/apps/monolyth/monolyth_compiler.d.ts +3 -0
  23. package/lib/compiler/apps/monolyth/monolyth_compiler.js +24 -0
  24. package/lib/compiler/apps/monolyth/stages/2_build_typescript_stage.js +2 -1
  25. package/lib/compiler/apps/monolyth/stages/5_dump_cli_stage.js +1 -1
  26. package/lib/compiler/apps/monolyth/stages/6_dump_package_json_stage.js +1 -1
  27. package/lib/compiler/elements/bucket.element.js +26 -11
  28. package/lib/compiler/elements/constants.element.js +1 -1
  29. package/lib/compiler/elements/element.d.ts +2 -0
  30. package/lib/compiler/elements/message.element.js +4 -4
  31. package/lib/compiler/helpers/dump_helpers.js +5 -2
  32. package/lib/compiler/stages/7_dump_stage.js +2 -0
  33. package/lib/compiler/treeshake.js +9 -37
  34. package/lib/compiler/typescript/bridge/extract.js +12 -0
  35. package/lib/compiler/typescript/bridge/inject.js +3 -0
  36. package/lib/compiler/typescript/bridge/organize.js +3 -3
  37. package/lib/elements/blocks/block.builder.js +4 -2
  38. package/lib/elements/blocks/job/internal/resource_job.builder.d.ts +22 -20
  39. package/lib/elements/blocks/job/internal/resource_job.d.ts +2 -1
  40. package/lib/elements/blocks/job/internal/resource_job.js +17 -4
  41. package/lib/elements/blocks/job/job.js +3 -0
  42. package/lib/elements/blocks/job/job.types.d.ts +7 -0
  43. package/lib/elements/blocks/job/job.types.js +2 -0
  44. package/lib/elements/blocks/machine/machine.js +3 -2
  45. package/lib/elements/blocks/resource/resource.builder.js +2 -4
  46. package/lib/elements/blocks/resource/resource.d.ts +5 -3
  47. package/lib/elements/blocks/resource/resource.js +26 -17
  48. package/lib/elements/edge/controller/adapters/controller_adapter.d.ts +2 -1
  49. package/lib/elements/edge/controller/adapters/controller_adapter.js +11 -2
  50. package/lib/elements/edge/controller/controller.builder.d.ts +4 -5
  51. package/lib/elements/edge/controller/controller.builder.js +7 -7
  52. package/lib/elements/edge/controller/controller.d.ts +2 -1
  53. package/lib/elements/edge/controller/controller.js +8 -6
  54. package/lib/elements/entities/bucket/adapters/bucket_adapter.d.ts +61 -23
  55. package/lib/elements/entities/bucket/adapters/bucket_adapter.js +22 -13
  56. package/lib/elements/entities/bucket/adapters/memory.bucket_adapter.d.ts +21 -22
  57. package/lib/elements/entities/bucket/adapters/memory.bucket_adapter.js +68 -2
  58. package/lib/elements/entities/bucket/adapters/memory.nql.d.ts +10 -6
  59. package/lib/elements/entities/bucket/adapters/memory.nql.js +38 -3
  60. package/lib/elements/entities/bucket/adapters/slow_memory.bucket_adapter.d.ts +0 -20
  61. package/lib/elements/entities/bucket/adapters/slow_memory.bucket_adapter.js +46 -30
  62. package/lib/elements/entities/bucket/bucket.builder.d.ts +8 -2
  63. package/lib/elements/entities/bucket/bucket.builder.js +13 -19
  64. package/lib/elements/entities/bucket/bucket.config.d.ts +5 -1
  65. package/lib/elements/entities/bucket/bucket.d.ts +180 -19
  66. package/lib/elements/entities/bucket/bucket.js +662 -48
  67. package/lib/elements/entities/bucket/bucket.schema.d.ts +7 -1
  68. package/lib/elements/entities/bucket/bucket.schema.js +2 -1
  69. package/lib/elements/entities/bucket/bucket.types.d.ts +2 -7
  70. package/lib/elements/entities/bucket/cache/bucket_cache.d.ts +6 -2
  71. package/lib/elements/entities/bucket/cache/bucket_cache.js +12 -12
  72. package/lib/elements/entities/bucket/graph/bucket_graph.d.ts +32 -5
  73. package/lib/elements/entities/bucket/graph/bucket_graph.js +80 -111
  74. package/lib/elements/entities/bucket/graph/bucket_graph.schema.d.ts +3 -6
  75. package/lib/elements/entities/bucket/graph/bucket_graph.schema.js +1 -4
  76. package/lib/elements/entities/bucket/graph/bucket_graph_link.builder.d.ts +3 -7
  77. package/lib/elements/entities/bucket/graph/bucket_graph_link.builder.js +6 -2
  78. package/lib/elements/entities/bucket/model/bucket_model.builder.js +1 -1
  79. package/lib/elements/entities/bucket/model/bucket_model.convert.js +3 -3
  80. package/lib/elements/entities/bucket/model/bucket_model.schema.d.ts +37 -8
  81. package/lib/elements/entities/bucket/model/bucket_model.schema.js +25 -4
  82. package/lib/elements/entities/bucket/model/bucket_model_field.builder.d.ts +33 -14
  83. package/lib/elements/entities/bucket/model/bucket_model_field.builder.js +56 -13
  84. package/lib/elements/entities/bucket/query/nql.schema.d.ts +1 -0
  85. package/lib/elements/entities/bucket/query/nql_compiler.js +13 -2
  86. package/lib/elements/entities/bucket/query/nql_engine.d.ts +11 -4
  87. package/lib/elements/entities/bucket/query/nql_engine.js +20 -11
  88. package/lib/elements/entities/bucket/view/bucket_view.js +63 -35
  89. package/lib/elements/entities/bucket/view/bucket_view.schema.d.ts +5 -2
  90. package/lib/elements/entities/bucket/view/bucket_view_field.builder.d.ts +6 -2
  91. package/lib/elements/entities/bucket/view/bucket_view_field.builder.js +22 -16
  92. package/lib/elements/entities/constants/constants.schema.d.ts +1 -1
  93. package/lib/elements/entities/drive/drive_adapter.d.ts +44 -0
  94. package/lib/elements/entities/drive/drive_adapter.js +10 -0
  95. package/lib/elements/entities/drive/local.drive_adapter.d.ts +10 -0
  96. package/lib/elements/entities/drive/local.drive_adapter.js +34 -0
  97. package/lib/elements/entities/message/message.schema.d.ts +1 -0
  98. package/lib/elements/entities/message/message.schema.js +33 -0
  99. package/lib/elements/entities/message/message_parser.d.ts +5 -1
  100. package/lib/elements/entities/message/message_parser.js +56 -35
  101. package/lib/elements/entities/message/template/message_template.schema.d.ts +10 -8
  102. package/lib/elements/entities/message/template/message_template_field.builder.d.ts +16 -6
  103. package/lib/elements/entities/message/template/message_template_field.builder.js +25 -0
  104. package/lib/elements/entities/message/template/message_template_parser.js +2 -1
  105. package/lib/engine/apps/app.config.d.ts +32 -11
  106. package/lib/engine/apps/app.config.js +12 -0
  107. package/lib/engine/apps/app.d.ts +2 -0
  108. package/lib/engine/apps/app.js +3 -0
  109. package/lib/engine/apps/inline.app.d.ts +5 -3
  110. package/lib/engine/apps/inline.app.js +27 -12
  111. package/lib/engine/apps/monolyth/monolyth.app.d.ts +4 -2
  112. package/lib/engine/apps/monolyth/monolyth.app.js +22 -10
  113. package/lib/engine/auth/authn.d.ts +5 -1
  114. package/lib/engine/auth/zero.authn_provider.d.ts +4 -2
  115. package/lib/engine/auth/zero.authn_provider.js +2 -2
  116. package/lib/engine/cli/cli.d.ts +3 -1
  117. package/lib/engine/cli/cli.js +22 -3
  118. package/lib/engine/cli/cli_adapter.d.ts +2 -1
  119. package/lib/engine/cli/cli_adapter.js +2 -1
  120. package/lib/engine/cli/cli_input.d.ts +19 -0
  121. package/lib/engine/cli/cli_input.js +207 -0
  122. package/lib/engine/cli/ui.d.ts +1 -1
  123. package/lib/engine/cli/ui.js +2 -2
  124. package/lib/engine/daemon.d.ts +3 -2
  125. package/lib/engine/daemon.js +14 -2
  126. package/lib/engine/data/date.js +2 -2
  127. package/lib/engine/data/datetime.d.ts +40 -4
  128. package/lib/engine/data/datetime.js +70 -11
  129. package/lib/engine/data/decimal.d.ts +1 -1
  130. package/lib/engine/data/decimal.js +3 -3
  131. package/lib/engine/data/error.d.ts +21 -4
  132. package/lib/engine/data/error.js +23 -7
  133. package/lib/engine/data/file.d.ts +38 -0
  134. package/lib/engine/data/file.js +54 -0
  135. package/lib/engine/data/json.d.ts +6 -0
  136. package/lib/engine/data/json.js +26 -0
  137. package/lib/engine/data/obj.d.ts +1 -1
  138. package/lib/engine/data/trash.d.ts +14 -0
  139. package/lib/engine/data/trash.js +2 -0
  140. package/lib/engine/data/tree.d.ts +7 -12
  141. package/lib/engine/data/tree.js +101 -49
  142. package/lib/engine/module.d.ts +2 -1
  143. package/lib/engine/module.js +2 -5
  144. package/lib/engine/space.d.ts +1 -0
  145. package/lib/engine/space.js +6 -0
  146. package/lib/engine/transaction/nodes/bucket.trx_node.d.ts +184 -24
  147. package/lib/engine/transaction/nodes/bucket.trx_node.js +346 -451
  148. package/lib/engine/transaction/nodes/bucket_query.trx_node.d.ts +4 -2
  149. package/lib/engine/transaction/nodes/bucket_query.trx_node.js +27 -15
  150. package/lib/engine/transaction/nodes/job.trx_node.d.ts +2 -1
  151. package/lib/engine/transaction/nodes/job.trx_node.js +6 -0
  152. package/lib/engine/transaction/trx.d.ts +5 -2
  153. package/lib/engine/transaction/trx.js +2 -2
  154. package/lib/engine/transaction/trx_engine.config.d.ts +1 -3
  155. package/lib/engine/transaction/trx_engine.d.ts +2 -2
  156. package/lib/engine/transaction/trx_engine.js +14 -11
  157. package/lib/engine/transaction/trx_node.d.ts +14 -4
  158. package/lib/engine/transaction/trx_node.js +50 -8
  159. package/lib/engine/tree.d.ts +1 -1
  160. package/lib/engine/util/crypto.d.ts +50 -0
  161. package/lib/engine/util/crypto.js +89 -0
  162. package/lib/engine/util/deep.d.ts +5 -0
  163. package/lib/engine/util/deep.js +46 -0
  164. package/lib/engine/util/dotenv.d.ts +2 -8
  165. package/lib/engine/util/dotenv.js +14 -36
  166. package/lib/engine/util/hash.d.ts +3 -0
  167. package/lib/engine/util/hash.js +23 -0
  168. package/lib/engine/util/log.js +1 -1
  169. package/lib/engine/util/mime.d.ts +10 -0
  170. package/lib/engine/util/mime.js +389 -0
  171. package/lib/engine/util/parse.d.ts +6 -5
  172. package/lib/engine/util/parse.js +16 -15
  173. package/lib/engine/util/path.d.ts +3 -0
  174. package/lib/engine/util/path.js +92 -0
  175. package/lib/engine/util/rules.d.ts +4 -0
  176. package/lib/engine/util/rules.js +12 -0
  177. package/package.json +2 -2
  178. package/tools/compile.js +2 -2
  179. package/tools/dotenv.d.ts +1 -0
  180. package/tools/dotenv.js +4 -0
  181. package/tools/joaquin/job.d.ts +5 -5
  182. package/tools/joaquin/mock.d.ts +23 -2
  183. package/tools/joaquin/mock.js +127 -21
  184. package/tsconfig.build.tsbuildinfo +1 -1
  185. package/lib/adapters/postgres/test/postgres.bucket_query.test.d.ts +0 -0
  186. package/lib/adapters/postgres/test/postgres.bucket_query.test.js +0 -136
@@ -1,522 +1,417 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BucketTrxNode = void 0;
4
- const error_1 = require("../../data/error");
3
+ exports.BucketDriveTrxNode = exports.BucketUnsafeTrxNode = exports.BucketTrxNode = void 0;
5
4
  const trx_node_1 = require("../trx_node");
6
5
  const bucket_query_trx_node_1 = require("./bucket_query.trx_node");
6
+ const error_1 = require("../../data/error");
7
7
  class BucketTrxNode {
8
8
  constructor(parentTrx, bucket) {
9
9
  this.parentTrx = parentTrx;
10
10
  this.bucket = bucket;
11
+ this.enableTenancy = true;
11
12
  }
12
- // Read/View One
13
- async readOne(id) {
13
+ /*
14
+ Modifiers
15
+ */
16
+ get no_tenancy() {
17
+ this.enableTenancy = false;
18
+ return this;
19
+ }
20
+ /*
21
+ Wrap
22
+ */
23
+ async wrap(action, input, fn, fmtTrxOut) {
14
24
  const trx = trx_node_1.TrxNode.makeChildNode(this.parentTrx, this.bucket.schema.module, 'bucket', this.bucket.schema.name);
15
- await trx_node_1.TrxNode.open(trx, 'readOne', { id });
16
- let obj;
25
+ await trx_node_1.TrxNode.open(trx, action, input);
26
+ let out;
17
27
  try {
18
- obj = await this.bucket.readOne(trx, id);
28
+ out = await fn(trx);
19
29
  }
20
30
  catch (e) {
21
- await trx_node_1.TrxNode.error(trx, e); // Bucket unexpected error
31
+ await trx_node_1.TrxNode.error(trx, e);
22
32
  throw e;
23
33
  }
24
- await trx_node_1.TrxNode.ok(trx, obj);
25
- return obj;
34
+ await trx_node_1.TrxNode.ok(trx, fmtTrxOut ? fmtTrxOut(out) : out);
35
+ return out;
36
+ }
37
+ /*
38
+ Read/View One
39
+ */
40
+ /**
41
+ * Returns one object by `id`, without pre-formatting,
42
+ * or `undefined` if the object was not found.
43
+ */
44
+ async readOne(id) {
45
+ return this.wrap('readOne', { id }, trx => this.bucket.readOne(trx, id, {
46
+ silent: true,
47
+ no_tenancy: !this.enableTenancy
48
+ }));
26
49
  }
50
+ /**
51
+ * Returns one object by `id` formated with the specified view,
52
+ * or `undefined` if the object was not found.
53
+ * - The formating process can impact performance. If you just need
54
+ * the raw obj, it's recommended to use `readOne` instead.
55
+ */
27
56
  async viewOne(id, view = 'default') {
28
- const trx = trx_node_1.TrxNode.makeChildNode(this.parentTrx, this.bucket.schema.module, 'bucket', this.bucket.schema.name);
29
- await trx_node_1.TrxNode.open(trx, 'viewOne', { id, view });
30
- let obj;
31
- try {
32
- obj = await this.bucket.viewOne(trx, id, view);
33
- }
34
- catch (e) {
35
- await trx_node_1.TrxNode.error(trx, e); // Bucket unexpected error
36
- throw e;
37
- }
38
- await trx_node_1.TrxNode.ok(trx, obj);
39
- return obj;
57
+ return this.wrap('viewOne', { id }, trx => this.bucket.viewOne(trx, id, view, {
58
+ silent: true,
59
+ no_tenancy: !this.enableTenancy
60
+ }));
40
61
  }
62
+ /**
63
+ * Returns one object by `id`, without pre-formatting,
64
+ * or **throws an exception** if the object was not found.
65
+ */
41
66
  async readOneOrFail(id) {
42
- const trx = trx_node_1.TrxNode.makeChildNode(this.parentTrx, this.bucket.schema.module, 'bucket', this.bucket.schema.name);
43
- await trx_node_1.TrxNode.open(trx, 'readOneOrFail', { id });
44
- let obj;
45
- try {
46
- obj = await this.bucket.readOne(trx, id);
47
- }
48
- catch (e) {
49
- await trx_node_1.TrxNode.error(trx, e); // Bucket unexpected error
50
- throw e;
51
- }
52
- if (!obj) {
53
- const e = error_1.NesoiError.Bucket.ObjNotFound({ bucket: this.bucket.schema.alias, id: id });
54
- await trx_node_1.TrxNode.error(trx, e);
55
- throw e;
56
- }
57
- await trx_node_1.TrxNode.ok(trx, obj);
58
- return obj;
67
+ return this.wrap('readOneOrFail', { id }, trx => this.bucket.readOne(trx, id, {
68
+ no_tenancy: !this.enableTenancy
69
+ }));
59
70
  }
71
+ /**
72
+ * Returns one object by `id`, without pre-formatting,
73
+ * or **throws an exception** if the object was not found.
74
+ * - The formating process can impact performance. If you just need
75
+ * the raw obj, it's recommended to use `readOneOrFail` instead.
76
+ */
60
77
  async viewOneOrFail(id, view = 'default') {
61
- const trx = trx_node_1.TrxNode.makeChildNode(this.parentTrx, this.bucket.schema.module, 'bucket', this.bucket.schema.name);
62
- await trx_node_1.TrxNode.open(trx, 'viewOneOrFail', { id, view });
63
- let obj;
64
- try {
65
- obj = await this.bucket.viewOne(trx, id, view);
66
- }
67
- catch (e) {
68
- await trx_node_1.TrxNode.error(trx, e); // Bucket unexpected error
69
- throw e;
70
- }
71
- if (!obj) {
72
- const e = error_1.NesoiError.Bucket.ObjNotFound({ bucket: this.bucket.schema.alias, id: id });
73
- await trx_node_1.TrxNode.error(trx, e);
74
- throw e;
75
- }
76
- await trx_node_1.TrxNode.ok(trx, obj);
77
- return obj;
78
+ return this.wrap('viewOneOrFail', { id }, trx => this.bucket.viewOne(trx, id, view, {
79
+ no_tenancy: !this.enableTenancy
80
+ }));
78
81
  }
79
- // All
80
- async readAll(pagination, order) {
81
- const trx = trx_node_1.TrxNode.makeChildNode(this.parentTrx, this.bucket.schema.module, 'bucket', this.bucket.schema.name);
82
- await trx_node_1.TrxNode.open(trx, 'readAll', { pagination, order });
83
- let objs;
84
- try {
85
- objs = await this.bucket.readAll(trx, pagination, order);
86
- }
87
- catch (e) {
88
- await trx_node_1.TrxNode.error(trx, e); // Bucket unexpected error
89
- throw e;
90
- }
91
- await trx_node_1.TrxNode.ok(trx, { length: objs.length });
92
- return objs;
82
+ /*
83
+ Read/View All
84
+ */
85
+ /**
86
+ * Returns a list of all objects, without pre-formatting.
87
+ */
88
+ async readAll() {
89
+ return this.wrap('readAll', {}, trx => this.bucket.readAll(trx, {
90
+ no_tenancy: !this.enableTenancy
91
+ }), objs => ({ length: objs.length }));
93
92
  }
94
- async viewAll(view = 'default', pagination, order) {
95
- const trx = trx_node_1.TrxNode.makeChildNode(this.parentTrx, this.bucket.schema.module, 'bucket', this.bucket.schema.name);
96
- await trx_node_1.TrxNode.open(trx, 'viewAll', { view, pagination, order });
97
- let objs;
98
- try {
99
- objs = await this.bucket.viewAll(trx, view, pagination, order);
100
- }
101
- catch (e) {
102
- await trx_node_1.TrxNode.error(trx, e); // Bucket unexpected error
103
- throw e;
104
- }
105
- await trx_node_1.TrxNode.ok(trx, { length: objs.length });
106
- return objs;
93
+ /**
94
+ * Returns a list of all objects formated with the specified view.
95
+ * - The formating process can impact performance. If you just need
96
+ * the raw obj, it's recommended to use `readAll` instead.
97
+ */
98
+ async viewAll(view = 'default') {
99
+ return this.wrap('viewAll', {}, trx => this.bucket.viewAll(trx, view, {
100
+ no_tenancy: !this.enableTenancy
101
+ }), objs => ({ length: objs.length }));
107
102
  }
108
- // Query
103
+ /*
104
+ Query
105
+ */
106
+ /**
107
+ * Returns a list containing the results of the query.
108
+ */
109
109
  query(query, view = 'default') {
110
110
  const trx = trx_node_1.TrxNode.makeChildNode(this.parentTrx, this.bucket.schema.module, 'bucket', this.bucket.schema.name);
111
- return new bucket_query_trx_node_1.BucketQueryTrxNode(trx, this.bucket, query, view);
111
+ return new bucket_query_trx_node_1.BucketQueryTrxNode(trx, this.bucket, query, view, this.enableTenancy);
112
112
  }
113
- // Graph Links
114
- async readLink(id, link, view = 'default') {
115
- const trx = trx_node_1.TrxNode.makeChildNode(this.parentTrx, this.bucket.schema.module, 'bucket', this.bucket.schema.name);
116
- await trx_node_1.TrxNode.open(trx, 'readLink', { id, link });
117
- let obj;
118
- let linkObj;
119
- try {
120
- obj = await this.bucket.readOne(trx, id);
121
- if (!obj) {
122
- const schema = this.bucket.schema.graph.links[link];
123
- if (schema.many) {
124
- return [];
125
- }
126
- return undefined;
127
- }
128
- linkObj = await this.bucket.graph.readLink(trx, link, obj, view);
129
- }
130
- catch (e) {
131
- await trx_node_1.TrxNode.error(trx, e); // Bucket unexpected error
132
- throw e;
133
- }
134
- await trx_node_1.TrxNode.ok(trx, linkObj);
135
- return linkObj;
113
+ /*
114
+ Graph
115
+ */
116
+ /**
117
+ * Returns one or more objects referenced by the graph link,
118
+ * or `undefined` if the graph link doesn't resolve.
119
+ */
120
+ async readLink(id, link) {
121
+ return this.wrap('readLink', { id, link }, trx => this.bucket.readLink(trx, id, link, {
122
+ silent: true,
123
+ no_tenancy: !this.enableTenancy
124
+ }));
136
125
  }
137
- async readLinkOrFail(id, link, view = 'default') {
138
- const trx = trx_node_1.TrxNode.makeChildNode(this.parentTrx, this.bucket.schema.module, 'bucket', this.bucket.schema.name);
139
- await trx_node_1.TrxNode.open(trx, 'readLinkOrFail', { id, link });
140
- let obj;
141
- let linkObj;
142
- try {
143
- obj = await this.bucket.readOne(trx, id);
144
- if (!obj) {
145
- const e = error_1.NesoiError.Bucket.ObjNotFound({ bucket: this.bucket.schema.alias, id: id });
146
- await trx_node_1.TrxNode.error(trx, e);
147
- throw e;
148
- }
149
- linkObj = await this.bucket.graph.readLink(trx, link, obj, view);
150
- if (!linkObj) {
151
- const e = error_1.NesoiError.Bucket.Graph.LinkNotFound({ bucket: this.bucket.schema.alias, link: link });
152
- await trx_node_1.TrxNode.error(trx, e);
153
- throw e;
154
- }
155
- }
156
- catch (e) {
157
- await trx_node_1.TrxNode.error(trx, e); // Bucket unexpected error
158
- throw e;
159
- }
160
- await trx_node_1.TrxNode.ok(trx);
161
- return linkObj;
126
+ /**
127
+ * Returns one or more objects referenced by the graph link built with a view,
128
+ * or `undefined` if the graph link doesn't resolve.
129
+ */
130
+ async viewLink(id, link, view = 'default') {
131
+ return this.wrap('viewLink', { id, link, view }, trx => this.bucket.viewLink(trx, id, link, view, {
132
+ silent: true,
133
+ no_tenancy: !this.enableTenancy
134
+ }));
162
135
  }
163
- async hasLink(id, link) {
164
- const trx = trx_node_1.TrxNode.makeChildNode(this.parentTrx, this.bucket.schema.module, 'bucket', this.bucket.schema.name);
165
- await trx_node_1.TrxNode.open(trx, 'hasLink', { id, link });
166
- let obj;
167
- let result;
168
- try {
169
- obj = await this.bucket.readOne(trx, id);
170
- if (!obj) {
171
- return undefined;
172
- }
173
- result = await this.bucket.graph.hasLink(trx, id, obj);
174
- }
175
- catch (e) {
176
- await trx_node_1.TrxNode.error(trx, e); // Bucket unexpected error
177
- throw e;
178
- }
179
- await trx_node_1.TrxNode.ok(trx, { result });
180
- return result;
136
+ /**
137
+ * Returns one or more objects referenced by the graph link,
138
+ * or **throws an exception** if the graph link doesn't resolve.
139
+ */
140
+ async readLinkOrFail(id, link) {
141
+ return this.wrap('readLinkOrFail', { id, link }, trx => this.bucket.readLink(trx, id, link, {
142
+ no_tenancy: !this.enableTenancy
143
+ }));
181
144
  }
182
- // Put / Create / Update
183
145
  /**
184
- * Updates an object by passing it directly to the bucket adapter,
185
- * without checking if it exists. This creates an object if a new
186
- * id is passed.
146
+ * Returns one or more objects referenced by the graph link built with a view,
147
+ * or **throws an exception** if the graph link doesn't resolve.
187
148
  */
188
- async put(obj) {
189
- const trx = trx_node_1.TrxNode.makeChildNode(this.parentTrx, this.bucket.schema.module, 'bucket', this.bucket.schema.name);
190
- await trx_node_1.TrxNode.open(trx, 'put', { obj });
191
- let _obj;
192
- try {
193
- _obj = await this.bucket.put(trx, obj);
194
- }
195
- catch (e) {
196
- await trx_node_1.TrxNode.error(trx, e); // Bucket unexpected error
197
- throw e;
198
- }
199
- await trx_node_1.TrxNode.ok(trx);
200
- return _obj;
149
+ async viewLinkOrFail(id, link, view = 'default') {
150
+ return this.wrap('viewLinkOrFail', { id, link, view }, trx => this.bucket.viewLink(trx, id, link, view, {
151
+ no_tenancy: !this.enableTenancy
152
+ }));
201
153
  }
202
154
  /**
203
- * Creates an object by passing it to the bucket adapter,
204
- * without an ID (it's removed if passed).
205
- * This is a safer version of `put`, which ensures no update will happen.
155
+ * Returns `true` if the graph link resolves to at least 1 object.
156
+ */
157
+ async hasLink(id, link) {
158
+ return this.wrap('hasLink', { id, link }, trx => this.bucket.hasLink(trx, id, link, {
159
+ no_tenancy: !this.enableTenancy
160
+ }));
161
+ }
162
+ /*
163
+ Create
164
+ */
165
+ /**
166
+ * Creates an object by passing it to the bucket adapter.
167
+ * Also creates the compositions of this bucket, from the
168
+ * `#composition` field passed in the message.
169
+ *
170
+ * - If `#composition` is wrong, this will throw an exception
206
171
  */
207
172
  async create(obj) {
208
- delete obj['id'];
209
- const trx = trx_node_1.TrxNode.makeChildNode(this.parentTrx, this.bucket.schema.module, 'bucket', this.bucket.schema.name);
210
- await trx_node_1.TrxNode.open(trx, 'create', { obj });
211
- const composition = obj['#composition'] || {};
212
- delete obj['#composition'];
213
- const input = Object.assign({}, this.bucket.schema.model.defaults, obj);
214
- let _obj;
215
- try {
216
- _obj = await this.bucket.put(trx, input);
217
- // Composition
218
- for (const link of Object.values(this.bucket.schema.graph.links)) {
219
- if (link.rel !== 'composition')
220
- continue;
221
- const linkObj = composition[link.name];
222
- if (!linkObj) {
223
- const e = error_1.NesoiError.Bucket.MissingComposition({ method: 'create', bucket: this.bucket.schema.name, link: link.name });
224
- await trx_node_1.TrxNode.error(trx, e);
225
- throw e;
226
- }
227
- if (link.many) {
228
- if (!Array.isArray(linkObj)) {
229
- const e = error_1.NesoiError.Bucket.CompositionValueShouldBeArray({ method: 'create', bucket: this.bucket.schema.name, link: link.name });
230
- await trx_node_1.TrxNode.error(trx, e);
231
- throw e;
232
- }
233
- for (const linkObjItem of linkObj) {
234
- await trx.bucket(link.bucket.refName).create(linkObjItem);
235
- }
236
- }
237
- else {
238
- await trx.bucket(link.bucket.refName).create(linkObj);
239
- }
240
- }
241
- }
242
- catch (e) {
243
- await trx_node_1.TrxNode.error(trx, e); // Bucket unexpected error
244
- throw e;
245
- }
246
- await trx_node_1.TrxNode.ok(trx);
247
- return _obj;
173
+ return this.wrap('create', { obj }, trx => this.bucket.create(trx, obj), () => undefined);
174
+ }
175
+ /*
176
+ Update (Patch, Replace)
177
+ */
178
+ /**
179
+ * Reads one object by `id` and `patch` (modify) it based on the one passed as an argument.
180
+ * Also patches the compositions of this bucket, from the
181
+ * `#composition` field passed in the message.
182
+ *
183
+ * - If the object is not found, this will throw an exception
184
+ * - If `#composition` is wrong, this will throw an exception
185
+ * - The read query before updating might impact performance and be unnecessary
186
+ * when you're updating from code that's sure the object exists. In that case,
187
+ * you can use `unsafe.patch`, which doesn't read prior to writing.
188
+ */
189
+ async patch(obj) {
190
+ return this.wrap('patch', { obj }, trx => this.bucket.update(trx, obj, {
191
+ mode: 'patch',
192
+ no_tenancy: !this.enableTenancy
193
+ }), () => undefined);
248
194
  }
249
195
  /**
250
- * Reads the id from the bucket adapter to ensure the object exists
251
- * before updating.
252
- * This is a safer version of `put`, suited for updating data.
196
+ * Reads one object by `id` and `replace` it with the one passed as an argument.
197
+ * Also patches the compositions of this bucket, from the
198
+ * `#composition` field passed in the message.
199
+ *
200
+ * - If the object is not found, this will throw an exception
201
+ * - If `#composition` is wrong, this will throw an exception
202
+ * - The read query before updating might impact performance and be unnecessary
203
+ * when you're updating from code that's sure the object exists. In that case,
204
+ * you can use `unsafe.replace`, which doesn't read prior to writing.
253
205
  */
254
206
  async replace(obj) {
255
- const trx = trx_node_1.TrxNode.makeChildNode(this.parentTrx, this.bucket.schema.module, 'bucket', this.bucket.schema.name);
256
- await trx_node_1.TrxNode.open(trx, 'replace', { obj });
257
- const composition = obj['#composition'] || {};
258
- delete obj['#composition'];
259
- let newObj;
260
- try {
261
- const oldObj = await this.bucket.readOne(trx, obj['id']);
262
- if (!oldObj) {
263
- const e = error_1.NesoiError.Bucket.ObjNotFound({ bucket: this.bucket.schema.alias, id: obj['id'] });
264
- await trx_node_1.TrxNode.error(trx, e);
265
- throw e;
266
- }
267
- newObj = await this.bucket.put(trx, obj);
268
- // Composition
269
- for (const link of Object.values(this.bucket.schema.graph.links)) {
270
- if (link.rel !== 'composition')
271
- continue;
272
- const linkObj = composition[link.name];
273
- if (!linkObj) {
274
- const e = error_1.NesoiError.Bucket.MissingComposition({ method: 'replace', bucket: this.bucket.schema.name, link: link.name });
275
- await trx_node_1.TrxNode.error(trx, e);
276
- throw e;
277
- }
278
- if (link.many) {
279
- if (!Array.isArray(linkObj)) {
280
- const e = error_1.NesoiError.Bucket.CompositionValueShouldBeArray({ method: 'replace', bucket: this.bucket.schema.name, link: link.name });
281
- await trx_node_1.TrxNode.error(trx, e);
282
- throw e;
283
- }
284
- for (const linkObjItem of linkObj) {
285
- await trx.bucket(link.bucket.refName).replace(linkObjItem);
286
- }
287
- }
288
- else {
289
- await trx.bucket(link.bucket.refName).replace(linkObj);
290
- }
291
- }
292
- }
293
- catch (e) {
294
- await trx_node_1.TrxNode.error(trx, e); // Bucket unexpected error
295
- throw e;
296
- }
297
- await trx_node_1.TrxNode.ok(trx);
298
- return newObj;
207
+ return this.wrap('replace', { obj }, trx => this.bucket.update(trx, obj, {
208
+ mode: 'replace',
209
+ no_tenancy: !this.enableTenancy
210
+ }), () => undefined);
211
+ }
212
+ /*
213
+ Put
214
+ */
215
+ /**
216
+ * Creates or replaces (by `id`) the object passed as an argument.
217
+ * Does the same for compositions of this bucket, from the
218
+ * `#composition` field passed in the message.
219
+ *
220
+ * - If `#composition` is wrong, this will throw an exception.
221
+ * - This will **REPLACE** objects and it's compositions if they already exist,
222
+ * so there might be unexpected data loss, use it carefully.
223
+ *
224
+ * **WARNING** Tenancy currently not implemented for put.
225
+ */
226
+ async put(obj) {
227
+ return this.wrap('put', { obj }, trx => this.bucket.put(trx, obj), () => undefined);
299
228
  }
229
+ /*
230
+ Delete
231
+ */
300
232
  /**
301
- * Reads the id from the bucket adapter to ensure the object exists
302
- * before updating. Applies changes to the object instead of replacing it.
233
+ * Attempts to read an object by `id`, if found, deletes it.
234
+ *
235
+ * - If you want to skip the read query, use the `unsafe.delete` method,
236
+ * so the behavior depends on the bucket used.
237
+ */
238
+ async delete(id) {
239
+ return this.wrap('delete', { id }, trx => this.bucket.delete(trx, id, {
240
+ no_tenancy: !this.enableTenancy
241
+ }), () => undefined);
242
+ }
243
+ /**
244
+ * Attempts to read an object by `id`, if found, deletes it.
245
+ *
246
+ * - If you want to skip the read query, use the `unsafe.delete` method,
247
+ * so the behavior depends on the bucket used.
248
+ */
249
+ async deleteMany(ids) {
250
+ return this.wrap('deleteMany', { ids }, trx => this.bucket.deleteMany(trx, ids, {
251
+ no_tenancy: !this.enableTenancy
252
+ }), () => undefined);
253
+ }
254
+ /*
255
+ Build
256
+ */
257
+ async buildOne(obj, view) {
258
+ return this.wrap('buildOne', { obj }, trx => this.bucket.buildOne(trx, obj, view), () => undefined);
259
+ }
260
+ async buildMany(objs, view) {
261
+ return this.wrap('buildMany', { objs }, trx => this.bucket.buildMany(trx, objs, view), () => undefined);
262
+ }
263
+ /*
264
+ Drive
265
+ */
266
+ /**
267
+ * Methods to use the Bucket's drive (file storage).
268
+ */
269
+ get drive() {
270
+ return new BucketDriveTrxNode(this, this.bucket);
271
+ }
272
+ /*
273
+ Unsafe
274
+ */
275
+ /**
276
+ * Unsafe versions of methods, which improve performance
277
+ * by avoiding some validations and queries.
278
+ *
279
+ * **Use it carefully.**
280
+ */
281
+ get unsafe() {
282
+ return new BucketUnsafeTrxNode(this, this.bucket, this.enableTenancy);
283
+ }
284
+ }
285
+ exports.BucketTrxNode = BucketTrxNode;
286
+ class BucketUnsafeTrxNode {
287
+ constructor(bucketTrx, bucket, enableTenancy) {
288
+ this.bucketTrx = bucketTrx;
289
+ this.bucket = bucket;
290
+ this.enableTenancy = enableTenancy;
291
+ }
292
+ /*
293
+ Modifiers
294
+ */
295
+ get no_tenancy() {
296
+ this.enableTenancy = false;
297
+ return this;
298
+ }
299
+ /*
300
+ Update (Patch, Replace)
301
+ */
302
+ /**
303
+ * Directly `patch` (modify) an object based on the one passed as an argument.
304
+ * Also patches the compositions of this bucket, from the
305
+ * `#composition` field passed in the message.
306
+ *
307
+ * > This unsafe version does not check if the object exists prior to patching.
308
+ *
309
+ * - If the object is not found, this will throw an exception
310
+ * - If `#composition` is wrong, this will throw an exception
303
311
  */
304
312
  async patch(obj) {
305
- const trx = trx_node_1.TrxNode.makeChildNode(this.parentTrx, this.bucket.schema.module, 'bucket', this.bucket.schema.name);
306
- await trx_node_1.TrxNode.open(trx, 'patch', { obj });
307
- const composition = obj['#composition'] || {};
308
- delete obj['#composition'];
309
- let newObj;
310
- try {
311
- const oldObj = await this.bucket.readOne(trx, obj['id']);
312
- if (!oldObj) {
313
- const e = error_1.NesoiError.Bucket.ObjNotFound({ bucket: this.bucket.schema.alias, id: obj['id'] });
314
- await trx_node_1.TrxNode.error(trx, e);
315
- throw e;
316
- }
317
- // TODO: deep merge
318
- const putObj = Object.assign({}, oldObj, obj);
319
- newObj = await this.bucket.put(trx, putObj);
320
- // Composition
321
- for (const link of Object.values(this.bucket.schema.graph.links)) {
322
- if (link.rel !== 'composition')
323
- continue;
324
- const linkObj = composition[link.name];
325
- if (!linkObj) {
326
- const e = error_1.NesoiError.Bucket.MissingComposition({ method: 'patch', bucket: this.bucket.schema.name, link: link.name });
327
- await trx_node_1.TrxNode.error(trx, e);
328
- throw e;
329
- }
330
- if (link.many) {
331
- if (!Array.isArray(linkObj)) {
332
- const e = error_1.NesoiError.Bucket.CompositionValueShouldBeArray({ method: 'patch', bucket: this.bucket.schema.name, link: link.name });
333
- await trx_node_1.TrxNode.error(trx, e);
334
- throw e;
335
- }
336
- for (const linkObjItem of linkObj) {
337
- await trx.bucket(link.bucket.refName).patch(linkObjItem);
338
- }
339
- }
340
- else {
341
- await trx.bucket(link.bucket.refName).patch(linkObj);
342
- }
343
- }
344
- }
345
- catch (e) {
346
- await trx_node_1.TrxNode.error(trx, e); // Bucket unexpected error
347
- throw e;
348
- }
349
- await trx_node_1.TrxNode.ok(trx);
350
- return newObj;
313
+ return this.bucketTrx.wrap('patch', { obj }, trx => this.bucket.update(trx, obj, {
314
+ mode: 'patch',
315
+ unsafe: true,
316
+ no_tenancy: !this.enableTenancy
317
+ }), () => undefined);
351
318
  }
352
- // Delete
319
+ /**
320
+ * Directly `replace` on object with the one passed as an argument.
321
+ * Also replaces the compositions of this bucket, from the
322
+ * `#composition` field passed in the message.
323
+ *
324
+ * > This unsafe version does not check if the object exists prior to replacing.
325
+ *
326
+ * - If the object is not found, this will throw an exception
327
+ * - If `#composition` is wrong, this will throw an exception
328
+ */
329
+ async replace(obj) {
330
+ return this.bucketTrx.wrap('replace', { obj }, trx => this.bucket.update(trx, obj, {
331
+ mode: 'replace',
332
+ unsafe: true,
333
+ no_tenancy: !this.enableTenancy
334
+ }), () => undefined);
335
+ }
336
+ /*
337
+ Delete
338
+ */
339
+ /**
340
+ * Deletes an object
341
+ *
342
+ * > This unsafe version does not check if the object exists prior to deleting.
343
+ */
353
344
  async delete(id) {
354
- const trx = trx_node_1.TrxNode.makeChildNode(this.parentTrx, this.bucket.schema.module, 'bucket', this.bucket.schema.name);
355
- await trx_node_1.TrxNode.open(trx, 'delete', { id });
356
- try {
357
- // Composition (with other key)
358
- for (const link of Object.values(this.bucket.schema.graph.links)) {
359
- if (link.rel !== 'composition')
360
- continue;
361
- if (link.keyOwner !== 'other')
362
- continue;
363
- const linked = await this.readLink(id, link.name);
364
- if (link.many) {
365
- for (const linkedItem of linked) {
366
- await trx.bucket(link.bucket.refName).delete(linkedItem.id);
367
- }
368
- }
369
- else {
370
- await trx.bucket(link.bucket.refName).delete(linked.id);
371
- }
372
- }
373
- // The object itself
374
- await this.bucket.delete(trx, id);
375
- // Composition (with self key)
376
- for (const link of Object.values(this.bucket.schema.graph.links)) {
377
- if (link.rel !== 'composition')
378
- continue;
379
- if (link.keyOwner !== 'self')
380
- continue;
381
- const linked = await this.readLink(id, link.name);
382
- if (link.many) {
383
- await trx.bucket(link.bucket.refName).deleteMany(linked.map((l) => l.id));
384
- }
385
- else {
386
- await trx.bucket(link.bucket.refName).delete(linked.id);
387
- }
388
- }
389
- }
390
- catch (e) {
391
- await trx_node_1.TrxNode.error(trx, e); // Bucket unexpected error
392
- throw e;
393
- }
394
- await trx_node_1.TrxNode.ok(trx);
345
+ return this.bucketTrx.wrap('delete', { id }, trx => this.bucket.delete(trx, id, {
346
+ unsafe: true,
347
+ no_tenancy: !this.enableTenancy
348
+ }), () => undefined);
395
349
  }
396
350
  /**
397
- * **WARNING**: This does not currently implement composition
351
+ * Attempts to read an object by `id`, if found, deletes it.
352
+ *
353
+ * > This unsafe version does not check if the objects exist prior to deleting.
398
354
  */
399
355
  async deleteMany(ids) {
400
- const trx = trx_node_1.TrxNode.makeChildNode(this.parentTrx, this.bucket.schema.module, 'bucket', this.bucket.schema.name);
401
- await trx_node_1.TrxNode.open(trx, 'deleteMany', { ids });
402
- try {
403
- // Composition (with other key)
404
- for (const link of Object.values(this.bucket.schema.graph.links)) {
405
- if (link.rel !== 'composition')
406
- continue;
407
- if (link.keyOwner !== 'other')
408
- continue;
409
- for (const id of ids) {
410
- const linked = await this.readLink(id, link.name);
411
- if (link.many) {
412
- await trx.bucket(link.bucket.refName).deleteMany(linked.map((l) => l.id));
413
- }
414
- else {
415
- await trx.bucket(link.bucket.refName).delete(linked.id);
416
- }
417
- }
418
- }
419
- await this.bucket.deleteMany(trx, ids);
420
- // Composition (with self key)
421
- for (const link of Object.values(this.bucket.schema.graph.links)) {
422
- if (link.rel !== 'composition')
423
- continue;
424
- if (link.keyOwner !== 'self')
425
- continue;
426
- for (const id of ids) {
427
- const linked = await this.readLink(id, link.name);
428
- if (link.many) {
429
- await trx.bucket(link.bucket.refName).deleteMany(linked.map((l) => l.id));
430
- }
431
- else {
432
- await trx.bucket(link.bucket.refName).delete(linked.id);
433
- }
434
- }
435
- }
436
- }
437
- catch (e) {
438
- await trx_node_1.TrxNode.error(trx, e); // Bucket unexpected error
439
- throw e;
356
+ return this.bucketTrx.wrap('deleteMany', { ids }, trx => this.bucket.deleteMany(trx, ids, {
357
+ unsafe: true,
358
+ no_tenancy: !this.enableTenancy
359
+ }), () => undefined);
360
+ }
361
+ }
362
+ exports.BucketUnsafeTrxNode = BucketUnsafeTrxNode;
363
+ class BucketDriveTrxNode {
364
+ constructor(bucketTrx, bucket) {
365
+ this.bucketTrx = bucketTrx;
366
+ this.bucket = bucket;
367
+ if (!this.bucket.drive) {
368
+ throw error_1.NesoiError.Bucket.Drive.NoAdapter({ bucket: this.bucket.schema.alias });
440
369
  }
441
- await trx_node_1.TrxNode.ok(trx);
442
370
  }
443
- async deleteOrFail(id) {
444
- const trx = trx_node_1.TrxNode.makeChildNode(this.parentTrx, this.bucket.schema.module, 'bucket', this.bucket.schema.name);
445
- await trx_node_1.TrxNode.open(trx, 'deleteOrFail', { id });
371
+ /**
372
+ * Read the contents of a File of this bucket's drive
373
+ */
374
+ read(file, options) {
446
375
  try {
447
- // Composition (with other key)
448
- for (const link of Object.values(this.bucket.schema.graph.links)) {
449
- if (link.rel !== 'composition')
450
- continue;
451
- if (link.keyOwner !== 'other')
452
- continue;
453
- const linked = await this.readLink(id, link.name);
454
- if (link.many) {
455
- for (const linkedItem of linked) {
456
- await trx.bucket(link.bucket.refName).deleteOrFail(linkedItem.id);
457
- }
458
- }
459
- else {
460
- await trx.bucket(link.bucket.refName).deleteOrFail(linked.id);
461
- }
462
- }
463
- const obj = await this.bucket.readOne(trx, id);
464
- if (!obj) {
465
- const e = error_1.NesoiError.Bucket.ObjNotFound({ bucket: this.bucket.schema.alias, id: id });
466
- await trx_node_1.TrxNode.error(trx, e);
467
- throw e;
468
- }
469
- await this.bucket.delete(trx, id);
470
- // Composition (with self key)
471
- for (const link of Object.values(this.bucket.schema.graph.links)) {
472
- if (link.rel !== 'composition')
473
- continue;
474
- if (link.keyOwner !== 'self')
475
- continue;
476
- const linked = await this.readLink(id, link.name);
477
- if (link.many) {
478
- for (const linkedItem of linked) {
479
- await trx.bucket(link.bucket.refName).deleteOrFail(linkedItem.id);
480
- }
481
- }
482
- else {
483
- await trx.bucket(link.bucket.refName).deleteOrFail(linked.id);
484
- }
485
- }
376
+ return this.bucket.drive.read(file);
486
377
  }
487
378
  catch (e) {
488
- await trx_node_1.TrxNode.error(trx, e); // Bucket unexpected error
379
+ if (options?.silent) {
380
+ console.error(e);
381
+ return;
382
+ }
489
383
  throw e;
490
384
  }
491
- await trx_node_1.TrxNode.ok(trx);
492
385
  }
493
- async buildOne(obj, view) {
494
- const trx = trx_node_1.TrxNode.makeChildNode(this.parentTrx, this.bucket.schema.module, 'bucket', this.bucket.schema.name);
495
- await trx_node_1.TrxNode.open(trx, 'buildOne', { obj });
496
- let result;
386
+ /**
387
+ * Move the file on disk
388
+ */
389
+ move(file, to, options) {
497
390
  try {
498
- result = await this.bucket.buildOne(trx, obj, view);
391
+ return this.bucket.drive.move(file, to);
499
392
  }
500
393
  catch (e) {
501
- await trx_node_1.TrxNode.error(trx, e); // Bucket unexpected error
394
+ if (options?.silent) {
395
+ console.error(e);
396
+ return;
397
+ }
502
398
  throw e;
503
399
  }
504
- await trx_node_1.TrxNode.ok(trx);
505
- return result;
506
400
  }
507
- async buildAll(objs, view) {
508
- const trx = trx_node_1.TrxNode.makeChildNode(this.parentTrx, this.bucket.schema.module, 'bucket', this.bucket.schema.name);
509
- await trx_node_1.TrxNode.open(trx, 'buildAll', { objs });
510
- let result;
401
+ /**
402
+ * Delete a file of this bucket's drive
403
+ */
404
+ delete(file, options) {
511
405
  try {
512
- result = await this.bucket.buildAll(trx, objs, view);
406
+ return this.bucket.drive.delete(file);
513
407
  }
514
408
  catch (e) {
515
- await trx_node_1.TrxNode.error(trx, e); // Bucket unexpected error
409
+ if (options?.silent) {
410
+ console.error(e);
411
+ return;
412
+ }
516
413
  throw e;
517
414
  }
518
- await trx_node_1.TrxNode.ok(trx);
519
- return result;
520
415
  }
521
416
  }
522
- exports.BucketTrxNode = BucketTrxNode;
417
+ exports.BucketDriveTrxNode = BucketDriveTrxNode;