@decaf-ts/for-nest 0.10.1 → 0.11.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 +1 -1
- package/dist/for-nest.cjs +1 -1
- package/dist/for-nest.cjs.map +1 -1
- package/dist/for-nest.js +1 -1
- package/dist/for-nest.js.map +1 -1
- package/lib/cjs/cli-module.cjs +53 -0
- package/lib/cjs/cli-module.cjs.map +1 -1
- package/lib/cjs/index.cjs +4 -3
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/webhooks/DecafWebhookModule.cjs +141 -0
- package/lib/cjs/webhooks/DecafWebhookModule.cjs.map +1 -0
- package/lib/cjs/webhooks/controllers.cjs +151 -0
- package/lib/cjs/webhooks/controllers.cjs.map +1 -0
- package/lib/cjs/webhooks/index.cjs +34 -0
- package/lib/cjs/webhooks/index.cjs.map +1 -0
- package/lib/cjs/webhooks/types.cjs +4 -0
- package/lib/cjs/webhooks/types.cjs.map +1 -0
- package/lib/esm/cli-module.js +51 -0
- package/lib/esm/cli-module.js.map +1 -1
- package/lib/esm/index.js +4 -3
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/webhooks/DecafWebhookModule.js +132 -0
- package/lib/esm/webhooks/DecafWebhookModule.js.map +1 -0
- package/lib/esm/webhooks/controllers.js +142 -0
- package/lib/esm/webhooks/controllers.js.map +1 -0
- package/lib/esm/webhooks/index.js +5 -0
- package/lib/esm/webhooks/index.js.map +1 -0
- package/lib/esm/webhooks/types.js +2 -0
- package/lib/esm/webhooks/types.js.map +1 -0
- package/lib/types/cli-module.d.cts +9 -0
- package/lib/types/cli-module.d.mts +9 -0
- package/lib/types/index.d.cts +4 -3
- package/lib/types/index.d.mts +4 -3
- package/lib/types/webhooks/DecafWebhookModule.d.cts +13 -0
- package/lib/types/webhooks/DecafWebhookModule.d.mts +13 -0
- package/lib/types/webhooks/controllers.d.cts +13 -0
- package/lib/types/webhooks/controllers.d.mts +13 -0
- package/lib/types/webhooks/index.d.cts +4 -0
- package/lib/types/webhooks/index.d.mts +4 -0
- package/lib/types/webhooks/types.d.cts +21 -0
- package/lib/types/webhooks/types.d.mts +21 -0
- package/package.json +13 -1
package/lib/esm/cli-module.js
CHANGED
|
@@ -4,6 +4,7 @@ import { Command } from "commander";
|
|
|
4
4
|
import fs from "fs";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import { Adapter, normalizeImport, Service, TaskModel } from "@decaf-ts/core";
|
|
7
|
+
import { SemverMigrationVersioning } from "@decaf-ts/core/migrations/SemverMigrationVersioning";
|
|
7
8
|
import { InternalError } from "@decaf-ts/db-decorators";
|
|
8
9
|
import { NestFactory } from "@nestjs/core";
|
|
9
10
|
import { DecafMigrationModule } from "./migrations/index.js";
|
|
@@ -70,6 +71,8 @@ export function resolveMigrateCommandConfig(options = {}, pkg = {}) {
|
|
|
70
71
|
const cliFlavours = parseList(options.flavour ?? options.adapter);
|
|
71
72
|
const packageFlavours = parseList(packageMigration.flavour ?? packageMigration.flavours);
|
|
72
73
|
const flavours = cliFlavours.length > 0 ? unique(cliFlavours) : unique(packageFlavours);
|
|
74
|
+
const versionDir = options.versionDir || packageMigration.versionDir;
|
|
75
|
+
const references = parseList(options.reference ?? packageMigration.references);
|
|
73
76
|
return {
|
|
74
77
|
input,
|
|
75
78
|
config: {
|
|
@@ -77,9 +80,38 @@ export function resolveMigrateCommandConfig(options = {}, pkg = {}) {
|
|
|
77
80
|
taskMode: parseBooleanFlag(options.taskMode ?? packageMigration.taskMode),
|
|
78
81
|
dryRun: parseBooleanFlag(options.dryRun ?? packageMigration.dryRun),
|
|
79
82
|
flavours,
|
|
83
|
+
versionDir,
|
|
84
|
+
references,
|
|
80
85
|
},
|
|
81
86
|
};
|
|
82
87
|
}
|
|
88
|
+
export function buildFileVersionHandlers(versionDir, adapters) {
|
|
89
|
+
const handlers = {};
|
|
90
|
+
for (const adapter of adapters) {
|
|
91
|
+
const alias = adapter.alias;
|
|
92
|
+
const file = path.join(versionDir, `${alias}.migration.version`);
|
|
93
|
+
handlers[alias] = {
|
|
94
|
+
// adapter and ctxArgs are available but not needed — version lives in the file
|
|
95
|
+
retrieveLastVersion: async (_adapter, ..._args) => {
|
|
96
|
+
try {
|
|
97
|
+
if (fs.existsSync(file)) {
|
|
98
|
+
const v = fs.readFileSync(file, "utf-8").trim();
|
|
99
|
+
return v || undefined;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
// no file yet → first run
|
|
104
|
+
}
|
|
105
|
+
return undefined;
|
|
106
|
+
},
|
|
107
|
+
setCurrentVersion: async (version, _adapter, ..._args) => {
|
|
108
|
+
fs.mkdirSync(versionDir, { recursive: true });
|
|
109
|
+
fs.writeFileSync(file, version, "utf-8");
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
return handlers;
|
|
114
|
+
}
|
|
83
115
|
const migrateCommand = new Command()
|
|
84
116
|
.name("migrate")
|
|
85
117
|
.description("boots the app context headlessly, executes decaf migrations, and exits")
|
|
@@ -89,6 +121,12 @@ const migrateCommand = new Command()
|
|
|
89
121
|
.option("--adapter <String>", "adapter flavour alias(es), comma-separated (same behavior as --flavour)")
|
|
90
122
|
.option("--task-mode [Boolean]", "runs migration via task mode (true/false). accepts bare flag as true")
|
|
91
123
|
.option("--dry-run [Boolean]", "runs migrations with dry-run context (true/false). accepts bare flag as true")
|
|
124
|
+
.option("--version-dir <String>", "directory where per-adapter version files are persisted (e.g. a Docker volume path). " +
|
|
125
|
+
"Each adapter writes its last-migrated version to <versionDir>/<alias>.migration.version. " +
|
|
126
|
+
"Can also be set via package.json decaf.migration.versionDir.")
|
|
127
|
+
.option("--reference <String>", "run only the named migration reference(s), comma-separated (e.g. 'product-migration'). " +
|
|
128
|
+
"Bypasses version range filtering — use for zero-day or one-off migrations. " +
|
|
129
|
+
"Can also be set via package.json decaf.migration.references.")
|
|
92
130
|
.action(async (options) => {
|
|
93
131
|
const pkg = JSON.parse(fs.readFileSync(path.join(process.cwd(), "package.json"), "utf-8"));
|
|
94
132
|
const log = logger.for("migrate");
|
|
@@ -124,12 +162,24 @@ const migrateCommand = new Command()
|
|
|
124
162
|
const migrateAdapters = taskAdapterAlias
|
|
125
163
|
? adapters.filter((a) => a.alias !== taskAdapterAlias && a.flavour !== taskAdapterAlias)
|
|
126
164
|
: adapters;
|
|
165
|
+
const handlers = config.versionDir
|
|
166
|
+
? buildFileVersionHandlers(config.versionDir, migrateAdapters)
|
|
167
|
+
: undefined;
|
|
168
|
+
if (config.versionDir)
|
|
169
|
+
log.info(`Version tracking: ${path.resolve(config.versionDir)}`);
|
|
170
|
+
else
|
|
171
|
+
log.warn(`No --version-dir set — every run will re-apply all migrations up to ${config.toVersion}`);
|
|
172
|
+
if (config.references.length)
|
|
173
|
+
log.info(`Running only references: ${config.references.join(", ")}`);
|
|
127
174
|
const migrations = await DecafMigrationModule.migrate({
|
|
128
175
|
toVersion: config.toVersion,
|
|
129
176
|
taskMode: config.taskMode,
|
|
130
177
|
dryRun: config.dryRun,
|
|
131
178
|
flavours: config.flavours.length > 0 ? config.flavours : undefined,
|
|
132
179
|
taskService,
|
|
180
|
+
handlers,
|
|
181
|
+
versioning: new SemverMigrationVersioning(),
|
|
182
|
+
references: config.references.length > 0 ? config.references : undefined,
|
|
133
183
|
}, migrateAdapters);
|
|
134
184
|
for (const migrationService of migrations || []) {
|
|
135
185
|
await migrationService.track();
|
|
@@ -144,6 +194,7 @@ const migrateCommand = new Command()
|
|
|
144
194
|
await app.close();
|
|
145
195
|
}
|
|
146
196
|
});
|
|
197
|
+
export { migrateCommand };
|
|
147
198
|
const nestCmd = new Command()
|
|
148
199
|
.name("nest")
|
|
149
200
|
.description("exposes several commands to help manage the nest integration");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-module.js","sourceRoot":"","sources":["../../src/cli-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC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CHANGED
|
@@ -35,27 +35,28 @@ export * from "./migrations/index.js";
|
|
|
35
35
|
export * from "./types.js";
|
|
36
36
|
export * from "./utils.js";
|
|
37
37
|
export * from "./events-module/index.js";
|
|
38
|
+
export * from "./webhooks/index.js";
|
|
38
39
|
/**
|
|
39
40
|
* Represents the current version of the ts-workspace module.
|
|
40
41
|
* The actual version number is replaced during the build process.
|
|
41
42
|
* @constant
|
|
42
43
|
* @type {string}
|
|
43
44
|
*/
|
|
44
|
-
export const VERSION = "0.10.
|
|
45
|
+
export const VERSION = "0.10.2";
|
|
45
46
|
/**
|
|
46
47
|
* @description Represents the current commit hash of the module build.
|
|
47
48
|
* @summary Stores the current git commit hash for the package. The build replaces
|
|
48
49
|
* the placeholder with the actual commit hash at publish time.
|
|
49
50
|
* @const COMMIT
|
|
50
51
|
*/
|
|
51
|
-
export const COMMIT = "
|
|
52
|
+
export const COMMIT = "cee7a8b";
|
|
52
53
|
/**
|
|
53
54
|
* @description Represents the full version string of the module.
|
|
54
55
|
* @summary Stores the semver version and commit hash for the package.
|
|
55
56
|
* The build replaces the placeholder with the actual `<version>-<commit>` value at publish time.
|
|
56
57
|
* @const FULL_VERSION
|
|
57
58
|
*/
|
|
58
|
-
export const FULL_VERSION = "0.10.
|
|
59
|
+
export const FULL_VERSION = "0.10.2-cee7a8b";
|
|
59
60
|
export const PACKAGE_NAME = "@decaf-ts/for-nest";
|
|
60
61
|
Metadata.allowReregistration(true);
|
|
61
62
|
Metadata.registerLibrary(PACKAGE_NAME, VERSION);
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,yBAAsB;AAEtB,gCAA6B,CAAC,oBAAoB;AAClD,uCAA8B;AAC9B,mCAA0B;AAC1B,wCAA+B;AAC/B,qCAA4B;AAC5B,mCAA0B;AAC1B,+BAA4B;AAC5B,iCAA8B;AAC9B,4BAAyB;AACzB,iCAA8B;AAC9B,sCAA6B;AAC7B,2BAAwB;AACxB,2BAAwB;AACxB,yCAAgC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,yBAAsB;AAEtB,gCAA6B,CAAC,oBAAoB;AAClD,uCAA8B;AAC9B,mCAA0B;AAC1B,wCAA+B;AAC/B,qCAA4B;AAC5B,mCAA0B;AAC1B,+BAA4B;AAC5B,iCAA8B;AAC9B,4BAAyB;AACzB,iCAA8B;AAC9B,sCAA6B;AAC7B,2BAAwB;AACxB,2BAAwB;AACxB,yCAAgC;AAChC,oCAA2B;AAE3B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAC;AAErC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,YAAY,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,kBAAkB,CAAC;AAE/C,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC;AAE1C,QAAQ,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;AACnC,QAAQ,CAAC,eAAe,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;AAChD,QAAQ,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var DecafWebhookModule_1;
|
|
8
|
+
import { Module } from "@nestjs/common";
|
|
9
|
+
import { RouterModule } from "@nestjs/core";
|
|
10
|
+
import { Adapter, PersistenceService, } from "@decaf-ts/core";
|
|
11
|
+
import { InternalError } from "@decaf-ts/db-decorators";
|
|
12
|
+
import { uses } from "@decaf-ts/decoration";
|
|
13
|
+
import { Logging } from "@decaf-ts/logging";
|
|
14
|
+
import { DecafRequestContext } from "./../request/index.js";
|
|
15
|
+
import { DecafHandlerExecutor } from "./../request/DecafHandlerExecutor.js";
|
|
16
|
+
import { DecafRequestHandlerInterceptor } from "./../interceptors/DecafRequestHandlerInterceptor.js";
|
|
17
|
+
import { DECAF_HANDLERS } from "./../constants.js";
|
|
18
|
+
import { APP_INTERCEPTOR } from "@nestjs/core";
|
|
19
|
+
import { FromModelController } from "./../decaf-model/index.js";
|
|
20
|
+
import { requestToContextTransformer } from "./../interceptors/context.js";
|
|
21
|
+
import { WebhookDelivery, WebhookEventRecord, WebhookSubscription, } from "@decaf-ts/for-http/server";
|
|
22
|
+
import { WebhookEventActionsController, WebhookSubscriptionActionsController, } from "./controllers.js";
|
|
23
|
+
let DecafWebhookModule = class DecafWebhookModule {
|
|
24
|
+
static { DecafWebhookModule_1 = this; }
|
|
25
|
+
static { this._logger = Logging.for(DecafWebhookModule_1); }
|
|
26
|
+
static get log() {
|
|
27
|
+
return this._logger;
|
|
28
|
+
}
|
|
29
|
+
static async bootPersistence(options) {
|
|
30
|
+
const log = this.log.for(this.bootPersistence);
|
|
31
|
+
if (!this._persistence) {
|
|
32
|
+
const trimmed = options.conf.map(([contr, cfg, ...args]) => {
|
|
33
|
+
const possible = args.pop();
|
|
34
|
+
if (!possible)
|
|
35
|
+
return [contr, cfg];
|
|
36
|
+
return [contr, cfg, ...args];
|
|
37
|
+
});
|
|
38
|
+
this._persistence = new PersistenceService();
|
|
39
|
+
await this._persistence.boot(trimmed);
|
|
40
|
+
const clients = this._persistence.client;
|
|
41
|
+
for (let i = 0; i < clients.length; i++) {
|
|
42
|
+
const cache = Adapter._cache || (Adapter._cache = {});
|
|
43
|
+
const webhookKeys = [
|
|
44
|
+
clients[i].flavour,
|
|
45
|
+
clients[i].alias,
|
|
46
|
+
"webhook_deliveries",
|
|
47
|
+
"webhook_events",
|
|
48
|
+
"webhook_subscriptions",
|
|
49
|
+
].filter((value) => !!value);
|
|
50
|
+
for (const key of webhookKeys) {
|
|
51
|
+
cache[key] = clients[i];
|
|
52
|
+
}
|
|
53
|
+
const c = options.conf[i];
|
|
54
|
+
const possibleTransf = c.slice(2, c.length);
|
|
55
|
+
let transformer = possibleTransf.pop();
|
|
56
|
+
if (!transformer ||
|
|
57
|
+
!transformer.from) {
|
|
58
|
+
const contr = Adapter.transformerFor(clients[i].flavour);
|
|
59
|
+
if (!contr)
|
|
60
|
+
throw new InternalError(`No transformer found for flavour ${clients[i].flavour}.`);
|
|
61
|
+
try {
|
|
62
|
+
transformer = contr.from
|
|
63
|
+
? contr
|
|
64
|
+
: new contr();
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
throw new InternalError(`Failed to boot transformer for ${clients[i].flavour}: ${e}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
requestToContextTransformer(clients[i].flavour)(transformer);
|
|
71
|
+
uses(clients[i].flavour)(WebhookSubscription);
|
|
72
|
+
uses(clients[i].flavour)(WebhookEventRecord);
|
|
73
|
+
uses(clients[i].flavour)(WebhookDelivery);
|
|
74
|
+
}
|
|
75
|
+
log.info("persistence layer created successfully!");
|
|
76
|
+
if (options.initialization) {
|
|
77
|
+
try {
|
|
78
|
+
await options.initialization();
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
throw new InternalError(`Failed to initialize webhook module: ${e}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return this._persistence.client;
|
|
86
|
+
}
|
|
87
|
+
static async forRoot(options) {
|
|
88
|
+
return this.forRootAsync(options);
|
|
89
|
+
}
|
|
90
|
+
static async forRootAsync(options) {
|
|
91
|
+
const adapters = await this.bootPersistence(options);
|
|
92
|
+
const controllers = [
|
|
93
|
+
FromModelController.create(WebhookSubscription),
|
|
94
|
+
FromModelController.create(WebhookEventRecord),
|
|
95
|
+
FromModelController.create(WebhookDelivery),
|
|
96
|
+
WebhookSubscriptionActionsController,
|
|
97
|
+
WebhookEventActionsController,
|
|
98
|
+
];
|
|
99
|
+
return {
|
|
100
|
+
module: DecafWebhookModule_1,
|
|
101
|
+
controllers,
|
|
102
|
+
imports: [
|
|
103
|
+
RouterModule.register([
|
|
104
|
+
{
|
|
105
|
+
path: (options.webhookApiPath || "webhooks").replace(/^\//, ""),
|
|
106
|
+
module: DecafWebhookModule_1,
|
|
107
|
+
},
|
|
108
|
+
]),
|
|
109
|
+
],
|
|
110
|
+
providers: [
|
|
111
|
+
DecafRequestContext,
|
|
112
|
+
DecafHandlerExecutor,
|
|
113
|
+
{
|
|
114
|
+
provide: DECAF_HANDLERS,
|
|
115
|
+
useFactory: () => options.handlers?.map((H) => new H()) ?? [],
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
provide: APP_INTERCEPTOR,
|
|
119
|
+
useClass: DecafRequestHandlerInterceptor,
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
exports: [DecafRequestContext, DecafHandlerExecutor],
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
DecafWebhookModule = DecafWebhookModule_1 = __decorate([
|
|
127
|
+
Module({})
|
|
128
|
+
], DecafWebhookModule);
|
|
129
|
+
export { DecafWebhookModule };
|
|
130
|
+
export const DecafWebhooksModule = DecafWebhookModule;
|
|
131
|
+
export async function runWebhooksMigrations() { }
|
|
132
|
+
//# sourceMappingURL=DecafWebhookModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DecafWebhookModule.js","sourceRoot":"","sources":["../../../src/webhooks/DecafWebhookModule.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAiB,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACL,OAAO,EACP,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAe,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,8BAAmB;AACjD,OAAO,EAAE,oBAAoB,EAAE,6CAAwC;AACvE,OAAO,EAAE,8BAA8B,EAAE,4DAAuD;AAChG,OAAO,EAAE,cAAc,EAAE,0BAAqB;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,mBAAmB,EAAE,kCAAuB;AACrD,OAAO,EAAE,2BAA2B,EAAE,qCAAgC;AACtE,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,6BAA6B,EAC7B,oCAAoC,GACrC,yBAAsB;AAGhB,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;;aACd,YAAO,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAkB,CAAC,AAAlC,CAAmC;IAKjD,MAAM,KAAK,GAAG;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,eAAe,CAC1B,OAAkC;QAElC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,e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;iBACzC;aACF;YACD,OAAO,EAAE,CAAC,mBAAmB,EAAE,oBAAoB,CAAC;SACrD,CAAC;IACJ,CAAC;;AA1HU,kBAAkB;IAD9B,MAAM,CAAC,EAAE,CAAC;GACE,kBAAkB,CA2H9B;;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AAEtD,MAAM,CAAC,KAAK,UAAU,qBAAqB,KAAmB,CAAC"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
var WebhookSubscriptionActionsController_1, WebhookEventActionsController_1;
|
|
14
|
+
import { Controller, Param, Post } from "@nestjs/common";
|
|
15
|
+
import { Repository, OrderDirection } from "@decaf-ts/core";
|
|
16
|
+
import { DecafController } from "./../controllers.js";
|
|
17
|
+
import { DecafRequestContext } from "./../request/index.js";
|
|
18
|
+
import { WebhookDelivery, WebhookEventRecord, WebhookStatus, WebhookSubscription, collectPagedResults, } from "@decaf-ts/for-http/server";
|
|
19
|
+
let WebhookSubscriptionActionsController = WebhookSubscriptionActionsController_1 = class WebhookSubscriptionActionsController extends DecafController {
|
|
20
|
+
constructor(clientContext) {
|
|
21
|
+
super(clientContext, WebhookSubscriptionActionsController_1.name);
|
|
22
|
+
}
|
|
23
|
+
async deactivate(id) {
|
|
24
|
+
const { ctx } = (await this.logCtx([], "deactivate", true)).for(this.deactivate);
|
|
25
|
+
const repo = Repository.forModel(WebhookSubscription);
|
|
26
|
+
const current = await repo.read(id, ctx);
|
|
27
|
+
current.active = false;
|
|
28
|
+
return repo.update(current, ctx);
|
|
29
|
+
}
|
|
30
|
+
async reactivate(id) {
|
|
31
|
+
const { ctx } = (await this.logCtx([], "reactivate", true)).for(this.reactivate);
|
|
32
|
+
const repo = Repository.forModel(WebhookSubscription);
|
|
33
|
+
const current = await repo.read(id, ctx);
|
|
34
|
+
current.active = true;
|
|
35
|
+
return repo.update(current, ctx);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
__decorate([
|
|
39
|
+
Post(":id/deactivate"),
|
|
40
|
+
__param(0, Param("id")),
|
|
41
|
+
__metadata("design:type", Function),
|
|
42
|
+
__metadata("design:paramtypes", [String]),
|
|
43
|
+
__metadata("design:returntype", Promise)
|
|
44
|
+
], WebhookSubscriptionActionsController.prototype, "deactivate", null);
|
|
45
|
+
__decorate([
|
|
46
|
+
Post(":id/reactivate"),
|
|
47
|
+
__param(0, Param("id")),
|
|
48
|
+
__metadata("design:type", Function),
|
|
49
|
+
__metadata("design:paramtypes", [String]),
|
|
50
|
+
__metadata("design:returntype", Promise)
|
|
51
|
+
], WebhookSubscriptionActionsController.prototype, "reactivate", null);
|
|
52
|
+
WebhookSubscriptionActionsController = WebhookSubscriptionActionsController_1 = __decorate([
|
|
53
|
+
Controller("webhook-subscriptions"),
|
|
54
|
+
__metadata("design:paramtypes", [DecafRequestContext])
|
|
55
|
+
], WebhookSubscriptionActionsController);
|
|
56
|
+
export { WebhookSubscriptionActionsController };
|
|
57
|
+
let WebhookEventActionsController = WebhookEventActionsController_1 = class WebhookEventActionsController extends DecafController {
|
|
58
|
+
constructor(clientContext) {
|
|
59
|
+
super(clientContext, WebhookEventActionsController_1.name);
|
|
60
|
+
}
|
|
61
|
+
async replay(id) {
|
|
62
|
+
const { ctx } = (await this.logCtx([], "replay", true)).for(this.replay);
|
|
63
|
+
const eventRepo = Repository.forModel(WebhookEventRecord);
|
|
64
|
+
const deliveryRepo = Repository.forModel(WebhookDelivery);
|
|
65
|
+
try {
|
|
66
|
+
let event;
|
|
67
|
+
try {
|
|
68
|
+
event = await eventRepo.read(id, ctx);
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
const events = await eventRepo
|
|
72
|
+
.select()
|
|
73
|
+
.where(eventRepo.attr("id").eq(id))
|
|
74
|
+
.limit(1)
|
|
75
|
+
.execute(ctx);
|
|
76
|
+
if (!events.length)
|
|
77
|
+
throw error;
|
|
78
|
+
event = events[0];
|
|
79
|
+
}
|
|
80
|
+
let deliveries = [];
|
|
81
|
+
try {
|
|
82
|
+
deliveries = await collectPagedResults(() => deliveryRepo
|
|
83
|
+
.select()
|
|
84
|
+
.where(deliveryRepo.attr("eventId").eq(event.id))
|
|
85
|
+
.orderBy("createdAt", OrderDirection.ASC)
|
|
86
|
+
.thenBy("id", OrderDirection.ASC)
|
|
87
|
+
.paginate(250, ctx), 250, ctx);
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
try {
|
|
91
|
+
deliveries = await deliveryRepo
|
|
92
|
+
.select()
|
|
93
|
+
.where(deliveryRepo.attr("eventId").eq(event.id))
|
|
94
|
+
.execute(ctx);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
deliveries = [];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const now = new Date();
|
|
101
|
+
for (const delivery of deliveries) {
|
|
102
|
+
delivery.status = WebhookStatus.PENDING;
|
|
103
|
+
delivery.attempts = 0;
|
|
104
|
+
delivery.nextAttemptAt = now;
|
|
105
|
+
delivery.lastAttemptAt = null;
|
|
106
|
+
delivery.errorMessage = undefined;
|
|
107
|
+
delivery.responseStatus = undefined;
|
|
108
|
+
delivery.responseBody = undefined;
|
|
109
|
+
}
|
|
110
|
+
event.status = WebhookStatus.PENDING;
|
|
111
|
+
event.deliveriesSucceeded = 0;
|
|
112
|
+
event.deliveriesFailed = 0;
|
|
113
|
+
event.nextAttemptAt = now;
|
|
114
|
+
event.updatedAt = now;
|
|
115
|
+
if (deliveries.length) {
|
|
116
|
+
try {
|
|
117
|
+
await deliveryRepo.updateAll(deliveries, ctx.override({ applyUpdateValidation: false }));
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
// Replay still resets the event state even if bulk delivery updates are not queryable here.
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return eventRepo.update(event, ctx);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
__decorate([
|
|
131
|
+
Post(":id/replay"),
|
|
132
|
+
__param(0, Param("id")),
|
|
133
|
+
__metadata("design:type", Function),
|
|
134
|
+
__metadata("design:paramtypes", [String]),
|
|
135
|
+
__metadata("design:returntype", Promise)
|
|
136
|
+
], WebhookEventActionsController.prototype, "replay", null);
|
|
137
|
+
WebhookEventActionsController = WebhookEventActionsController_1 = __decorate([
|
|
138
|
+
Controller("webhook-events"),
|
|
139
|
+
__metadata("design:paramtypes", [DecafRequestContext])
|
|
140
|
+
], WebhookEventActionsController);
|
|
141
|
+
export { WebhookEventActionsController };
|
|
142
|
+
//# sourceMappingURL=controllers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controllers.js","sourceRoot":"","sources":["../../../src/webhooks/controllers.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAa,cAAc,EAAE,MA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AClC,QAAQ,CAAC,cAAc,GAAG,SAAS,CAAC;gBACpC,QAAQ,CAAC,YAAY,GAAG,SAAS,CAAC;YACpC,CAAC;YAED,KAAK,CAAC,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC;YACrC,KAAK,CAAC,mBAAmB,GAAG,CAAC,CAAC;YAC9B,KAAK,CAAC,gBAAgB,GAAG,CAAC,CAAC;YAC3B,KAAK,CAAC,aAAa,GAAG,GAAG,CAAC;YAC1B,KAAK,CAAC,SAAS,GAAG,GAAG,CAAC;YAEtB,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;gBACtB,IAAI,CAAC;oBACH,MAAM,YAAY,CAAC,SAAS,CAC1B,UAAU,EACV,GAAG,CAAC,QAAQ,CAAC,EAAE,qBAAqB,EAAE,KAAK,EAAE,CAAC,CAC/C,CAAC;gBACJ,CAAC;gBAAC,MAAM,CAAC;oBACP,4FAA4F;gBAC9F,CAAC;YACH,CAAC;YACD,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACtC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF,CAAA;AA/EO;IADL,IAAI,CAAC,YAAY,CAAC;IACL,WAAA,KAAK,CAAC,IAAI,CAAC,CAAA;;;;2DA8ExB;AApFU,6BAA6B;IADzC,UAAU,CAAC,gBAAgB,CAAC;qCAEA,mBAAmB;GADnC,6BAA6B,CAqFzC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from "./DecafWebhookModule.js";
|
|
2
|
+
export * from "./controllers.js";
|
|
3
|
+
export * from "./types.js";
|
|
4
|
+
export { WebhookDelivery, WebhookDeliveryService, WebhookEventRecord, WebhookPublisherService, WebhookSignatureMiddleware, WebhookStatus, WebhookSubscription, WebhookSubscriptionService, computeNextAttempt, signWebhookPayload, verifyWebhookSignature, } from "@decaf-ts/for-http/server";
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/webhooks/index.ts"],"names":[],"mappings":"AAAA,wCAAqC;AACrC,iCAA8B;AAC9B,2BAAwB;AAExB,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAClB,uBAAuB,EACvB,0BAA0B,EAC1B,aAAa,EACb,mBAAmB,EACnB,0BAA0B,EAC1B,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/webhooks/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
+
import { Adapter } from "@decaf-ts/core";
|
|
2
3
|
export declare function resolveInputPath(input?: string, exists?: (candidate: string) => boolean, candidates?: string[]): string;
|
|
3
4
|
export declare function buildOutputFilePath(params: {
|
|
4
5
|
outputDir: string;
|
|
@@ -15,6 +16,14 @@ export declare function resolveMigrateCommandConfig(options?: Record<string, unk
|
|
|
15
16
|
taskMode: boolean | undefined;
|
|
16
17
|
dryRun: boolean | undefined;
|
|
17
18
|
flavours: string[];
|
|
19
|
+
versionDir: string | undefined;
|
|
20
|
+
references: string[];
|
|
18
21
|
};
|
|
19
22
|
};
|
|
23
|
+
export declare function buildFileVersionHandlers(versionDir: string, adapters: Adapter<any, any, any, any>[]): Record<string, {
|
|
24
|
+
retrieveLastVersion: () => Promise<string | undefined>;
|
|
25
|
+
setCurrentVersion: (v: string) => Promise<void>;
|
|
26
|
+
}>;
|
|
27
|
+
declare const migrateCommand: Command;
|
|
28
|
+
export { migrateCommand };
|
|
20
29
|
export default function nest(): Command;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
+
import { Adapter } from "@decaf-ts/core";
|
|
2
3
|
export declare function resolveInputPath(input?: string, exists?: (candidate: string) => boolean, candidates?: string[]): string;
|
|
3
4
|
export declare function buildOutputFilePath(params: {
|
|
4
5
|
outputDir: string;
|
|
@@ -15,6 +16,14 @@ export declare function resolveMigrateCommandConfig(options?: Record<string, unk
|
|
|
15
16
|
taskMode: boolean | undefined;
|
|
16
17
|
dryRun: boolean | undefined;
|
|
17
18
|
flavours: string[];
|
|
19
|
+
versionDir: string | undefined;
|
|
20
|
+
references: string[];
|
|
18
21
|
};
|
|
19
22
|
};
|
|
23
|
+
export declare function buildFileVersionHandlers(versionDir: string, adapters: Adapter<any, any, any, any>[]): Record<string, {
|
|
24
|
+
retrieveLastVersion: () => Promise<string | undefined>;
|
|
25
|
+
setCurrentVersion: (v: string) => Promise<void>;
|
|
26
|
+
}>;
|
|
27
|
+
declare const migrateCommand: Command;
|
|
28
|
+
export { migrateCommand };
|
|
20
29
|
export default function nest(): Command;
|
package/lib/types/index.d.cts
CHANGED
|
@@ -34,25 +34,26 @@ export * from "./migrations/index.d.cts";
|
|
|
34
34
|
export * from "./types.d.cts";
|
|
35
35
|
export * from "./utils.d.cts";
|
|
36
36
|
export * from "./events-module/index.d.cts";
|
|
37
|
+
export * from "./webhooks/index.d.cts";
|
|
37
38
|
/**
|
|
38
39
|
* Represents the current version of the ts-workspace module.
|
|
39
40
|
* The actual version number is replaced during the build process.
|
|
40
41
|
* @constant
|
|
41
42
|
* @type {string}
|
|
42
43
|
*/
|
|
43
|
-
export declare const VERSION = "0.10.
|
|
44
|
+
export declare const VERSION = "0.10.2";
|
|
44
45
|
/**
|
|
45
46
|
* @description Represents the current commit hash of the module build.
|
|
46
47
|
* @summary Stores the current git commit hash for the package. The build replaces
|
|
47
48
|
* the placeholder with the actual commit hash at publish time.
|
|
48
49
|
* @const COMMIT
|
|
49
50
|
*/
|
|
50
|
-
export declare const COMMIT = "
|
|
51
|
+
export declare const COMMIT = "cee7a8b";
|
|
51
52
|
/**
|
|
52
53
|
* @description Represents the full version string of the module.
|
|
53
54
|
* @summary Stores the semver version and commit hash for the package.
|
|
54
55
|
* The build replaces the placeholder with the actual `<version>-<commit>` value at publish time.
|
|
55
56
|
* @const FULL_VERSION
|
|
56
57
|
*/
|
|
57
|
-
export declare const FULL_VERSION = "0.10.
|
|
58
|
+
export declare const FULL_VERSION = "0.10.2-cee7a8b";
|
|
58
59
|
export declare const PACKAGE_NAME = "@decaf-ts/for-nest";
|
package/lib/types/index.d.mts
CHANGED
|
@@ -34,25 +34,26 @@ export * from "./migrations/index.d.mts";
|
|
|
34
34
|
export * from "./types.d.mts";
|
|
35
35
|
export * from "./utils.d.mts";
|
|
36
36
|
export * from "./events-module/index.d.mts";
|
|
37
|
+
export * from "./webhooks/index.d.mts";
|
|
37
38
|
/**
|
|
38
39
|
* Represents the current version of the ts-workspace module.
|
|
39
40
|
* The actual version number is replaced during the build process.
|
|
40
41
|
* @constant
|
|
41
42
|
* @type {string}
|
|
42
43
|
*/
|
|
43
|
-
export declare const VERSION = "0.10.
|
|
44
|
+
export declare const VERSION = "0.10.2";
|
|
44
45
|
/**
|
|
45
46
|
* @description Represents the current commit hash of the module build.
|
|
46
47
|
* @summary Stores the current git commit hash for the package. The build replaces
|
|
47
48
|
* the placeholder with the actual commit hash at publish time.
|
|
48
49
|
* @const COMMIT
|
|
49
50
|
*/
|
|
50
|
-
export declare const COMMIT = "
|
|
51
|
+
export declare const COMMIT = "cee7a8b";
|
|
51
52
|
/**
|
|
52
53
|
* @description Represents the full version string of the module.
|
|
53
54
|
* @summary Stores the semver version and commit hash for the package.
|
|
54
55
|
* The build replaces the placeholder with the actual `<version>-<commit>` value at publish time.
|
|
55
56
|
* @const FULL_VERSION
|
|
56
57
|
*/
|
|
57
|
-
export declare const FULL_VERSION = "0.10.
|
|
58
|
+
export declare const FULL_VERSION = "0.10.2-cee7a8b";
|
|
58
59
|
export declare const PACKAGE_NAME = "@decaf-ts/for-nest";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DynamicModule } from "@nestjs/common";
|
|
2
|
+
import { Adapter } from "@decaf-ts/core";
|
|
3
|
+
import { DecafWebhookModuleOptions } from "./types.d.cts";
|
|
4
|
+
export declare class DecafWebhookModule {
|
|
5
|
+
private static _logger;
|
|
6
|
+
private static _persistence?;
|
|
7
|
+
private static get log();
|
|
8
|
+
static bootPersistence(options: DecafWebhookModuleOptions): Promise<Adapter<any, any, any, any>[]>;
|
|
9
|
+
static forRoot(options: DecafWebhookModuleOptions): Promise<DynamicModule>;
|
|
10
|
+
static forRootAsync(options: DecafWebhookModuleOptions): Promise<DynamicModule>;
|
|
11
|
+
}
|
|
12
|
+
export declare const DecafWebhooksModule: typeof DecafWebhookModule;
|
|
13
|
+
export declare function runWebhooksMigrations(): Promise<void>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DynamicModule } from "@nestjs/common";
|
|
2
|
+
import { Adapter } from "@decaf-ts/core";
|
|
3
|
+
import { DecafWebhookModuleOptions } from "./types.d.mts";
|
|
4
|
+
export declare class DecafWebhookModule {
|
|
5
|
+
private static _logger;
|
|
6
|
+
private static _persistence?;
|
|
7
|
+
private static get log();
|
|
8
|
+
static bootPersistence(options: DecafWebhookModuleOptions): Promise<Adapter<any, any, any, any>[]>;
|
|
9
|
+
static forRoot(options: DecafWebhookModuleOptions): Promise<DynamicModule>;
|
|
10
|
+
static forRootAsync(options: DecafWebhookModuleOptions): Promise<DynamicModule>;
|
|
11
|
+
}
|
|
12
|
+
export declare const DecafWebhooksModule: typeof DecafWebhookModule;
|
|
13
|
+
export declare function runWebhooksMigrations(): Promise<void>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DecafController } from "../controllers.d.cts";
|
|
2
|
+
import { DecafRequestContext } from "../request/index.d.cts";
|
|
3
|
+
import { DecafServerCtx } from "../constants.d.cts";
|
|
4
|
+
import { WebhookEventRecord, WebhookSubscription } from "@decaf-ts/for-http/server";
|
|
5
|
+
export declare class WebhookSubscriptionActionsController extends DecafController<DecafServerCtx> {
|
|
6
|
+
constructor(clientContext: DecafRequestContext);
|
|
7
|
+
deactivate(id: string): Promise<WebhookSubscription>;
|
|
8
|
+
reactivate(id: string): Promise<WebhookSubscription>;
|
|
9
|
+
}
|
|
10
|
+
export declare class WebhookEventActionsController extends DecafController<DecafServerCtx> {
|
|
11
|
+
constructor(clientContext: DecafRequestContext);
|
|
12
|
+
replay(id: string): Promise<WebhookEventRecord>;
|
|
13
|
+
}
|