@supacloud/app 0.1.0 → 0.2.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 +6 -0
- package/dist/context.d.ts +5 -0
- package/dist/decorators.d.ts +9 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -67,6 +67,12 @@ export class CaseModule {}
|
|
|
67
67
|
The compiler rejects scope violations (e.g. an `application` provider
|
|
68
68
|
depending on a `request` provider) at build time.
|
|
69
69
|
|
|
70
|
+
## Built-in Tokens
|
|
71
|
+
|
|
72
|
+
- `DB_CLIENT` — Platform database / Drizzle client (`application` scope).
|
|
73
|
+
- `REQUEST_CONTEXT` — HTTP request context (`request` scope).
|
|
74
|
+
- `JOB_CONTEXT` — Background job execution context (`job` scope).
|
|
75
|
+
|
|
70
76
|
## Non-decorator usage
|
|
71
77
|
|
|
72
78
|
`defineModule(options)` produces the same metadata as `@Module(options)` and
|
package/dist/context.d.ts
CHANGED
|
@@ -12,3 +12,8 @@ export declare const REQUEST_CONTEXT: InjectionToken<unknown>;
|
|
|
12
12
|
* cancellation signal, ...).
|
|
13
13
|
*/
|
|
14
14
|
export declare const JOB_CONTEXT: InjectionToken<unknown>;
|
|
15
|
+
/**
|
|
16
|
+
* Built-in token for the platform database client (PostgreSQL/Drizzle client)
|
|
17
|
+
* passed to `createApplication({ deps: { dbClient } })`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const DB_CLIENT: InjectionToken<unknown>;
|
package/dist/decorators.d.ts
CHANGED
|
@@ -36,15 +36,18 @@ export interface ModuleMeta extends Required<Omit<ModuleOptions, "exports">> {
|
|
|
36
36
|
export interface CommandOptions {
|
|
37
37
|
name: string;
|
|
38
38
|
/** Permission identifier required to execute (e.g. "case.create"). */
|
|
39
|
-
permission
|
|
39
|
+
permission: string;
|
|
40
40
|
/** Transaction requirement for the underlying write, e.g. "required". */
|
|
41
|
-
transaction?:
|
|
41
|
+
transaction?: "required" | "none";
|
|
42
42
|
/** Audit event name recorded on success, e.g. "case.created". */
|
|
43
43
|
audit?: string;
|
|
44
44
|
/** Idempotency strategy, e.g. "required". */
|
|
45
|
-
idempotency?:
|
|
45
|
+
idempotency?: "required" | "none";
|
|
46
46
|
}
|
|
47
|
-
export type CommandMeta = CommandOptions
|
|
47
|
+
export type CommandMeta = Omit<CommandOptions, "transaction" | "idempotency"> & {
|
|
48
|
+
transaction: "required" | "none";
|
|
49
|
+
idempotency: "required" | "none";
|
|
50
|
+
};
|
|
48
51
|
export interface QueryOptions {
|
|
49
52
|
name: string;
|
|
50
53
|
}
|
|
@@ -62,6 +65,8 @@ export interface RouteOptions {
|
|
|
62
65
|
query?: unknown;
|
|
63
66
|
/** TypeBox schema for the response. */
|
|
64
67
|
response?: unknown;
|
|
68
|
+
/** Command class whose governance metadata must be enforced for this route. */
|
|
69
|
+
command?: Type<unknown>;
|
|
65
70
|
}
|
|
66
71
|
export interface RouteDefinition extends RouteOptions {
|
|
67
72
|
method: HttpMethod;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ export type { ClassProvider, ExistingProvider, FactoryProvider, Provider, Token,
|
|
|
7
7
|
export { Command, Controller, Delete, Get, Inject, Injectable, Module, Patch, Post, Put, Query, getCommandMeta, getControllerMeta, getInjectParams, getInjectableMeta, getModuleMeta, getQueryMeta, getRoutes, COMMAND_METADATA, CONTROLLER_METADATA, INJECTABLE_METADATA, INJECT_PARAMS_METADATA, MODULE_METADATA, QUERY_METADATA, ROUTES_METADATA, } from "./decorators";
|
|
8
8
|
export type { CommandMeta, CommandOptions, ControllerMeta, HttpMethod, InjectableMeta, InjectableOptions, ModuleMeta, ModuleOptions, QueryMeta, QueryOptions, RouteDefinition, RouteOptions, } from "./decorators";
|
|
9
9
|
export { defineModule } from "./module";
|
|
10
|
-
export { JOB_CONTEXT, REQUEST_CONTEXT } from "./context";
|
|
10
|
+
export { DB_CLIENT, JOB_CONTEXT, REQUEST_CONTEXT } from "./context";
|
package/dist/index.js
CHANGED
|
@@ -101,7 +101,11 @@ function getModuleMeta(target) {
|
|
|
101
101
|
}
|
|
102
102
|
function Command(options) {
|
|
103
103
|
return (target) => {
|
|
104
|
-
defineMetadata(target, COMMAND_METADATA, {
|
|
104
|
+
defineMetadata(target, COMMAND_METADATA, {
|
|
105
|
+
...options,
|
|
106
|
+
transaction: options.transaction ?? "none",
|
|
107
|
+
idempotency: options.idempotency ?? "none"
|
|
108
|
+
});
|
|
105
109
|
};
|
|
106
110
|
}
|
|
107
111
|
function getCommandMeta(target) {
|
|
@@ -164,11 +168,15 @@ var REQUEST_CONTEXT = new InjectionToken("supacloud.request-context", {
|
|
|
164
168
|
var JOB_CONTEXT = new InjectionToken("supacloud.job-context", {
|
|
165
169
|
scope: "job"
|
|
166
170
|
});
|
|
171
|
+
var DB_CLIENT = new InjectionToken("supacloud.db-client", {
|
|
172
|
+
scope: "application"
|
|
173
|
+
});
|
|
167
174
|
export {
|
|
168
175
|
COMMAND_METADATA,
|
|
169
176
|
CONTROLLER_METADATA,
|
|
170
177
|
Command,
|
|
171
178
|
Controller,
|
|
179
|
+
DB_CLIENT,
|
|
172
180
|
DEFAULT_SCOPE,
|
|
173
181
|
Delete,
|
|
174
182
|
Get,
|
package/package.json
CHANGED