@supacloud/app 0.1.0 → 0.4.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
@@ -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>;
@@ -23,6 +23,8 @@ export interface InjectableMeta {
23
23
  }
24
24
  export interface ModuleOptions {
25
25
  name: string;
26
+ /** Tags for architectural boundary governance (e.g. ['scope:case', 'type:feature']). */
27
+ tags?: string[];
26
28
  imports?: Array<Type<unknown>>;
27
29
  providers?: Provider[];
28
30
  controllers?: Array<Type<unknown>>;
@@ -30,21 +32,25 @@ export interface ModuleOptions {
30
32
  queries?: Array<Type<unknown>>;
31
33
  exports?: Token[];
32
34
  }
33
- export interface ModuleMeta extends Required<Omit<ModuleOptions, "exports">> {
35
+ export interface ModuleMeta extends Required<Omit<ModuleOptions, "exports" | "tags">> {
36
+ tags?: string[];
34
37
  exports: Token[];
35
38
  }
36
39
  export interface CommandOptions {
37
40
  name: string;
38
41
  /** Permission identifier required to execute (e.g. "case.create"). */
39
- permission?: string;
42
+ permission: string;
40
43
  /** Transaction requirement for the underlying write, e.g. "required". */
41
- transaction?: string;
44
+ transaction?: "required" | "none";
42
45
  /** Audit event name recorded on success, e.g. "case.created". */
43
46
  audit?: string;
44
47
  /** Idempotency strategy, e.g. "required". */
45
- idempotency?: string;
48
+ idempotency?: "required" | "none";
46
49
  }
47
- export type CommandMeta = CommandOptions;
50
+ export type CommandMeta = Omit<CommandOptions, "transaction" | "idempotency"> & {
51
+ transaction: "required" | "none";
52
+ idempotency: "required" | "none";
53
+ };
48
54
  export interface QueryOptions {
49
55
  name: string;
50
56
  }
@@ -52,7 +58,7 @@ export type QueryMeta = QueryOptions;
52
58
  export interface ControllerMeta {
53
59
  path: string;
54
60
  }
55
- export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
61
+ export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
56
62
  export interface RouteOptions {
57
63
  /** TypeBox schema (or compatible) for the request body. */
58
64
  body?: unknown;
@@ -62,6 +68,8 @@ export interface RouteOptions {
62
68
  query?: unknown;
63
69
  /** TypeBox schema for the response. */
64
70
  response?: unknown;
71
+ /** Command class whose governance metadata must be enforced for this route. */
72
+ command?: Type<unknown>;
65
73
  }
66
74
  export interface RouteDefinition extends RouteOptions {
67
75
  method: HttpMethod;
@@ -91,4 +99,6 @@ export declare const Post: (path: string, options?: RouteOptions) => MethodDecor
91
99
  export declare const Put: (path: string, options?: RouteOptions) => MethodDecorator;
92
100
  export declare const Patch: (path: string, options?: RouteOptions) => MethodDecorator;
93
101
  export declare const Delete: (path: string, options?: RouteOptions) => MethodDecorator;
102
+ export declare const Head: (path: string, options?: RouteOptions) => MethodDecorator;
103
+ export declare const Options: (path: string, options?: RouteOptions) => MethodDecorator;
94
104
  export declare function getRoutes(target: object): RouteDefinition[];
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export { InjectionToken } from "./token";
4
4
  export type { InjectionTokenOptions } from "./token";
5
5
  export { isClassProvider, isExistingProvider, isFactoryProvider, isValueProvider, } from "./provider";
6
6
  export type { ClassProvider, ExistingProvider, FactoryProvider, Provider, Token, Type, ValueProvider, } from "./provider";
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";
7
+ export { Command, Controller, Delete, Get, Head, Inject, Injectable, Module, Options, 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
@@ -86,6 +86,7 @@ function Module(options) {
86
86
  return (target) => {
87
87
  const meta = {
88
88
  name: options.name,
89
+ tags: options.tags ?? [],
89
90
  imports: options.imports ?? [],
90
91
  providers: options.providers ?? [],
91
92
  controllers: options.controllers ?? [],
@@ -101,7 +102,11 @@ function getModuleMeta(target) {
101
102
  }
102
103
  function Command(options) {
103
104
  return (target) => {
104
- defineMetadata(target, COMMAND_METADATA, { ...options });
105
+ defineMetadata(target, COMMAND_METADATA, {
106
+ ...options,
107
+ transaction: options.transaction ?? "none",
108
+ idempotency: options.idempotency ?? "none"
109
+ });
105
110
  };
106
111
  }
107
112
  function getCommandMeta(target) {
@@ -143,6 +148,8 @@ var Post = createRouteDecorator("POST");
143
148
  var Put = createRouteDecorator("PUT");
144
149
  var Patch = createRouteDecorator("PATCH");
145
150
  var Delete = createRouteDecorator("DELETE");
151
+ var Head = createRouteDecorator("HEAD");
152
+ var Options = createRouteDecorator("OPTIONS");
146
153
  function getRoutes(target) {
147
154
  return readOwnOrInherited(target, ROUTES_METADATA) ?? [];
148
155
  }
@@ -164,14 +171,19 @@ var REQUEST_CONTEXT = new InjectionToken("supacloud.request-context", {
164
171
  var JOB_CONTEXT = new InjectionToken("supacloud.job-context", {
165
172
  scope: "job"
166
173
  });
174
+ var DB_CLIENT = new InjectionToken("supacloud.db-client", {
175
+ scope: "application"
176
+ });
167
177
  export {
168
178
  COMMAND_METADATA,
169
179
  CONTROLLER_METADATA,
170
180
  Command,
171
181
  Controller,
182
+ DB_CLIENT,
172
183
  DEFAULT_SCOPE,
173
184
  Delete,
174
185
  Get,
186
+ Head,
175
187
  INJECTABLE_METADATA,
176
188
  INJECT_PARAMS_METADATA,
177
189
  Inject,
@@ -180,6 +192,7 @@ export {
180
192
  JOB_CONTEXT,
181
193
  MODULE_METADATA,
182
194
  Module,
195
+ Options,
183
196
  Patch,
184
197
  Post,
185
198
  Put,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supacloud/app",
3
- "version": "0.1.0",
3
+ "version": "0.4.0",
4
4
  "description": "Angular-style application metadata for SupaCloud: modules, DI tokens, providers, scopes, controllers and commands",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",