@facteurjs/core 1.0.0-beta.1 → 1.0.0-beta.2

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.
@@ -14,7 +14,8 @@ const getNotificationRoute = defineRoute(({ facteur }) => ({
14
14
  tenantId: request.query.tenantId,
15
15
  page: request.query.page,
16
16
  limit: request.query.limit,
17
- status: request.query.status
17
+ status: request.query.status,
18
+ tags: request.query.tags ? JSON.parse(request.query.tags) : void 0
18
19
  });
19
20
  return {
20
21
  status: 200,
@@ -31,8 +31,9 @@ var KnexAdapter = class {
31
31
  const limit = Math.min(options.limit || 10, 100);
32
32
  const offset = (page - 1) * limit;
33
33
  let query = this.#connection.table(this.#tableName).where("notifiable_id", options.notifiableId);
34
- if (options.tenantId) query = query.where("tenant_id", options.tenantId);
35
- if (options.status) query = query.where("status", options.status);
34
+ if (options.tenantId) query.where("tenant_id", options.tenantId);
35
+ if (options.status) query.where("status", options.status);
36
+ if (options.tags) query.whereJsonSupersetOf("tags", JSON.stringify(options.tags));
36
37
  const results = await query.orderBy("created_at", "desc").limit(limit).offset(offset).select("*");
37
38
  return results.map((row) => ({
38
39
  id: row.id,
@@ -30,7 +30,7 @@ var KyselyAdapter = class {
30
30
  const page = options.page || 1;
31
31
  const limit = Math.min(options.limit || 10, 100);
32
32
  const offset = (page - 1) * limit;
33
- const results = await this.#connection.selectFrom(this.#tableName).selectAll().where("notifiable_id", "=", options.notifiableId).$if(!!options.tenantId, (qb) => qb.where("tenant_id", "=", options.tenantId)).$if(!!options.status, (qb) => qb.where("status", "=", options.status)).orderBy("created_at", "desc").limit(limit).offset(offset).execute();
33
+ const results = await this.#connection.selectFrom(this.#tableName).selectAll().where("notifiable_id", "=", options.notifiableId).$if(!!options.tenantId, (qb) => qb.where("tenant_id", "=", options.tenantId)).$if(!!options.status, (qb) => qb.where("status", "=", options.status)).$if(!!options.tags, (qb) => qb.where("tags", "@>", JSON.stringify(options.tags))).orderBy("created_at", "desc").limit(limit).offset(offset).execute();
34
34
  return results.map((row) => ({
35
35
  id: row.id,
36
36
  notifiableId: row.notifiable_id,
@@ -10,6 +10,7 @@ var FacteurDatabase = class {
10
10
  return this.options.databaseAdapter?.getNotifications({
11
11
  page,
12
12
  limit,
13
+ tags: options.tags,
13
14
  status: options.status,
14
15
  tenantId: options.tenantId,
15
16
  notifiableId: options.notifiableId
@@ -11,6 +11,7 @@ interface AdapterGetNotificationsParams {
11
11
  page?: number | undefined;
12
12
  status?: NotificationStatus | undefined;
13
13
  limit?: number;
14
+ tags?: string[] | undefined;
14
15
  }
15
16
  interface GetNotificationsParams {
16
17
  notifiableId: Identifier;
@@ -18,6 +19,7 @@ interface GetNotificationsParams {
18
19
  page?: number;
19
20
  limit?: number;
20
21
  status?: NotificationStatus;
22
+ tags?: string[];
21
23
  }
22
24
  interface Notification {
23
25
  id: Identifier;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@facteurjs/core",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.1",
4
+ "version": "1.0.0-beta.2",
5
5
  "description": "Core package for facteur",
6
6
  "author": "Julien Ripouteau <julien@ripouteau.com>",
7
7
  "license": "ISC",