@izumisy-tailor/omakase-modules 0.3.0 → 0.4.1

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.
Files changed (37) hide show
  1. package/README.md +0 -16
  2. package/docs/generated/README.md +35 -0
  3. package/docs/{tutorials → generated/_media}/creating-modules.md +192 -17
  4. package/docs/{tutorials → generated/_media}/using-modules.md +17 -18
  5. package/docs/generated/builder/README.md +25 -0
  6. package/docs/generated/builder/functions/defineModule.md +60 -0
  7. package/docs/generated/builder/functions/withModuleConfiguration.md +68 -0
  8. package/docs/generated/builder/type-aliases/AnyDefinedModule.md +57 -0
  9. package/docs/generated/builder/type-aliases/ConfiguredDependencies.md +44 -0
  10. package/docs/generated/builder/type-aliases/ConfiguredModule.md +60 -0
  11. package/docs/generated/builder/type-aliases/DefinedModule.md +93 -0
  12. package/docs/generated/builder/type-aliases/DependencyModules.md +29 -0
  13. package/docs/generated/builder/type-aliases/EmptyDependencies.md +34 -0
  14. package/docs/generated/builder/type-aliases/ModuleBuilder.md +124 -0
  15. package/docs/generated/builder/type-aliases/ModuleBuilderProps.md +42 -0
  16. package/docs/generated/builder/type-aliases/ModuleFactoryContext.md +40 -0
  17. package/docs/generated/builder/type-aliases/TablesFromNames.md +28 -0
  18. package/docs/generated/config/README.md +19 -0
  19. package/docs/generated/config/classes/ModuleLoader.md +128 -0
  20. package/docs/generated/config/functions/loadModules.md +79 -0
  21. package/docs/generated/config/sdk/README.md +16 -0
  22. package/docs/generated/config/sdk/functions/getModulesReference.md +81 -0
  23. package/docs/generated/config/sdk/functions/loadModuleForDev.md +53 -0
  24. package/docs/generated/config/sdk/type-aliases/GetModulesReferenceOptions.md +60 -0
  25. package/docs/generated/config/type-aliases/LoadedModules.md +162 -0
  26. package/docs/generated/modules.md +11 -0
  27. package/package.json +11 -7
  28. package/src/builder/helpers.ts +347 -27
  29. package/src/builder/index.ts +6 -1
  30. package/src/builder/register.ts +3 -6
  31. package/src/config/module-loader.ts +234 -12
  32. package/src/config/sdk/dev-context.ts +82 -0
  33. package/src/config/sdk/index.ts +2 -1
  34. package/src/config/sdk/paths.ts +85 -3
  35. package/src/config/sdk/wrapper/base.ts +68 -15
  36. package/src/config/sdk/wrapper/generator.ts +40 -3
  37. package/src/config/sdk/wrapper/strategies.ts +32 -13
