@mbc-cqrs-serverless/ui-setting 1.3.4 → 1.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
@@ -314,6 +314,42 @@ await dataSettingService.create(tenantCode, {
314
314
 
315
315
  Full documentation available at [https://mbc-cqrs-serverless.mbc-net.com/](https://mbc-cqrs-serverless.mbc-net.com/)
316
316
 
317
+ ## Configurable table name
318
+
319
+ `SettingModule` stores its data on the `master` DynamoDB table by default
320
+ (shared with `MasterModule`). Pass `tableName` to override it (backward
321
+ compatible). Both `register` and `registerAsync` accept it:
322
+
323
+ ```ts
324
+ SettingModule.register({
325
+ enableSettingController: true,
326
+ tableName: 'master', // default: 'master'
327
+ })
328
+
329
+ SettingModule.registerAsync({ tableName: 'master', inject: [] })
330
+
331
+ // When combined with MasterModule on the same table, let MasterModule own the
332
+ // data-sync pipeline and defer the alias:
333
+ SettingModule.register({
334
+ enableSettingController: true,
335
+ registerEventHandlerAlias: false,
336
+ })
337
+ ```
338
+
339
+ > **Shared table:** `SettingModule` and `MasterModule` share the same physical
340
+ > table. When you use both:
341
+ > 1. Register them with the **same** `tableName`, otherwise their data is split
342
+ > across two tables.
343
+ > 2. Set `registerEventHandlerAlias: false` on `SettingModule` so `MasterModule`
344
+ > owns the `<tableName>_CommandEventHandler` alias. If both modules own the
345
+ > alias, the app still boots but logs a **warning** — which module's data-sync
346
+ > handlers run is then import-order dependent, so setting the flag is required
347
+ > for deterministic behavior.
348
+ >
349
+ > **Provisioning:** A custom `tableName` must exist as physical tables
350
+ > (`-command` / `-data` / `-history`). Add the raw base name to
351
+ > `prisma/dynamodbs/cqrs.json` and define the tables in your IaC.
352
+
317
353
  ## License
318
354
 
319
355
  Copyright © 2024-2025, Murakami Business Consulting, Inc. [https://www.mbc-net.com/](https://www.mbc-net.com/)
@@ -1,5 +1,38 @@
1
+ import { IDataSyncHandler } from '@mbc-cqrs-serverless/core';
2
+ import { ModuleMetadata, Type } from '@nestjs/common';
3
+ /**
4
+ * ui-setting stores its data on the master table by default, so `tableName`
5
+ * defaults to 'master'. When combined with MasterModule, both modules MUST use
6
+ * the same `tableName` value.
7
+ *
8
+ * NOTE: this value must stay in sync with `TABLE_NAME` in
9
+ * `@mbc-cqrs-serverless/master` (packages/master/src/constants/index.ts). It is
10
+ * duplicated here to avoid a package dependency; if the master default table
11
+ * name ever changes, update this constant too.
12
+ */
13
+ export declare const DEFAULT_UI_SETTING_TABLE_NAME = "master";
1
14
  export interface SettingModuleOptions {
2
15
  enableSettingController?: boolean;
3
16
  enableDataController?: boolean;
17
+ /** DynamoDB base table name. Default: 'master' (shared with MasterModule). */
18
+ tableName?: string;
19
+ dataSyncHandlers?: Type<IDataSyncHandler>[];
20
+ /**
21
+ * Whether SettingModule owns the `<tableName>_CommandEventHandler` alias.
22
+ * Defaults to `true`. When combined with MasterModule on the same (default
23
+ * 'master') table, set this to `false` so MasterModule owns the alias and the
24
+ * duplicate-alias guard does not trip.
25
+ */
26
+ registerEventHandlerAlias?: boolean;
27
+ }
28
+ export interface SettingModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
29
+ enableSettingController?: boolean;
30
+ enableDataController?: boolean;
31
+ tableName?: string;
32
+ dataSyncHandlers?: Type<IDataSyncHandler>[];
33
+ registerEventHandlerAlias?: boolean;
34
+ inject?: any[];
35
+ /** ui-setting needs no runtime-resolved options; provided for API symmetry. */
36
+ useFactory?: (...args: any[]) => Promise<unknown> | unknown;
4
37
  }
5
38
  export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<SettingModuleOptions, "register", "create", {}>, MODULE_OPTIONS_TOKEN: string | symbol, OPTIONS_TYPE: SettingModuleOptions & Partial<{}>;
@@ -1,7 +1,18 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.OPTIONS_TYPE = exports.MODULE_OPTIONS_TOKEN = exports.ConfigurableModuleClass = void 0;
4
+ exports.OPTIONS_TYPE = exports.MODULE_OPTIONS_TOKEN = exports.ConfigurableModuleClass = exports.DEFAULT_UI_SETTING_TABLE_NAME = void 0;
5
5
  const common_1 = require("@nestjs/common");
6
+ /**
7
+ * ui-setting stores its data on the master table by default, so `tableName`
8
+ * defaults to 'master'. When combined with MasterModule, both modules MUST use
9
+ * the same `tableName` value.
10
+ *
11
+ * NOTE: this value must stay in sync with `TABLE_NAME` in
12
+ * `@mbc-cqrs-serverless/master` (packages/master/src/constants/index.ts). It is
13
+ * duplicated here to avoid a package dependency; if the master default table
14
+ * name ever changes, update this constant too.
15
+ */
16
+ exports.DEFAULT_UI_SETTING_TABLE_NAME = 'master';
6
17
  _a = new common_1.ConfigurableModuleBuilder().build(), exports.ConfigurableModuleClass = _a.ConfigurableModuleClass, exports.MODULE_OPTIONS_TOKEN = _a.MODULE_OPTIONS_TOKEN, exports.OPTIONS_TYPE = _a.OPTIONS_TYPE;
7
18
  //# sourceMappingURL=setting.module-definition.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"setting.module-definition.js","sourceRoot":"","sources":["../src/setting.module-definition.ts"],"names":[],"mappings":";;;;AAAA,2CAA0D;AAM7C,KACX,IAAI,kCAAyB,EAAwB,CAAC,KAAK,EAAE,EADhD,+BAAuB,+BAAE,4BAAoB,4BAAE,oBAAY,mBACX"}
1
+ {"version":3,"file":"setting.module-definition.js","sourceRoot":"","sources":["../src/setting.module-definition.ts"],"names":[],"mappings":";;;;AACA,2CAAgF;AAEhF;;;;;;;;;GASG;AACU,QAAA,6BAA6B,GAAG,QAAQ,CAAA;AA6BxC,KACX,IAAI,kCAAyB,EAAwB,CAAC,KAAK,EAAE,EADhD,+BAAuB,+BAAE,4BAAoB,4BAAE,oBAAY,mBACX"}
@@ -1,5 +1,6 @@
1
1
  import { DynamicModule } from '@nestjs/common';
2
- import { ConfigurableModuleClass, OPTIONS_TYPE } from './setting.module-definition';
2
+ import { ConfigurableModuleClass, OPTIONS_TYPE, SettingModuleAsyncOptions } from './setting.module-definition';
3
3
  export declare class SettingModule extends ConfigurableModuleClass {
4
4
  static register(options: typeof OPTIONS_TYPE): DynamicModule;
5
+ static registerAsync(options: SettingModuleAsyncOptions): DynamicModule;
5
6
  }
@@ -16,34 +16,62 @@ const setting_service_1 = require("./services/setting.service");
16
16
  const setting_module_definition_1 = require("./setting.module-definition");
17
17
  let SettingModule = class SettingModule extends setting_module_definition_1.ConfigurableModuleClass {
18
18
  static register(options) {
19
- const module = super.register(options);
20
- const { enableDataController, enableSettingController } = options;
21
- if (enableDataController || enableSettingController) {
22
- if (!module.controllers) {
23
- module.controllers = [];
24
- }
25
- if (enableDataController) {
26
- module.controllers.push(data_setting_controller_1.DataSettingController);
27
- }
28
- if (enableSettingController) {
29
- module.controllers.push(setting_controller_1.SettingController);
30
- }
19
+ const base = super.register(options);
20
+ const controllers = [...(base.controllers ?? [])];
21
+ const imports = [...(base.imports ?? [])];
22
+ const providers = [...(base.providers ?? [])];
23
+ const handlers = options.dataSyncHandlers ?? [];
24
+ providers.push(...handlers);
25
+ if (options.enableDataController) {
26
+ controllers.push(data_setting_controller_1.DataSettingController);
31
27
  }
32
- return {
33
- ...module,
34
- };
28
+ if (options.enableSettingController) {
29
+ controllers.push(setting_controller_1.SettingController);
30
+ }
31
+ imports.push((0, core_1.buildDomainCommandModule)(setting_module_definition_1.DEFAULT_UI_SETTING_TABLE_NAME, {
32
+ tableName: options.tableName,
33
+ dataSyncHandlers: handlers,
34
+ registerEventHandlerAlias: options.registerEventHandlerAlias,
35
+ }));
36
+ return { ...base, providers, controllers, imports };
37
+ }
38
+ static registerAsync(options) {
39
+ const base = super.registerAsync({
40
+ imports: options.imports,
41
+ inject: options.inject ?? [],
42
+ useFactory: async (...args) => {
43
+ await options.useFactory?.(...args);
44
+ return {
45
+ enableDataController: options.enableDataController,
46
+ enableSettingController: options.enableSettingController,
47
+ tableName: options.tableName ?? setting_module_definition_1.DEFAULT_UI_SETTING_TABLE_NAME,
48
+ dataSyncHandlers: options.dataSyncHandlers,
49
+ };
50
+ },
51
+ });
52
+ const controllers = [...(base.controllers ?? [])];
53
+ const imports = [...(base.imports ?? [])];
54
+ const providers = [...(base.providers ?? [])];
55
+ const handlers = options.dataSyncHandlers ?? [];
56
+ providers.push(...handlers);
57
+ if (options.enableDataController) {
58
+ controllers.push(data_setting_controller_1.DataSettingController);
59
+ }
60
+ if (options.enableSettingController) {
61
+ controllers.push(setting_controller_1.SettingController);
62
+ }
63
+ imports.push((0, core_1.buildDomainCommandModule)(setting_module_definition_1.DEFAULT_UI_SETTING_TABLE_NAME, {
64
+ tableName: options.tableName,
65
+ dataSyncHandlers: handlers,
66
+ registerEventHandlerAlias: options.registerEventHandlerAlias,
67
+ }));
68
+ return { ...base, providers, controllers, imports };
35
69
  }
36
70
  };
37
71
  exports.SettingModule = SettingModule;
38
72
  exports.SettingModule = SettingModule = __decorate([
39
73
  (0, common_1.Module)({
40
- imports: [
41
- core_1.CommandModule.register({
42
- tableName: 'master',
43
- }),
44
- core_1.DataStoreModule,
45
- core_1.QueueModule,
46
- ],
74
+ imports: [core_1.DataStoreModule, core_1.QueueModule],
47
75
  providers: [setting_service_1.SettingService, data_setting_service_1.DataSettingService],
48
76
  exports: [setting_service_1.SettingService, data_setting_service_1.DataSettingService],
49
77
  })
@@ -1 +1 @@
1
- {"version":3,"file":"setting.module.js","sourceRoot":"","sources":["../src/setting.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAIkC;AAClC,2CAAsD;AAEtD,mFAA6E;AAC7E,yEAAoE;AACpE,0EAAoE;AACpE,gEAA2D;AAC3D,2EAGoC;AAY7B,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,mDAAuB;IACxD,MAAM,CAAC,QAAQ,CAAC,OAA4B;QAC1C,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QAEtC,MAAM,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,GAAG,OAAO,CAAA;QAEjE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c-cqrs-serverless/ui-setting",
3
- "version": "1.3.4",
3
+ "version": "1.4.0",
4
4
  "description": "Setting master data",
5
5
  "keywords": [
6
6
  "mbc",
@@ -41,7 +41,7 @@
41
41
  "access": "public"
42
42
  },
43
43
  "dependencies": {
44
- "@mbc-cqrs-serverless/core": "1.3.4"
44
+ "@mbc-cqrs-serverless/core": "1.4.0"
45
45
  },
46
- "gitHead": "e5b2e10fe73ebd89bf26b23942752d4ebe79388e"
46
+ "gitHead": "972a2726e2696e94e988dfc3135086b13cf2345b"
47
47
  }