@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,16 @@
1
+ [**@izumisy-tailor/omakase-modules**](../../README.md)
2
+
3
+ ***
4
+
5
+ [@izumisy-tailor/omakase-modules](../../modules.md) / config/sdk
6
+
7
+ # config/sdk
8
+
9
+ ## Type Aliases
10
+
11
+ - [GetModulesReferenceOptions](type-aliases/GetModulesReferenceOptions.md)
12
+
13
+ ## Functions
14
+
15
+ - [getModulesReference](functions/getModulesReference.md)
16
+ - [loadModuleForDev](functions/loadModuleForDev.md)
@@ -0,0 +1,81 @@
1
+ [**@izumisy-tailor/omakase-modules**](../../../README.md)
2
+
3
+ ***
4
+
5
+ [@izumisy-tailor/omakase-modules](../../../modules.md) / [config/sdk](../README.md) / getModulesReference
6
+
7
+ # Function: getModulesReference()
8
+
9
+ > **getModulesReference**(`loadedModules`, `options`): `Promise`\<\{ `executor`: `string`[]; `resolver`: `string`[]; `tailordb`: `string`[]; \}\>
10
+
11
+ Defined in: [config/sdk/paths.ts:98](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/config/sdk/paths.ts#L98)
12
+
13
+ Get file path patterns for modules to use in Tailor configuration.
14
+
15
+ This function processes your loaded modules and returns glob patterns
16
+ that can be spread into your `defineConfig`. It handles all the necessary
17
+ setup to make module TailorDB types, resolvers, and executors available
18
+ to Tailor's configuration system.
19
+
20
+ ## Parameters
21
+
22
+ | Parameter | Type | Description |
23
+ | ------ | ------ | ------ |
24
+ | `loadedModules` | [`LoadedModules`](../../type-aliases/LoadedModules.md) | The result of calling `loadModules()` |
25
+ | `options` | [`GetModulesReferenceOptions`](../type-aliases/GetModulesReferenceOptions.md) | Optional configuration for path resolution and logging |
26
+
27
+ ## Returns
28
+
29
+ `Promise`\<\{ `executor`: `string`[]; `resolver`: `string`[]; `tailordb`: `string`[]; \}\>
30
+
31
+ An object containing glob patterns for `tailordb`, `resolver`, and `executor` files
32
+
33
+ ## Examples
34
+
35
+ ```typescript
36
+ // tailor.config.ts
37
+ import { defineConfig, defineGenerators } from "@tailor-platform/sdk";
38
+ import { getModulesReference } from "@izumisy-tailor/omakase-modules/config/sdk";
39
+ import modules from "./modules";
40
+
41
+ // Get module path patterns
42
+ const moduleReference = await getModulesReference(modules);
43
+
44
+ export default defineConfig({
45
+ name: "my-app",
46
+
47
+ // Spread module paths alongside your local files
48
+ db: {
49
+ "main-db": {
50
+ files: ["./src/tailordb/*.ts", ...moduleReference.tailordb],
51
+ },
52
+ },
53
+
54
+ resolver: {
55
+ "main-pipeline": {
56
+ files: ["./src/resolvers/*.ts", ...moduleReference.resolver],
57
+ },
58
+ },
59
+
60
+ executor: {
61
+ files: ["./src/executors/*.ts", ...moduleReference.executor],
62
+ },
63
+ });
64
+ ```
65
+
66
+ ```typescript
67
+ // With custom options
68
+ const moduleReference = await getModulesReference(modules, {
69
+ basePath: import.meta.dirname, // Use ESM module directory
70
+ silent: true, // No console output
71
+ });
72
+ ```
73
+
74
+ ## Remarks
75
+
76
+ The returned object contains three arrays:
77
+ - `tailordb` - Paths to TailorDB type definitions from modules
78
+ - `resolver` - Paths to GraphQL resolver definitions from modules
79
+ - `executor` - Paths to event executor definitions from modules
80
+
81
+ If a module has no files of a certain type, that array will be empty.
@@ -0,0 +1,53 @@
1
+ [**@izumisy-tailor/omakase-modules**](../../../README.md)
2
+
3
+ ***
4
+
5
+ [@izumisy-tailor/omakase-modules](../../../modules.md) / [config/sdk](../README.md) / loadModuleForDev
6
+
7
+ # Function: loadModuleForDev()
8
+
9
+ > **loadModuleForDev**\<`C`, `Tables`, `Deps`\>(`module`, `config?`): [`LoadedModules`](../../type-aliases/LoadedModules.md)
10
+
11
+ Defined in: [config/sdk/dev-context.ts:29](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/config/sdk/dev-context.ts#L29)
12
+
13
+ Creates a LoadedModules context for individual module development.
14
+
15
+ This allows using `getModulesReference` in a module's own `tailor.config.ts`,
16
+ enabling the kysely-type generator to work during module development.
17
+
18
+ Dependencies declared in the module's `defineModule` are automatically
19
+ registered with default (empty) configurations.
20
+
21
+ ## Type Parameters
22
+
23
+ | Type Parameter |
24
+ | ------ |
25
+ | `C` *extends* `Record`\<`string`, `unknown`\> |
26
+ | `Tables` *extends* `Record`\<`string`, `unknown`\> |
27
+ | `Deps` *extends* [`DependencyModules`](../../../builder/type-aliases/DependencyModules.md) |
28
+
29
+ ## Parameters
30
+
31
+ | Parameter | Type | Description |
32
+ | ------ | ------ | ------ |
33
+ | `module` | [`DefinedModule`](../../../builder/type-aliases/DefinedModule.md)\<`C`, `Tables`, `Deps`\> | The module being developed |
34
+ | `config?` | `C` | Optional development configuration. If omitted, uses module.devConfig. |
35
+
36
+ ## Returns
37
+
38
+ [`LoadedModules`](../../type-aliases/LoadedModules.md)
39
+
40
+ A LoadedModules object that can be passed to getModulesReference
41
+
42
+ ## Example
43
+
44
+ ```typescript
45
+ // tailor.config.ts
46
+ import { loadModuleForDev, getModulesReference } from "@izumisy-tailor/omakase-modules/config/sdk";
47
+ import inventoryModule from "./src/module";
48
+
49
+ const modules = loadModuleForDev(inventoryModule);
50
+ const moduleReference = await getModulesReference(modules);
51
+
52
+ export default defineConfig({ ... });
53
+ ```
@@ -0,0 +1,60 @@
1
+ [**@izumisy-tailor/omakase-modules**](../../../README.md)
2
+
3
+ ***
4
+
5
+ [@izumisy-tailor/omakase-modules](../../../modules.md) / [config/sdk](../README.md) / GetModulesReferenceOptions
6
+
7
+ # Type Alias: GetModulesReferenceOptions
8
+
9
+ > **GetModulesReferenceOptions** = `object`
10
+
11
+ Defined in: [config/sdk/paths.ts:16](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/config/sdk/paths.ts#L16)
12
+
13
+ Options for configuring [getModulesReference](../functions/getModulesReference.md) behavior.
14
+
15
+ ## Example
16
+
17
+ ```typescript
18
+ const moduleReference = await getModulesReference(modules, {
19
+ basePath: "/custom/path",
20
+ silent: true, // Suppress console output
21
+ });
22
+ ```
23
+
24
+ ## Properties
25
+
26
+ ### basePath?
27
+
28
+ > `optional` **basePath**: `string`
29
+
30
+ Defined in: [config/sdk/paths.ts:25](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/config/sdk/paths.ts#L25)
31
+
32
+ Base path for the application.
33
+
34
+ This determines where wrapper files are generated and where module
35
+ paths are resolved from. Defaults to `process.cwd()`.
36
+
37
+ #### Default
38
+
39
+ ```ts
40
+ process.cwd()
41
+ ```
42
+
43
+ ***
44
+
45
+ ### silent?
46
+
47
+ > `optional` **silent**: `boolean`
48
+
49
+ Defined in: [config/sdk/paths.ts:34](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/config/sdk/paths.ts#L34)
50
+
51
+ Whether to suppress log output.
52
+
53
+ When `true`, no console output will be printed during module loading.
54
+ Useful for testing or when you want cleaner build output.
55
+
56
+ #### Default
57
+
58
+ ```ts
59
+ false
60
+ ```
@@ -0,0 +1,162 @@
1
+ [**@izumisy-tailor/omakase-modules**](../../README.md)
2
+
3
+ ***
4
+
5
+ [@izumisy-tailor/omakase-modules](../../modules.md) / [config](../README.md) / LoadedModules
6
+
7
+ # Type Alias: LoadedModules
8
+
9
+ > **LoadedModules** = `object`
10
+
11
+ Defined in: [config/module-loader.ts:135](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/config/module-loader.ts#L135)
12
+
13
+ The result of loading modules, providing access to module configurations and tables.
14
+
15
+ This type is returned by [loadModules](../functions/loadModules.md) and passed to module factory functions.
16
+ It provides utilities for:
17
+ - Accessing configured module instances
18
+ - Loading module configurations
19
+ - Retrieving tables from dependency modules
20
+
21
+ ## Example
22
+
23
+ ```typescript
24
+ // In tailor.config.ts - using getModulesReference with LoadedModules
25
+ import { getModulesReference } from "@izumisy-tailor/omakase-modules/config/sdk";
26
+ import modules from "./modules";
27
+
28
+ const moduleReference = await getModulesReference(modules);
29
+
30
+ export default defineConfig({
31
+ db: {
32
+ "main-db": {
33
+ files: ["./src/tailordb/*.ts", ...moduleReference.tailordb],
34
+ },
35
+ },
36
+ // ...
37
+ });
38
+ ```
39
+
40
+ ## Properties
41
+
42
+ ### getTables()
43
+
44
+ > **getTables**: \<`T`\>(`factory`) => `Promise`\<`T`\>
45
+
46
+ Defined in: [config/module-loader.ts:204](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/config/module-loader.ts#L204)
47
+
48
+ Get the tables from a dependency module by calling its factory function.
49
+
50
+ Use this when a module needs to reference tables from another module,
51
+ such as creating foreign key relationships or using shared types.
52
+
53
+ #### Type Parameters
54
+
55
+ | Type Parameter |
56
+ | ------ |
57
+ | `T` |
58
+
59
+ #### Parameters
60
+
61
+ | Parameter | Type | Description |
62
+ | ------ | ------ | ------ |
63
+ | `factory` | (`loadedModules`) => `Promise`\<`T`\> | The factory function exported by the dependency module's `tailordb/index.ts` |
64
+
65
+ #### Returns
66
+
67
+ `Promise`\<`T`\>
68
+
69
+ A promise resolving to the tables created by the factory
70
+
71
+ #### Example
72
+
73
+ ```typescript
74
+ // In inventory-module's tailordb/index.ts
75
+ import commerceModuleTables from "omakase-module-commerce-core/backend/tailordb";
76
+ import orderModuleTables from "omakase-module-order/backend/tailordb";
77
+
78
+ export default withModuleConfiguration(
79
+ moduleDef,
80
+ async (context, loadedModules) => {
81
+ // Get tables from commerce module to reference product/productVariant
82
+ const { product, productVariant } = await loadedModules.getTables(
83
+ commerceModuleTables
84
+ );
85
+
86
+ // Get tables from order module to reference order
87
+ const { order } = await loadedModules.getTables(orderModuleTables);
88
+
89
+ // Use dependency tables when building this module's tables
90
+ const inventory = buildInventoryTable(context, { product, productVariant });
91
+ const inventoryTransaction = buildInventoryTransactionTable(context, {
92
+ inventory,
93
+ order,
94
+ });
95
+
96
+ return { inventory, inventoryTransaction };
97
+ }
98
+ );
99
+ ```
100
+
101
+ ***
102
+
103
+ ### loadConfig()
104
+
105
+ > **loadConfig**: \<`C`\>(`module`) => `object`
106
+
107
+ Defined in: [config/module-loader.ts:161](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/config/module-loader.ts#L161)
108
+
109
+ Load the configuration for a specific module.
110
+
111
+ Use this in module factory functions to access the user-provided configuration.
112
+ Throws an error if the module has not been registered via `loadModules`.
113
+
114
+ #### Type Parameters
115
+
116
+ | Type Parameter |
117
+ | ------ |
118
+ | `C` *extends* `Record`\<`string`, `unknown`\> |
119
+
120
+ #### Parameters
121
+
122
+ | Parameter | Type | Description |
123
+ | ------ | ------ | ------ |
124
+ | `module` | \{ `packageName`: `string`; \} | An object with `packageName` (typically the module definition) |
125
+ | `module.packageName` | `string` | - |
126
+
127
+ #### Returns
128
+
129
+ `object`
130
+
131
+ An object containing the module's configuration
132
+
133
+ ##### config
134
+
135
+ > **config**: `C`
136
+
137
+ #### Throws
138
+
139
+ Error if the module has not been configured
140
+
141
+ #### Example
142
+
143
+ ```typescript
144
+ // In a module's tailordb/index.ts
145
+ import moduleDef from "../module";
146
+
147
+ export default withModuleConfiguration(moduleDef, (context, loadedModules) => {
148
+ // Access this module's configuration
149
+ const { config } = loadedModules.loadConfig<ModuleConfig>(moduleDef);
150
+ const prefix = config.dataModel?.product?.docNumberPrefix ?? "PROD";
151
+
152
+ return { product: buildProductTable(context) };
153
+ });
154
+ ```
155
+
156
+ ***
157
+
158
+ ### loadedModules
159
+
160
+ > **loadedModules**: `Record`\<`string`, [`ConfiguredModule`](../../builder/type-aliases/ConfiguredModule.md)\<`any`\>\>
161
+
162
+ Defined in: [config/module-loader.ts:136](https://github.com/tailor-sandbox/omakase-modules/blob/c8d6563533665d8bb159b4602b5c906b40e938f2/packages/core/src/config/module-loader.ts#L136)
@@ -0,0 +1,11 @@
1
+ [**@izumisy-tailor/omakase-modules**](README.md)
2
+
3
+ ***
4
+
5
+ # @izumisy-tailor/omakase-modules
6
+
7
+ ## Modules
8
+
9
+ - [builder](builder/README.md)
10
+ - [config](config/README.md)
11
+ - [config/sdk](config/sdk/README.md)
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@izumisy-tailor/omakase-modules",
3
3
  "private": false,
4
- "version": "0.3.0",
4
+ "version": "0.4.1",
5
5
  "description": "Modularization mechanism for Tailor Platform application powered by Tailor SDK",
6
6
  "type": "module",
7
7
  "files": [
8
- "src",
9
- "docs"
8
+ "docs/generated",
9
+ "src"
10
10
  ],
11
11
  "exports": {
12
12
  ".": "./src/config/index.ts",
@@ -22,18 +22,22 @@
22
22
  "author": "Tailor Inc.",
23
23
  "license": "MIT",
24
24
  "devDependencies": {
25
- "@types/node": "^25.0.3",
25
+ "@types/node": "^25.0.8",
26
+ "typedoc": "^0.28.16",
27
+ "typedoc-plugin-markdown": "^4.9.0",
26
28
  "typescript": "^5",
27
- "vitest": "^4.0.16"
29
+ "vite-tsconfig-paths": "^6.0.4",
30
+ "vitest": "^4.0.17"
28
31
  },
29
32
  "peerDependencies": {
30
- "@tailor-platform/sdk": "^0.20.0"
33
+ "@tailor-platform/sdk": "^1.2.6"
31
34
  },
32
35
  "dependencies": {
33
36
  "dedent": "^1.7.1"
34
37
  },
35
38
  "scripts": {
36
39
  "type-check": "tsc",
37
- "test": "vitest run"
40
+ "test": "vitest run",
41
+ "docsgen": "typedoc"
38
42
  }
39
43
  }