@facteurjs/adonisjs 1.0.0-beta.2 → 1.0.0-beta.4
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/dist/adonisjs/configure.d.ts +6 -0
- package/dist/adonisjs/configure.js +44 -0
- package/dist/adonisjs/stubs/index.js +5 -0
- package/dist/adonisjs/stubs/index.ts +1 -0
- package/dist/adonisjs/stubs/make/notification.stub +9 -0
- package/dist/adonisjs/stubs/migrations/notifications.stub +36 -0
- package/dist/adonisjs/stubs/migrations/preferences.stub +32 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/package.json +4 -5
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { stubsRoot } from "./stubs/index.js";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
5
|
+
|
|
6
|
+
//#region configure.ts
|
|
7
|
+
async function addSubpathImport(command) {
|
|
8
|
+
try {
|
|
9
|
+
const pkgJson = await readFile(join(fileURLToPath(command.app.appRoot), "package.json"), "utf-8");
|
|
10
|
+
const pkg = JSON.parse(pkgJson);
|
|
11
|
+
pkg.imports ??= {};
|
|
12
|
+
pkg.imports["#notifications/*"] = "./app/notifications/*.js";
|
|
13
|
+
await writeFile(join(fileURLToPath(command.app.appRoot), "package.json"), JSON.stringify(pkg, null, 2) + "\n");
|
|
14
|
+
} catch (error) {
|
|
15
|
+
command.logger.error("Failed to add subpath import in your package.json :" + error.message);
|
|
16
|
+
command.logger.error("Please add the following to your package.json:\n");
|
|
17
|
+
command.logger.error(`\n"imports": {\n "#notifications/*": "./app/notifications/*.js"\n},\n`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async function configure(command) {
|
|
21
|
+
const codemods = await command.createCodemods();
|
|
22
|
+
await codemods.makeUsingStub(stubsRoot, "config/notifications.stub", {});
|
|
23
|
+
await codemods.updateRcFile((rcFile) => {
|
|
24
|
+
rcFile.addProvider("@facteurjs/adonisjs/facteur_provider");
|
|
25
|
+
});
|
|
26
|
+
await addSubpathImport(command);
|
|
27
|
+
await codemods.makeUsingStub(stubsRoot, "migration.stub", {
|
|
28
|
+
entity: command.app.generators.createEntity("notifications"),
|
|
29
|
+
migration: {
|
|
30
|
+
folder: "database/migrations",
|
|
31
|
+
fileName: `${(/* @__PURE__ */ new Date()).getTime()}_create_notifications_table.ts`
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
await codemods.makeUsingStub(stubsRoot, "migrations/preferences.stub", {
|
|
35
|
+
entity: command.app.generators.createEntity("notifications_preferences"),
|
|
36
|
+
migration: {
|
|
37
|
+
folder: "database/migrations",
|
|
38
|
+
fileName: `${(/* @__PURE__ */ new Date()).getTime()}_create_notifications_preferences_table.ts`
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { configure };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const stubsRoot = import.meta.dirname
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({
|
|
3
|
+
to: app.makePath(app.rcFile.directories['notifications'], notificationFileName)
|
|
4
|
+
})
|
|
5
|
+
}}}
|
|
6
|
+
import User from '#models/user'
|
|
7
|
+
|
|
8
|
+
interface NotificationParams {}
|
|
9
|
+
export default class {{ notificationName }} extends Notification<User, NotificationParams> {}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({
|
|
3
|
+
to: app.makePath(migration.folder, entity.path, migration.fileName)
|
|
4
|
+
})
|
|
5
|
+
}}}
|
|
6
|
+
import { BaseSchema } from '@adonisjs/lucid/schema'
|
|
7
|
+
|
|
8
|
+
export default class extends BaseSchema {
|
|
9
|
+
protected tableName = 'notifications'
|
|
10
|
+
|
|
11
|
+
async up() {
|
|
12
|
+
this.schema.createTable(this.tableName, (table) => {
|
|
13
|
+
table.increments('id').primary()
|
|
14
|
+
table.text('notifiable_id').notNullable()
|
|
15
|
+
table.text('tenant_id').nullable()
|
|
16
|
+
table.text('type').notNullable()
|
|
17
|
+
table.jsonb('content').notNullable()
|
|
18
|
+
table.text('status').notNullable().defaultTo('unseen')
|
|
19
|
+
table.jsonb('tags').nullable()
|
|
20
|
+
table.timestamp('read_at').nullable()
|
|
21
|
+
table.timestamp('seen_at').nullable()
|
|
22
|
+
|
|
23
|
+
table.timestamp('created_at').notNullable()
|
|
24
|
+
table.timestamp('updated_at').nullable()
|
|
25
|
+
|
|
26
|
+
table.index(['notifiable_id'])
|
|
27
|
+
table.index(['tenant_id'])
|
|
28
|
+
table.index(['status'])
|
|
29
|
+
table.index(['notifiable_id', 'tenant_id'])
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async down() {
|
|
34
|
+
this.schema.dropTable(this.tableName)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({
|
|
3
|
+
to: app.makePath(migration.folder, entity.path, migration.fileName)
|
|
4
|
+
})
|
|
5
|
+
}}}
|
|
6
|
+
import { BaseSchema } from '@adonisjs/lucid/schema'
|
|
7
|
+
|
|
8
|
+
export default class extends BaseSchema {
|
|
9
|
+
protected tableName = 'notification_preferences'
|
|
10
|
+
|
|
11
|
+
async up() {
|
|
12
|
+
this.schema.createTable(this.tableName, (table) => {
|
|
13
|
+
table.increments('id').primary()
|
|
14
|
+
|
|
15
|
+
table.text('user_id').notNullable()
|
|
16
|
+
table.text('tenant_id').nullable()
|
|
17
|
+
table.text('notification_name').nullable()
|
|
18
|
+
table.json('channels').notNullable()
|
|
19
|
+
|
|
20
|
+
table.timestamp('created_at').notNullable()
|
|
21
|
+
table.timestamp('updated_at').nullable()
|
|
22
|
+
|
|
23
|
+
table.index(['user_id'])
|
|
24
|
+
table.index(['tenant_id'])
|
|
25
|
+
table.unique(['user_id', 'tenant_id', 'notification_name'])
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async down() {
|
|
30
|
+
this.schema.dropTable(this.tableName)
|
|
31
|
+
}
|
|
32
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineConfig } from "./define_config.js";
|
|
2
2
|
import { channels } from "./channels.js";
|
|
3
3
|
import { NotificationManager } from "./manager.js";
|
|
4
|
+
import { configure } from "./adonisjs/configure.js";
|
|
4
5
|
export * from "@facteurjs/core";
|
|
5
|
-
export { NotificationManager, channels, defineConfig };
|
|
6
|
+
export { NotificationManager, channels, configure, defineConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { defineConfig } from "./define_config.js";
|
|
2
2
|
import { channels } from "./channels.js";
|
|
3
3
|
import { NotificationManager } from "./manager.js";
|
|
4
|
+
import { configure } from "./adonisjs/configure.js";
|
|
4
5
|
|
|
5
6
|
export * from "@facteurjs/core"
|
|
6
7
|
|
|
7
|
-
export { NotificationManager, channels, defineConfig };
|
|
8
|
+
export { NotificationManager, channels, configure, defineConfig };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@facteurjs/adonisjs",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-beta.
|
|
4
|
+
"version": "1.0.0-beta.4",
|
|
5
5
|
"description": "AdonisJS integration for Facteur",
|
|
6
6
|
"author": "Julien Ripouteau <julien@ripouteau.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -23,11 +23,10 @@
|
|
|
23
23
|
"./channels/webhook": "./dist/channels/webhook.js",
|
|
24
24
|
"./channels/webpush": "./dist/channels/webpush.js",
|
|
25
25
|
"./database": "./dist/database/index.js",
|
|
26
|
-
"./providers/facteur_provider": "./dist/providers/facteur_provider.js",
|
|
27
26
|
"./services/main": "./dist/services/main.js",
|
|
28
27
|
"./types": "./dist/types.js",
|
|
29
28
|
"./package.json": "./package.json",
|
|
30
|
-
"./facteur_provider": "./
|
|
29
|
+
"./facteur_provider": "./dist/providers/facteur_provider.js"
|
|
31
30
|
},
|
|
32
31
|
"main": "./dist/index.js",
|
|
33
32
|
"module": "./dist/index.js",
|
|
@@ -54,9 +53,9 @@
|
|
|
54
53
|
}
|
|
55
54
|
},
|
|
56
55
|
"dependencies": {
|
|
57
|
-
"@facteurjs/core": "1.0.0-beta.1",
|
|
58
56
|
"@julr/utils": "1.9.0",
|
|
59
|
-
"@poppinss/exception": "^1.2.2"
|
|
57
|
+
"@poppinss/exception": "^1.2.2",
|
|
58
|
+
"@facteurjs/core": "1.0.0-beta.4"
|
|
60
59
|
},
|
|
61
60
|
"devDependencies": {
|
|
62
61
|
"@adonisjs/core": "^6.19.0",
|