@@ -0,0 +1,60 @@
1
+ [**@izumisy-tailor/omakase-modules**](../../README.md)
2
+
3
+ ***
4
+
5
+ [@izumisy-tailor/omakase-modules](../../modules.md) / [builder](../README.md) / ConfiguredModule
6
+
7
+ # Type Alias: ConfiguredModule\<C\>
8
+
9
+ > **ConfiguredModule**\<`C`\> = `object`
10
+
11
+ Defined in: [builder/helpers.ts:80](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/builder/helpers.ts#L80)
12
+
13
+ A module that has been configured with specific settings.
14
+
15
+ This type represents the result of calling `configure()` on a [DefinedModule](DefinedModule.md).
16
+ Configured modules can be passed as dependencies to other modules or used
17
+ directly in your application's Tailor configuration.
18
+
19
+ ## Example
20
+
21
+ ```typescript
22
+ // Create a configured module
23
+ const $commerceModule = commerceModule.configure({
24
+ config: { dbNamespace: "main-db" },
25
+ });
26
+
27
+ // Use as a dependency in another module
28
+ const $inventoryModule = inventoryModule.configure({
29
+ config: { dbNamespace: "main-db" },
30
+ dependencies: {
31
+ commerce: $commerceModule,
32
+ },
33
+ });
34
+ ```
35
+
36
+ ## Type Parameters
37
+
38
+ | Type Parameter | Default type |
39
+ | ------ | ------ |
40
+ | `C` *extends* `Record`\<`string`, `unknown`\> | `Record`\<`string`, `unknown`\> |
41
+
42
+ ## Properties
43
+
44
+ ### moduleProps
45
+
46
+ > **moduleProps**: `object`
47
+
48
+ Defined in: [builder/helpers.ts:87](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/builder/helpers.ts#L87)
49
+
50
+ #### config
51
+
52
+ > **config**: `C`
53
+
54
+ ***
55
+
56
+ ### packageName
57
+
58
+ > **packageName**: `string`
59
+
60
+ Defined in: [builder/helpers.ts:86](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/builder/helpers.ts#L86)
@@ -0,0 +1,93 @@
1
+ [**@izumisy-tailor/omakase-modules**](../../README.md)
2
+
3
+ ***
4
+
5
+ [@izumisy-tailor/omakase-modules](../../modules.md) / [builder](../README.md) / DefinedModule
6
+
7
+ # Type Alias: DefinedModule\<C, Tables, Deps\>
8
+
9
+ > **DefinedModule**\<`C`, `Tables`, `Deps`\> = `object`
10
+
11
+ Defined in: [builder/helpers.ts:214](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/builder/helpers.ts#L214)
12
+
13
+ A fully defined, reusable module that can be configured and composed.
14
+
15
+ This is the primary type for modules created with [defineModule](../functions/defineModule.md).
16
+ A `DefinedModule` encapsulates:
17
+ - The module's package name for identification
18
+ - Its dependencies on other modules
19
+ - A `configure()` method to create a [ConfiguredModule](ConfiguredModule.md)
20
+ - Optional development configuration for local testing
21
+
22
+ ## Example
23
+
24
+ ```typescript
25
+ // Define a module
26
+ const inventoryModule = defineModule<InventoryConfig, InventoryTables>({
27
+ packageName: "inventory-module",
28
+ })
29
+ .withDependencies({ commerce: commerceModule })
30
+ .withDevConfig({ dbNamespace: "dev" })
31
+ .build();
32
+
33
+ // Configure the module for use
34
+ const $inventory = inventoryModule.configure({
35
+ config: { dbNamespace: "production" },
36
+ dependencies: {
37
+ commerce: $commerceModule,
38
+ },
39
+ });
40
+ ```
41
+
42
+ ## Type Parameters
43
+
44
+ | Type Parameter | Default type |
45
+ | ------ | ------ |
46
+ | `C` *extends* `Record`\<`string`, `unknown`\> | - |
47
+ | `Tables` *extends* `Record`\<`string`, `unknown`\> | `Record`\<`string`, `unknown`\> |
48
+ | `Deps` *extends* [`DependencyModules`](DependencyModules.md) | [`EmptyDependencies`](EmptyDependencies.md) |
49
+
50
+ ## Properties
51
+
52
+ ### configure()
53
+
54
+ > **configure**: (`props`) => [`ConfiguredModule`](ConfiguredModule.md)\<`C`\>
55
+
56
+ Defined in: [builder/helpers.ts:230](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/builder/helpers.ts#L230)
57
+
58
+ #### Parameters
59
+
60
+ | Parameter | Type |
61
+ | ------ | ------ |
62
+ | `props` | [`ModuleBuilderProps`](ModuleBuilderProps.md)\<`C`, `Deps`\> |
63
+
64
+ #### Returns
65
+
66
+ [`ConfiguredModule`](ConfiguredModule.md)\<`C`\>
67
+
68
+ ***
69
+
70
+ ### dependencies
71
+
72
+ > **dependencies**: `Deps`
73
+
74
+ Defined in: [builder/helpers.ts:229](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/builder/helpers.ts#L229)
75
+
76
+ ***
77
+
78
+ ### devConfig?
79
+
80
+ > `optional` **devConfig**: `C`
81
+
82
+ Defined in: [builder/helpers.ts:235](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/builder/helpers.ts#L235)
83
+
84
+ Default configuration for module development.
85
+ Used by loadModuleForDev when no config is provided.
86
+
87
+ ***
88
+
89
+ ### packageName
90
+
91
+ > **packageName**: `string`
92
+
93
+ Defined in: [builder/helpers.ts:228](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/builder/helpers.ts#L228)
@@ -0,0 +1,29 @@
1
+ [**@izumisy-tailor/omakase-modules**](../../README.md)
2
+
3
+ ***
4
+
5
+ [@izumisy-tailor/omakase-modules](../../modules.md) / [builder](../README.md) / DependencyModules
6
+
7
+ # Type Alias: DependencyModules
8
+
9
+ > **DependencyModules** = `Record`\<`string`, [`AnyDefinedModule`](AnyDefinedModule.md)\> \| [`EmptyDependencies`](EmptyDependencies.md)
10
+
11
+ Defined in: [builder/helpers.ts:112](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/builder/helpers.ts#L112)
12
+
13
+ A record of module dependencies or an empty dependency set.
14
+
15
+ This type represents the dependencies that a module can declare.
16
+ It is either a record mapping dependency names to [AnyDefinedModule](AnyDefinedModule.md),
17
+ or [EmptyDependencies](EmptyDependencies.md) for modules without dependencies.
18
+
19
+ ## Example
20
+
21
+ ```typescript
22
+ // Used internally when defining module dependencies
23
+ defineModule<MyConfig, MyTables>({
24
+ packageName: "my-module",
25
+ }).withDependencies({
26
+ commerce: commerceModule, // Record<string, AnyDefinedModule>
27
+ order: orderModule,
28
+ }).build();
29
+ ```
@@ -0,0 +1,34 @@
1
+ [**@izumisy-tailor/omakase-modules**](../../README.md)
2
+
3
+ ***
4
+
5
+ [@izumisy-tailor/omakase-modules](../../modules.md) / [builder](../README.md) / EmptyDependencies
6
+
7
+ # Type Alias: EmptyDependencies
8
+
9
+ > **EmptyDependencies** = `object`
10
+
11
+ Defined in: [builder/helpers.ts:18](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/builder/helpers.ts#L18)
12
+
13
+ Represents a module with no dependencies.
14
+
15
+ This is a branded type used internally to distinguish modules
16
+ that have no dependencies from those that do. When defining a module
17
+ without dependencies, you don't need to use this type directly.
18
+
19
+ ## Example
20
+
21
+ ```typescript
22
+ // Modules without dependencies don't need to specify this type
23
+ export default defineModule<MyConfig, MyTables>({
24
+ packageName: "my-module",
25
+ }).build();
26
+ ```
27
+
28
+ ## Properties
29
+
30
+ ### \_\_empty?
31
+
32
+ > `readonly` `optional` **\_\_empty**: `never`
33
+
34
+ Defined in: [builder/helpers.ts:18](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/builder/helpers.ts#L18)
@@ -0,0 +1,124 @@
1
+ [**@izumisy-tailor/omakase-modules**](../../README.md)
2
+
3
+ ***
4
+
5
+ [@izumisy-tailor/omakase-modules](../../modules.md) / [builder](../README.md) / ModuleBuilder
6
+
7
+ # Type Alias: ModuleBuilder\<C, Tables, Deps\>
8
+
9
+ > **ModuleBuilder**\<`C`, `Tables`, `Deps`\> = `object`
10
+
11
+ Defined in: [builder/helpers.ts:251](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/builder/helpers.ts#L251)
12
+
13
+ Intermediate builder type returned by defineModule.
14
+ Use .withDependencies() to add dependencies, then call .build() to finalize.
15
+ Modules without dependencies can call .build() directly.
16
+
17
+ ## Type Parameters
18
+
19
+ | Type Parameter | Default type |
20
+ | ------ | ------ |
21
+ | `C` *extends* `Record`\<`string`, `unknown`\> | - |
22
+ | `Tables` *extends* `Record`\<`string`, `unknown`\> | - |
23
+ | `Deps` *extends* [`DependencyModules`](DependencyModules.md) | [`EmptyDependencies`](EmptyDependencies.md) |
24
+
25
+ ## Properties
26
+
27
+ ### build()
28
+
29
+ > **build**: () => [`DefinedModule`](DefinedModule.md)\<`C`, `Tables`, `Deps`\>
30
+
31
+ Defined in: [builder/helpers.ts:307](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/builder/helpers.ts#L307)
32
+
33
+ Finalizes the module definition and returns the DefinedModule.
34
+ This must be called at the end of the builder chain to get the actual module.
35
+
36
+ #### Returns
37
+
38
+ [`DefinedModule`](DefinedModule.md)\<`C`, `Tables`, `Deps`\>
39
+
40
+ #### Example
41
+
42
+ ```typescript
43
+ // Without dependencies
44
+ export default defineModule<ModuleConfig, Tables>({
45
+ packageName: "my-module",
46
+ }).build();
47
+
48
+ // With dependencies and dev config
49
+ export default defineModule<ModuleConfig, Tables>({
50
+ packageName: "my-module",
51
+ })
52
+ .withDependencies({ commerce: commerceModule })
53
+ .withDevConfig({ dbNamespace: "dev" })
54
+ .build();
55
+ ```
56
+
57
+ ***
58
+
59
+ ### withDependencies()
60
+
61
+ > **withDependencies**: \<`NewDeps`\>(`deps`) => `ModuleBuilder`\<`C`, `Tables`, `NewDeps`\>
62
+
63
+ Defined in: [builder/helpers.ts:270](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/builder/helpers.ts#L270)
64
+
65
+ Adds dependencies to the module definition.
66
+ The Deps type is automatically inferred from the record.
67
+
68
+ #### Type Parameters
69
+
70
+ | Type Parameter |
71
+ | ------ |
72
+ | `NewDeps` *extends* [`DependencyModules`](DependencyModules.md) |
73
+
74
+ #### Parameters
75
+
76
+ | Parameter | Type |
77
+ | ------ | ------ |
78
+ | `deps` | `NewDeps` |
79
+
80
+ #### Returns
81
+
82
+ `ModuleBuilder`\<`C`, `Tables`, `NewDeps`\>
83
+
84
+ #### Example
85
+
86
+ ```typescript
87
+ export default defineModule<ModuleConfig, Tables>({
88
+ packageName: "my-module",
89
+ }).withDependencies({
90
+ commerce: commerceModule,
91
+ order: orderModule,
92
+ }).build();
93
+ ```
94
+
95
+ ***
96
+
97
+ ### withDevConfig()
98
+
99
+ > **withDevConfig**: (`config`) => `ModuleBuilder`\<`C`, `Tables`, `Deps`\>
100
+
101
+ Defined in: [builder/helpers.ts:286](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/builder/helpers.ts#L286)
102
+
103
+ Sets the default configuration for module development.
104
+ This config is used by loadModuleForDev when no config is provided.
105
+
106
+ #### Parameters
107
+
108
+ | Parameter | Type |
109
+ | ------ | ------ |
110
+ | `config` | `C` |
111
+
112
+ #### Returns
113
+
114
+ `ModuleBuilder`\<`C`, `Tables`, `Deps`\>
115
+
116
+ #### Example
117
+
118
+ ```typescript
119
+ export default defineModule<ModuleConfig, Tables>({
120
+ packageName: "my-module",
121
+ }).withDevConfig({
122
+ dbNamespace: "main-db",
123
+ }).build();
124
+ ```
@@ -0,0 +1,42 @@
1
+ [**@izumisy-tailor/omakase-modules**](../../README.md)
2
+
3
+ ***
4
+
5
+ [@izumisy-tailor/omakase-modules](../../modules.md) / [builder](../README.md) / ModuleBuilderProps
6
+
7
+ # Type Alias: ModuleBuilderProps\<C, Deps\>
8
+
9
+ > **ModuleBuilderProps**\<`C`, `Deps`\> = `Deps` *extends* [`EmptyDependencies`](EmptyDependencies.md) ? `object` : `object`
10
+
11
+ Defined in: [builder/helpers.ts:44](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/builder/helpers.ts#L44)
12
+
13
+ Properties required when configuring a module via `configure()`.
14
+
15
+ The shape of this type varies based on whether the module has dependencies:
16
+ - **Without dependencies**: `{ config: C }`
17
+ - **With dependencies**: `{ config: C; dependencies: ConfiguredDependencies<Deps> }`
18
+
19
+ ## Type Parameters
20
+
21
+ | Type Parameter |
22
+ | ------ |
23
+ | `C` *extends* `Record`\<`string`, `unknown`\> |
24
+ | `Deps` *extends* [`DependencyModules`](DependencyModules.md) |
25
+
26
+ ## Example
27
+
28
+ ```typescript
29
+ // Module without dependencies
30
+ myModule.configure({
31
+ config: { dbNamespace: "main-db" },
32
+ });
33
+
34
+ // Module with dependencies
35
+ inventoryModule.configure({
36
+ config: { dbNamespace: "main-db" },
37
+ dependencies: {
38
+ commerce: $commerceModule,
39
+ order: $orderModule,
40
+ },
41
+ });
42
+ ```
@@ -0,0 +1,40 @@
1
+ [**@izumisy-tailor/omakase-modules**](../../README.md)
2
+
3
+ ***
4
+
5
+ [@izumisy-tailor/omakase-modules](../../modules.md) / [builder](../README.md) / ModuleFactoryContext
6
+
7
+ # Type Alias: ModuleFactoryContext\<C\>
8
+
9
+ > **ModuleFactoryContext**\<`C`\> = `object`
10
+
11
+ Defined in: [builder/helpers.ts:409](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/builder/helpers.ts#L409)
12
+
13
+ Context passed to table builder functions.
14
+ Provides access to the module's configuration.
15
+
16
+ ## Example
17
+
18
+ ```typescript
19
+ export const buildProductTable = (
20
+ { config }: ModuleFactoryContext<ModuleConfig>,
21
+ deps: { category: TailorDBType }
22
+ ) => {
23
+ const prefix = config.dataModel?.product?.docNumberPrefix ?? "PROD";
24
+ return db.type("Product", { ... });
25
+ };
26
+ ```
27
+
28
+ ## Type Parameters
29
+
30
+ | Type Parameter |
31
+ | ------ |
32
+ | `C` *extends* `Record`\<`string`, `unknown`\> |
33
+
34
+ ## Properties
35
+
36
+ ### config
37
+
38
+ > **config**: `C`
39
+
40
+ Defined in: [builder/helpers.ts:410](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/builder/helpers.ts#L410)
@@ -0,0 +1,28 @@
1
+ [**@izumisy-tailor/omakase-modules**](../../README.md)
2
+
3
+ ***
4
+
5
+ [@izumisy-tailor/omakase-modules](../../modules.md) / [builder](../README.md) / TablesFromNames
6
+
7
+ # Type Alias: TablesFromNames\<T\>
8
+
9
+ > **TablesFromNames**\<`T`\> = `{ [K in T[number]]: TailorDBType }`
10
+
11
+ Defined in: [builder/helpers.ts:390](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/builder/helpers.ts#L390)
12
+
13
+ Derives a tables type from a tableNames array.
14
+ Use this to avoid manually defining a separate Tables type.
15
+
16
+ ## Type Parameters
17
+
18
+ | Type Parameter |
19
+ | ------ |
20
+ | `T` *extends* readonly `string`[] |
21
+
22
+ ## Example
23
+
24
+ ```typescript
25
+ export const tableNames = ["product", "category"] as const;
26
+ type MyTables = TablesFromNames<typeof tableNames>;
27
+ // Result: { product: TailorDBType; category: TailorDBType }
28
+ ```
@@ -0,0 +1,19 @@
1
+ [**@izumisy-tailor/omakase-modules**](../README.md)
2
+
3
+ ***
4
+
5
+ [@izumisy-tailor/omakase-modules](../modules.md) / config
6
+
7
+ # config
8
+
9
+ ## Classes
10
+
11
+ - [ModuleLoader](classes/ModuleLoader.md)
12
+
13
+ ## Type Aliases
14
+
15
+ - [LoadedModules](type-aliases/LoadedModules.md)
16
+
17
+ ## Functions
18
+
19
+ - [loadModules](functions/loadModules.md)
@@ -0,0 +1,128 @@
1
+ [**@izumisy-tailor/omakase-modules**](../../README.md)
2
+
3
+ ***
4
+
5
+ [@izumisy-tailor/omakase-modules](../../modules.md) / [config](../README.md) / ModuleLoader
6
+
7
+ # Class: ModuleLoader
8
+
9
+ Defined in: [config/module-loader.ts:49](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/config/module-loader.ts#L49)
10
+
11
+ Module loader for registering and configuring modules.
12
+
13
+ The `ModuleLoader` is used within the [loadModules](../functions/loadModules.md) function to register
14
+ configured modules. Modules can depend on each other, and the loader ensures
15
+ proper dependency management.
16
+
17
+ ## Example
18
+
19
+ ```typescript
20
+ import { loadModules } from "@izumisy-tailor/omakase-modules";
21
+ import commerceModule from "omakase-module-commerce-core";
22
+ import orderModule from "omakase-module-order";
23
+ import inventoryModule from "omakase-module-inventory";
24
+
25
+ export default loadModules((loader) => {
26
+ // Add a module without dependencies
27
+ const $commerce = loader.add(
28
+ commerceModule.configure({
29
+ config: {
30
+ dataModel: {
31
+ product: { docNumberPrefix: "PROD" },
32
+ },
33
+ },
34
+ })
35
+ );
36
+
37
+ // Add a module that depends on commerce
38
+ const $order = loader.add(
39
+ orderModule.configure({
40
+ config: { dataModel: {} },
41
+ dependencies: { commerce: $commerce },
42
+ })
43
+ );
44
+
45
+ // Add a module that depends on both commerce and order
46
+ loader.add(
47
+ inventoryModule.configure({
48
+ config: { dbNamespace: "main-db" },
49
+ dependencies: { commerce: $commerce, order: $order },
50
+ })
51
+ );
52
+
53
+ return loader;
54
+ });
55
+ ```
56
+
57
+ ## Constructors
58
+
59
+ ### Constructor
60
+
61
+ > **new ModuleLoader**(): `ModuleLoader`
62
+
63
+ #### Returns
64
+
65
+ `ModuleLoader`
66
+
67
+ ## Methods
68
+
69
+ ### add()
70
+
71
+ > **add**\<`C`\>(`module`): [`ConfiguredModule`](../../builder/type-aliases/ConfiguredModule.md)\<`C`\>
72
+
73
+ Defined in: [config/module-loader.ts:92](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/config/module-loader.ts#L92)
74
+
75
+ Add a configured module to the loader.
76
+
77
+ Returns the added module so it can be used as a dependency for other modules.
78
+ This enables type-safe dependency wiring between modules.
79
+
80
+ #### Type Parameters
81
+
82
+ | Type Parameter |
83
+ | ------ |
84
+ | `C` *extends* `Record`\<`string`, `unknown`\> |
85
+
86
+ #### Parameters
87
+
88
+ | Parameter | Type | Description |
89
+ | ------ | ------ | ------ |
90
+ | `module` | [`ConfiguredModule`](../../builder/type-aliases/ConfiguredModule.md)\<`C`\> | A configured module created by calling `moduleDefinition.configure()` |
91
+
92
+ #### Returns
93
+
94
+ [`ConfiguredModule`](../../builder/type-aliases/ConfiguredModule.md)\<`C`\>
95
+
96
+ The same configured module, to be used as a dependency for other modules
97
+
98
+ #### Example
99
+
100
+ ```typescript
101
+ loadModules((loader) => {
102
+ // Capture the returned value to use as a dependency
103
+ const $commerce = loader.add(
104
+ commerceModule.configure({
105
+ config: {
106
+ dataModel: {
107
+ product: {
108
+ docNumberPrefix: "PP-PROD",
109
+ customAttributes: {
110
+ customStatus: db.enum(["new", "used", "refurbished"]),
111
+ },
112
+ },
113
+ },
114
+ },
115
+ })
116
+ );
117
+
118
+ // Use the captured module as a dependency
119
+ loader.add(
120
+ orderModule.configure({
121
+ config: { dataModel: {} },
122
+ dependencies: { commerce: $commerce },
123
+ })
124
+ );
125
+
126
+ return loader;
127
+ });
128
+ ```
@@ -0,0 +1,79 @@
1
+ [**@izumisy-tailor/omakase-modules**](../../README.md)
2
+
3
+ ***
4
+
5
+ [@izumisy-tailor/omakase-modules](../../modules.md) / [config](../README.md) / loadModules
6
+
7
+ # Function: loadModules()
8
+
9
+ > **loadModules**(`configurator`): [`LoadedModules`](../type-aliases/LoadedModules.md)
10
+
11
+ Defined in: [config/module-loader.ts:277](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/config/module-loader.ts#L277)
12
+
13
+ Load and configure modules for your Tailor application.
14
+
15
+ This is the main entry point for setting up omakase modules. Use this function
16
+ to register all modules your application needs, configure them with your settings,
17
+ and wire up dependencies between modules.
18
+
19
+ ## Parameters
20
+
21
+ | Parameter | Type | Description |
22
+ | ------ | ------ | ------ |
23
+ | `configurator` | (`loader`) => [`ModuleLoader`](../classes/ModuleLoader.md) | A function that receives a [ModuleLoader](../classes/ModuleLoader.md) and returns it after adding modules |
24
+
25
+ ## Returns
26
+
27
+ [`LoadedModules`](../type-aliases/LoadedModules.md)
28
+
29
+ A [LoadedModules](../type-aliases/LoadedModules.md) object containing all registered modules and utilities
30
+
31
+ ## Example
32
+
33
+ ```typescript
34
+ // modules.ts - Define your module configuration
35
+ import { loadModules } from "@izumisy-tailor/omakase-modules";
36
+ import { db } from "@tailor-platform/sdk";
37
+ import commerceModule from "omakase-module-commerce-core";
38
+ import orderModule from "omakase-module-order";
39
+ import inventoryModule from "omakase-module-inventory";
40
+
41
+ export default loadModules((loader) => {
42
+ // Configure and add the commerce module
43
+ const $commerce = loader.add(
44
+ commerceModule.configure({
45
+ config: {
46
+ dataModel: {
47
+ product: {
48
+ docNumberPrefix: "PP-PROD",
49
+ customAttributes: {
50
+ customStatus: db.enum(["new", "used", "refurbished"]),
51
+ },
52
+ },
53
+ },
54
+ },
55
+ })
56
+ );
57
+
58
+ // Configure order module with commerce as a dependency
59
+ const $order = loader.add(
60
+ orderModule.configure({
61
+ config: { dataModel: {} },
62
+ dependencies: { commerce: $commerce },
63
+ })
64
+ );
65
+
66
+ // Configure inventory module with both dependencies
67
+ loader.add(
68
+ inventoryModule.configure({
69
+ config: {
70
+ dbNamespace: "main-db",
71
+ invantoryBootstrapBaseValue: 300,
72
+ },
73
+ dependencies: { commerce: $commerce, order: $order },
74
+ })
75
+ );
76
+
77
+ return loader;
78
+ });
79
+ ```