@lobb-js/core 0.29.0 → 0.31.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
@@ -1 +1 @@
1
- # @lobb-js/core
1
+ # @lobb-js/core
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lobb-js/core",
3
3
  "license": "UNLICENSED",
4
- "version": "0.29.0",
4
+ "version": "0.31.0",
5
5
  "type": "module",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -46,12 +46,15 @@ export const collectionControllers: CollectionControllers = {
46
46
  });
47
47
  }
48
48
 
49
+ const dryRun = c.req.query("dry_run") !== undefined;
50
+
49
51
  const result = await Lobb.instance.collectionService.createOne({
50
52
  collectionName,
51
53
  context: c,
52
54
  data: body.data,
53
55
  children: body.children,
54
56
  triggeredBy: "API",
57
+ dryRun,
55
58
  });
56
59
 
57
60
  return c.json(result, 201);
@@ -209,6 +212,8 @@ export const collectionControllers: CollectionControllers = {
209
212
  }
210
213
  }
211
214
 
215
+ const dryRun = c.req.query("dry_run") !== undefined;
216
+
212
217
  const result = await Lobb.instance.collectionService.updateOne({
213
218
  collectionName,
214
219
  context: c,
@@ -216,6 +221,7 @@ export const collectionControllers: CollectionControllers = {
216
221
  data: body.data,
217
222
  children: body.children,
218
223
  triggeredBy: "API",
224
+ dryRun,
219
225
  });
220
226
  return c.json(result, 200);
221
227
  },
@@ -245,12 +251,15 @@ export const collectionControllers: CollectionControllers = {
245
251
  }
246
252
  }
247
253
 
254
+ const dryRun = c.req.query("dry_run") !== undefined;
255
+
248
256
  const result = await Lobb.instance.collectionService.deleteOne({
249
257
  collectionName,
250
258
  context: c,
251
259
  id,
252
260
  force,
253
261
  triggeredBy: "API",
262
+ dryRun,
254
263
  });
255
264
 
256
265
  return c.json(result);
@@ -234,6 +234,7 @@ export class CollectionStore {
234
234
  triggeredBy = "INTERNAL",
235
235
  context,
236
236
  client,
237
+ dryRun = false,
237
238
  }: {
238
239
  collectionName: string;
239
240
  data: Record<string, any>;
@@ -241,6 +242,7 @@ export class CollectionStore {
241
242
  triggeredBy?: TriggeredBy;
242
243
  context?: HonoContext;
243
244
  client?: PoolClient;
245
+ dryRun?: boolean;
244
246
  }): Promise<ExposedServiceOutput> {
245
247
  return await beginTransaction(
246
248
  async (client) => {
@@ -258,6 +260,7 @@ export class CollectionStore {
258
260
  context: context,
259
261
  triggeredBy: triggeredBy,
260
262
  transaction: client,
263
+ dryRun,
261
264
  },
262
265
  );
263
266
 
@@ -269,7 +272,6 @@ export class CollectionStore {
269
272
  );
270
273
  }
271
274
 
272
-
273
275
  data = (await Lobb.instance.eventSystem.emit(
274
276
  `core.store.createOne`,
275
277
  {
@@ -301,6 +303,7 @@ export class CollectionStore {
301
303
  triggeredBy = "INTERNAL",
302
304
  context,
303
305
  client,
306
+ dryRun = false,
304
307
  }: {
305
308
  collectionName: string;
306
309
  id: string;
@@ -309,6 +312,7 @@ export class CollectionStore {
309
312
  triggeredBy?: TriggeredBy;
310
313
  context?: HonoContext;
311
314
  client?: PoolClient;
315
+ dryRun?: boolean;
312
316
  }): Promise<ExposedServiceOutput> {
313
317
  return await beginTransaction(
314
318
  async (client) => {
@@ -321,8 +325,10 @@ export class CollectionStore {
321
325
  context: context,
322
326
  triggeredBy: triggeredBy,
323
327
  transaction: client,
328
+ dryRun,
324
329
  },
325
330
  );
331
+
326
332
  data = await this.dbDriver.updateOne(
327
333
  collectionName,
328
334
  result.id,
@@ -361,6 +367,7 @@ export class CollectionStore {
361
367
  triggeredBy = "INTERNAL",
362
368
  context,
363
369
  client,
370
+ dryRun = false,
364
371
  }: {
365
372
  collectionName: string;
366
373
  id: string;
@@ -368,6 +375,7 @@ export class CollectionStore {
368
375
  triggeredBy?: TriggeredBy;
369
376
  context?: HonoContext;
370
377
  client?: PoolClient;
378
+ dryRun?: boolean;
371
379
  },
372
380
  ): Promise<ExposedServiceOutput> {
373
381
  return await beginTransaction(
@@ -380,6 +388,7 @@ export class CollectionStore {
380
388
  context: context,
381
389
  triggeredBy: triggeredBy,
382
390
  transaction: client,
391
+ dryRun,
383
392
  },
384
393
  );
385
394
 
@@ -62,7 +62,7 @@ export class ConfigManager {
62
62
  } as any;
63
63
 
64
64
  // Convert the original field to virtual (drives the UI picker)
65
- collection.fields[fieldName] = { virtual: true, ui: { icon: "Shuffle" } } as any;
65
+ collection.fields[fieldName] = { virtual: true, ui: { icon: "GitFork" } } as any;
66
66
 
67
67
  // Auto-register the polymorphic relation
68
68
  if (!this.config.relations) this.config.relations = [];
@@ -9,6 +9,7 @@ import { enumWorkflows } from "./processors/enumWorkflows.ts";
9
9
  import { coerceAndValidateWorkflows } from "./processors/coerceAndValidateWorkflows.ts";
10
10
  import { coreWorkflowsCollectionWorkflows } from "./workflowsCollection/workflowsCollectionWorkflows.ts";
11
11
  import { getQueryCoreWorkflows } from "./queryCoreWorkflows.ts";
12
+ import { dryRunWorkflows } from "./processors/dryRunWorkflows.ts";
12
13
 
13
14
  export function getCoreWorkflows(): Array<Workflow> {
14
15
  return [
@@ -23,5 +24,6 @@ export function getCoreWorkflows(): Array<Workflow> {
23
24
  ...getCollectionsTableWorkflows(),
24
25
  ...getQueryCoreWorkflows(),
25
26
  ...getUtilsCoreWorkflows(),
27
+ ...dryRunWorkflows,
26
28
  ];
27
29
  }
@@ -0,0 +1,28 @@
1
+ import type { Workflow } from "../../WorkflowSystem.ts";
2
+
3
+ export const dryRunWorkflows: Workflow[] = [
4
+ {
5
+ name: "core_dryRunCreate",
6
+ eventName: "core.store.preCreateOne",
7
+ handler: async (input) => {
8
+ if (!input.dryRun) return input;
9
+ throw new Response(null, { status: 204 });
10
+ },
11
+ },
12
+ {
13
+ name: "core_dryRunUpdate",
14
+ eventName: "core.store.preUpdateOne",
15
+ handler: async (input) => {
16
+ if (!input.dryRun) return input;
17
+ throw new Response(null, { status: 204 });
18
+ },
19
+ },
20
+ {
21
+ name: "core_dryRunDelete",
22
+ eventName: "core.store.preDeleteOne",
23
+ handler: async (input) => {
24
+ if (!input.dryRun) return input;
25
+ throw new Response(null, { status: 204 });
26
+ },
27
+ },
28
+ ];