@voyantjs/core 0.1.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/LICENSE +109 -0
- package/README.md +41 -0
- package/dist/config.d.ts +151 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +168 -0
- package/dist/config.js.map +1 -0
- package/dist/container.d.ts +20 -0
- package/dist/container.d.ts.map +1 -0
- package/dist/container.js +21 -0
- package/dist/container.js.map +1 -0
- package/dist/env.d.ts +28 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +2 -0
- package/dist/env.js.map +1 -0
- package/dist/events.d.ts +39 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +42 -0
- package/dist/events.js.map +1 -0
- package/dist/hooks.d.ts +19 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +33 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/links.d.ts +169 -0
- package/dist/links.d.ts.map +1 -0
- package/dist/links.js +146 -0
- package/dist/links.js.map +1 -0
- package/dist/module.d.ts +36 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +2 -0
- package/dist/module.js.map +1 -0
- package/dist/orchestration.d.ts +33 -0
- package/dist/orchestration.d.ts.map +1 -0
- package/dist/orchestration.js +2 -0
- package/dist/orchestration.js.map +1 -0
- package/dist/plugin.d.ts +89 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +57 -0
- package/dist/plugin.js.map +1 -0
- package/dist/query.d.ts +91 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/query.js +120 -0
- package/dist/query.js.map +1 -0
- package/dist/registry.d.ts +17 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +31 -0
- package/dist/registry.js.map +1 -0
- package/dist/workflows.d.ts +118 -0
- package/dist/workflows.d.ts.map +1 -0
- package/dist/workflows.js +122 -0
- package/dist/workflows.js.map +1 -0
- package/package.json +80 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Functional Source License, Version 1.1, Apache 2.0 Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 PixelMakers Studio SRL
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly
|
|
28
|
+
display and redistribute the Software for any Permitted Purpose identified
|
|
29
|
+
below.
|
|
30
|
+
|
|
31
|
+
### Permitted Purpose
|
|
32
|
+
|
|
33
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing
|
|
34
|
+
Use means making the Software available to others in a commercial product or
|
|
35
|
+
service that:
|
|
36
|
+
|
|
37
|
+
1. substitutes for the Software;
|
|
38
|
+
|
|
39
|
+
2. substitutes for any other product or service we offer using the Software
|
|
40
|
+
that exists as of the date we make the Software available; or
|
|
41
|
+
|
|
42
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
43
|
+
|
|
44
|
+
Permitted Purposes specifically include using the Software:
|
|
45
|
+
|
|
46
|
+
1. for your internal use and access;
|
|
47
|
+
|
|
48
|
+
2. for non-commercial education;
|
|
49
|
+
|
|
50
|
+
3. for non-commercial research; and
|
|
51
|
+
|
|
52
|
+
4. in connection with professional services that you provide to a licensee
|
|
53
|
+
using the Software in accordance with these Terms and Conditions.
|
|
54
|
+
|
|
55
|
+
### Patents
|
|
56
|
+
|
|
57
|
+
To the extent your use for a Permitted Purpose would necessarily infringe
|
|
58
|
+
our patents, the license grant above includes a license under our patents.
|
|
59
|
+
If you make a claim against any party that the Software infringes or
|
|
60
|
+
contributes to the infringement of any patent, then your patent license to
|
|
61
|
+
the Software ends immediately.
|
|
62
|
+
|
|
63
|
+
### Redistribution
|
|
64
|
+
|
|
65
|
+
The Terms and Conditions apply to all copies, modifications and derivatives
|
|
66
|
+
of the Software.
|
|
67
|
+
|
|
68
|
+
If you redistribute any copies, modifications or derivatives of the
|
|
69
|
+
Software, you must include a copy of or a link to these Terms and Conditions
|
|
70
|
+
and not remove any copyright notices provided in or with the Software.
|
|
71
|
+
|
|
72
|
+
### Disclaimer
|
|
73
|
+
|
|
74
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS
|
|
75
|
+
OR IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A
|
|
76
|
+
PARTICULAR PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
77
|
+
|
|
78
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO
|
|
79
|
+
THE SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
|
|
80
|
+
DAMAGES, EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
81
|
+
|
|
82
|
+
### Trademarks
|
|
83
|
+
|
|
84
|
+
Except for displaying the License Details and identifying us as the origin
|
|
85
|
+
of the Software, you have no right under these Terms and Conditions to use
|
|
86
|
+
our trademarks, trade names, service marks or product names.
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Grant of Future License
|
|
91
|
+
|
|
92
|
+
We hereby irrevocably grant you an additional license to use the Software
|
|
93
|
+
under the Apache License, Version 2.0 that is effective on the second
|
|
94
|
+
anniversary of the date we make the Software available. On or after that
|
|
95
|
+
date, you may use the Software under the Apache License, Version 2.0, in
|
|
96
|
+
which case the following will apply:
|
|
97
|
+
|
|
98
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
99
|
+
use this file except in compliance with the License.
|
|
100
|
+
|
|
101
|
+
You may obtain a copy of the License at
|
|
102
|
+
|
|
103
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
104
|
+
|
|
105
|
+
Unless required by applicable law or agreed to in writing, software
|
|
106
|
+
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
107
|
+
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
108
|
+
License for the specific language governing permissions and limitations
|
|
109
|
+
under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @voyantjs/core
|
|
2
|
+
|
|
3
|
+
Module system and framework primitives for Voyant. Transport-agnostic — provides the contracts, registry, container, event bus, links, query, workflows, plugins, and config shape that every Voyant module and transport adapter builds on.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @voyantjs/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { defineModule } from "@voyantjs/core/module"
|
|
15
|
+
import { defineLink } from "@voyantjs/core/links"
|
|
16
|
+
import { definePlugin } from "@voyantjs/core/plugin"
|
|
17
|
+
import { defineVoyantConfig } from "@voyantjs/core/config"
|
|
18
|
+
import { createWorkflow, step } from "@voyantjs/core/workflows"
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Exports
|
|
22
|
+
|
|
23
|
+
| Entry | Description |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| `.` | Barrel re-exports |
|
|
26
|
+
| `./module` | `Module`, `defineModule` |
|
|
27
|
+
| `./registry` | Module registry |
|
|
28
|
+
| `./container` | `createContainer` dependency container |
|
|
29
|
+
| `./events` | `createEventBus` in-process event bus |
|
|
30
|
+
| `./hooks` | Lifecycle hook contracts |
|
|
31
|
+
| `./orchestration` | `JobRunner` interface for background jobs |
|
|
32
|
+
| `./links` | Module Links — `defineLink`, `generateLinkTableSql`, `LinkService` |
|
|
33
|
+
| `./query` | Cross-module reads — `queryGraph`, `createQueryContext` |
|
|
34
|
+
| `./workflows` | In-process saga primitive with compensation |
|
|
35
|
+
| `./plugin` | Plugin bundles — `definePlugin`, `registerPlugins` |
|
|
36
|
+
| `./config` | `VoyantConfig` manifest shape + `defineVoyantConfig` |
|
|
37
|
+
| `./env` | Environment helpers |
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
FSL-1.1-Apache-2.0
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Voyant configuration manifest.
|
|
3
|
+
*
|
|
4
|
+
* `voyant.config.ts` is a **manifest**, not a runtime config — it exists to
|
|
5
|
+
* power tooling (CLI generators, registry resolution, `voyant db:sync-links`,
|
|
6
|
+
* deployment scripts). Runtime composition of modules, plugins, and
|
|
7
|
+
* middleware still happens in code via `createApp({ modules, plugins, ... })`.
|
|
8
|
+
*
|
|
9
|
+
* Shape mirrors Medusa's `defineConfig` so users familiar with that
|
|
10
|
+
* ecosystem can transfer their mental model directly.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Core runtime settings declared for tooling purposes (connection strings,
|
|
14
|
+
* cache backend, auth provider). All fields are optional because runtime
|
|
15
|
+
* wiring lives in template code and environment bindings.
|
|
16
|
+
*/
|
|
17
|
+
export interface ProjectConfig {
|
|
18
|
+
/** Database connection descriptor. */
|
|
19
|
+
database?: {
|
|
20
|
+
/** Environment variable name that holds the connection URL. */
|
|
21
|
+
urlEnv?: string;
|
|
22
|
+
/** Adapter to use at runtime. */
|
|
23
|
+
adapter?: "edge" | "node";
|
|
24
|
+
};
|
|
25
|
+
/** Cache backend descriptor. */
|
|
26
|
+
cache?: {
|
|
27
|
+
/** Provider name (e.g. "kv", "redis", "memory"). */
|
|
28
|
+
provider?: string;
|
|
29
|
+
/** Cloudflare binding name (when using `kv`). */
|
|
30
|
+
binding?: string;
|
|
31
|
+
};
|
|
32
|
+
/** Auth provider descriptor. */
|
|
33
|
+
auth?: {
|
|
34
|
+
/** Provider identifier (e.g. "better-auth"). */
|
|
35
|
+
provider?: string;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Admin-dashboard manifest entry. Mirrors Medusa's admin section.
|
|
40
|
+
*/
|
|
41
|
+
export interface AdminConfig {
|
|
42
|
+
/** Whether the admin dashboard is enabled for this project. */
|
|
43
|
+
enabled?: boolean;
|
|
44
|
+
/** URL path the dashboard is mounted at (e.g. "/app"). */
|
|
45
|
+
path?: string;
|
|
46
|
+
/** Optional URL the admin dashboard should call back to. */
|
|
47
|
+
backendUrl?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A module declaration — either a string identifier (referencing a package
|
|
51
|
+
* or workspace-local module) or an inline descriptor with options.
|
|
52
|
+
*/
|
|
53
|
+
export type ModuleEntry = string | {
|
|
54
|
+
/** Module identifier (package name or workspace path). */
|
|
55
|
+
resolve: string;
|
|
56
|
+
/** Arbitrary module options consumed by the module factory. */
|
|
57
|
+
options?: Record<string, unknown>;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* A plugin declaration — mirrors {@link ModuleEntry} but references
|
|
61
|
+
* distributable plugin bundles (see `@voyantjs/core/plugin`).
|
|
62
|
+
*/
|
|
63
|
+
export type PluginEntry = string | {
|
|
64
|
+
/** Plugin identifier (package name). */
|
|
65
|
+
resolve: string;
|
|
66
|
+
/** Arbitrary plugin options. */
|
|
67
|
+
options?: Record<string, unknown>;
|
|
68
|
+
};
|
|
69
|
+
/** Supported deployment targets (informational — used by CLI/tooling). */
|
|
70
|
+
export type DeploymentTarget = "cloudflare-worker" | "node" | "vercel" | "bun" | (string & {});
|
|
71
|
+
/**
|
|
72
|
+
* The top-level voyant.config.ts manifest.
|
|
73
|
+
*
|
|
74
|
+
* @see {@link defineVoyantConfig}
|
|
75
|
+
*/
|
|
76
|
+
export interface VoyantConfig {
|
|
77
|
+
/** Core runtime settings (database, cache, auth). */
|
|
78
|
+
projectConfig?: ProjectConfig;
|
|
79
|
+
/** Admin dashboard configuration. */
|
|
80
|
+
admin?: AdminConfig;
|
|
81
|
+
/** Modules composed into the application. */
|
|
82
|
+
modules?: ModuleEntry[];
|
|
83
|
+
/** Plugins registered alongside core modules. */
|
|
84
|
+
plugins?: PluginEntry[];
|
|
85
|
+
/** Feature flags for gradual rollout. */
|
|
86
|
+
featureFlags?: Record<string, boolean>;
|
|
87
|
+
/** Deployment target hint consumed by tooling. */
|
|
88
|
+
deployment?: DeploymentTarget;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Identity helper that returns the config as-is.
|
|
92
|
+
*
|
|
93
|
+
* Exists purely so authors can write `defineVoyantConfig({ ... })` and get
|
|
94
|
+
* type inference + IDE help without casting. Does not perform runtime
|
|
95
|
+
* validation — malformed manifests will surface at CLI/tooling consumption
|
|
96
|
+
* time via {@link validateVoyantConfig}.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* // templates/dmc/voyant.config.ts
|
|
101
|
+
* import { defineVoyantConfig } from "@voyantjs/core/config"
|
|
102
|
+
*
|
|
103
|
+
* export default defineVoyantConfig({
|
|
104
|
+
* modules: ["crm", "bookings", "products", "finance", "suppliers"],
|
|
105
|
+
* plugins: ["payload-cms", "bokun"],
|
|
106
|
+
* deployment: "cloudflare-worker",
|
|
107
|
+
* admin: { enabled: true, path: "/app" },
|
|
108
|
+
* })
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export declare function defineVoyantConfig<C extends VoyantConfig>(config: C): C;
|
|
112
|
+
/**
|
|
113
|
+
* A single validation issue detected in a {@link VoyantConfig} manifest.
|
|
114
|
+
*/
|
|
115
|
+
export interface ConfigValidationIssue {
|
|
116
|
+
/** Dotted path to the offending field (e.g. `modules[0].resolve`). */
|
|
117
|
+
path: string;
|
|
118
|
+
/** Human-readable description. */
|
|
119
|
+
message: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Result returned by {@link validateVoyantConfig}.
|
|
123
|
+
*/
|
|
124
|
+
export interface ConfigValidationResult {
|
|
125
|
+
/** True when no issues were detected. */
|
|
126
|
+
ok: boolean;
|
|
127
|
+
/** List of validation issues (empty when `ok` is true). */
|
|
128
|
+
issues: ConfigValidationIssue[];
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Lightweight structural validation for a {@link VoyantConfig} manifest.
|
|
132
|
+
*
|
|
133
|
+
* Checks only shape/identity: field types, non-empty identifiers, no
|
|
134
|
+
* duplicate module/plugin names. It does **not** resolve package names or
|
|
135
|
+
* check that referenced modules exist on disk — that is CLI/tooling
|
|
136
|
+
* territory.
|
|
137
|
+
*
|
|
138
|
+
* Returns a result object rather than throwing so callers can choose how
|
|
139
|
+
* to surface issues (pretty printing, aggregating, etc.).
|
|
140
|
+
*/
|
|
141
|
+
export declare function validateVoyantConfig(config: unknown): ConfigValidationResult;
|
|
142
|
+
/**
|
|
143
|
+
* Normalize a {@link ModuleEntry} or {@link PluginEntry} into the canonical
|
|
144
|
+
* `{ resolve, options }` object shape. Accepts string shorthand and inline
|
|
145
|
+
* descriptors alike.
|
|
146
|
+
*/
|
|
147
|
+
export declare function resolveEntry<E extends ModuleEntry | PluginEntry>(entry: E): {
|
|
148
|
+
resolve: string;
|
|
149
|
+
options: Record<string, unknown>;
|
|
150
|
+
};
|
|
151
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@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
|
3
|
+
*
|
|
4
|
+
* `voyant.config.ts` is a **manifest**, not a runtime config — it exists to
|
|
5
|
+
* power tooling (CLI generators, registry resolution, `voyant db:sync-links`,
|
|
6
|
+
* deployment scripts). Runtime composition of modules, plugins, and
|
|
7
|
+
* middleware still happens in code via `createApp({ modules, plugins, ... })`.
|
|
8
|
+
*
|
|
9
|
+
* Shape mirrors Medusa's `defineConfig` so users familiar with that
|
|
10
|
+
* ecosystem can transfer their mental model directly.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Identity helper that returns the config as-is.
|
|
14
|
+
*
|
|
15
|
+
* Exists purely so authors can write `defineVoyantConfig({ ... })` and get
|
|
16
|
+
* type inference + IDE help without casting. Does not perform runtime
|
|
17
|
+
* validation — malformed manifests will surface at CLI/tooling consumption
|
|
18
|
+
* time via {@link validateVoyantConfig}.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* // templates/dmc/voyant.config.ts
|
|
23
|
+
* import { defineVoyantConfig } from "@voyantjs/core/config"
|
|
24
|
+
*
|
|
25
|
+
* export default defineVoyantConfig({
|
|
26
|
+
* modules: ["crm", "bookings", "products", "finance", "suppliers"],
|
|
27
|
+
* plugins: ["payload-cms", "bokun"],
|
|
28
|
+
* deployment: "cloudflare-worker",
|
|
29
|
+
* admin: { enabled: true, path: "/app" },
|
|
30
|
+
* })
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export function defineVoyantConfig(config) {
|
|
34
|
+
return config;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Lightweight structural validation for a {@link VoyantConfig} manifest.
|
|
38
|
+
*
|
|
39
|
+
* Checks only shape/identity: field types, non-empty identifiers, no
|
|
40
|
+
* duplicate module/plugin names. It does **not** resolve package names or
|
|
41
|
+
* check that referenced modules exist on disk — that is CLI/tooling
|
|
42
|
+
* territory.
|
|
43
|
+
*
|
|
44
|
+
* Returns a result object rather than throwing so callers can choose how
|
|
45
|
+
* to surface issues (pretty printing, aggregating, etc.).
|
|
46
|
+
*/
|
|
47
|
+
export function validateVoyantConfig(config) {
|
|
48
|
+
const issues = [];
|
|
49
|
+
if (config === null || typeof config !== "object") {
|
|
50
|
+
return {
|
|
51
|
+
ok: false,
|
|
52
|
+
issues: [{ path: "", message: "Config must be an object." }],
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const cfg = config;
|
|
56
|
+
if (cfg.modules !== undefined) {
|
|
57
|
+
if (!Array.isArray(cfg.modules)) {
|
|
58
|
+
issues.push({ path: "modules", message: "Expected an array." });
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
const seen = new Set();
|
|
62
|
+
cfg.modules.forEach((entry, index) => {
|
|
63
|
+
const name = extractEntryName(entry);
|
|
64
|
+
if (!name) {
|
|
65
|
+
issues.push({
|
|
66
|
+
path: `modules[${index}]`,
|
|
67
|
+
message: "Module entry must be a non-empty string or an object with a `resolve` string.",
|
|
68
|
+
});
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (seen.has(name)) {
|
|
72
|
+
issues.push({
|
|
73
|
+
path: `modules[${index}]`,
|
|
74
|
+
message: `Duplicate module "${name}".`,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
seen.add(name);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (cfg.plugins !== undefined) {
|
|
82
|
+
if (!Array.isArray(cfg.plugins)) {
|
|
83
|
+
issues.push({ path: "plugins", message: "Expected an array." });
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
const seen = new Set();
|
|
87
|
+
cfg.plugins.forEach((entry, index) => {
|
|
88
|
+
const name = extractEntryName(entry);
|
|
89
|
+
if (!name) {
|
|
90
|
+
issues.push({
|
|
91
|
+
path: `plugins[${index}]`,
|
|
92
|
+
message: "Plugin entry must be a non-empty string or an object with a `resolve` string.",
|
|
93
|
+
});
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (seen.has(name)) {
|
|
97
|
+
issues.push({
|
|
98
|
+
path: `plugins[${index}]`,
|
|
99
|
+
message: `Duplicate plugin "${name}".`,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
seen.add(name);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (cfg.admin !== undefined) {
|
|
107
|
+
if (cfg.admin === null || typeof cfg.admin !== "object" || Array.isArray(cfg.admin)) {
|
|
108
|
+
issues.push({ path: "admin", message: "Expected an object." });
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
const admin = cfg.admin;
|
|
112
|
+
if (admin.enabled !== undefined && typeof admin.enabled !== "boolean") {
|
|
113
|
+
issues.push({ path: "admin.enabled", message: "Expected a boolean." });
|
|
114
|
+
}
|
|
115
|
+
if (admin.path !== undefined && typeof admin.path !== "string") {
|
|
116
|
+
issues.push({ path: "admin.path", message: "Expected a string." });
|
|
117
|
+
}
|
|
118
|
+
if (admin.backendUrl !== undefined && typeof admin.backendUrl !== "string") {
|
|
119
|
+
issues.push({ path: "admin.backendUrl", message: "Expected a string." });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (cfg.featureFlags !== undefined) {
|
|
124
|
+
if (cfg.featureFlags === null ||
|
|
125
|
+
typeof cfg.featureFlags !== "object" ||
|
|
126
|
+
Array.isArray(cfg.featureFlags)) {
|
|
127
|
+
issues.push({ path: "featureFlags", message: "Expected an object of booleans." });
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
for (const [key, value] of Object.entries(cfg.featureFlags)) {
|
|
131
|
+
if (typeof value !== "boolean") {
|
|
132
|
+
issues.push({
|
|
133
|
+
path: `featureFlags.${key}`,
|
|
134
|
+
message: "Expected a boolean.",
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (cfg.deployment !== undefined && typeof cfg.deployment !== "string") {
|
|
141
|
+
issues.push({ path: "deployment", message: "Expected a string." });
|
|
142
|
+
}
|
|
143
|
+
return { ok: issues.length === 0, issues };
|
|
144
|
+
}
|
|
145
|
+
function extractEntryName(entry) {
|
|
146
|
+
if (typeof entry === "string") {
|
|
147
|
+
return entry.trim().length > 0 ? entry : null;
|
|
148
|
+
}
|
|
149
|
+
if (entry !== null && typeof entry === "object" && "resolve" in entry) {
|
|
150
|
+
const resolve = entry.resolve;
|
|
151
|
+
if (typeof resolve === "string" && resolve.trim().length > 0) {
|
|
152
|
+
return resolve;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Normalize a {@link ModuleEntry} or {@link PluginEntry} into the canonical
|
|
159
|
+
* `{ resolve, options }` object shape. Accepts string shorthand and inline
|
|
160
|
+
* descriptors alike.
|
|
161
|
+
*/
|
|
162
|
+
export function resolveEntry(entry) {
|
|
163
|
+
if (typeof entry === "string") {
|
|
164
|
+
return { resolve: entry, options: {} };
|
|
165
|
+
}
|
|
166
|
+
return { resolve: entry.resolve, options: entry.options ?? {} };
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA0FH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,kBAAkB,CAAyB,MAAS;IAClE,OAAO,MAAM,CAAA;AACf,CAAC;AAsBD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAe;IAClD,MAAM,MAAM,GAA4B,EAAE,CAAA;IAE1C,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAClD,OAAO;YACL,EAAE,EAAE,KAAK;YACT,MAAM,EAAE,CAAC,EAAE,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AAQ,EAAE,CAAC;QACvE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC,CAAA;IACpE,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;AAC5C,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAc;IACtC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;IAC/C,CAAC;IACD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,SAAS,IAAI,KAAK,EAAE,CAAC;QACtE,MAAM,OAAO,GAAI,KAA8B,CAAC,OAAO,CAAA;QACvD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7D,OAAO,OAAO,CAAA;QAChB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAQ;IAER,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAA;IACxC,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,EAAE,EAAE,CAAA;AACjE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A lightweight module container providing per-request service resolution.
|
|
3
|
+
*
|
|
4
|
+
* Modules register services at app boot; routes resolve them per request.
|
|
5
|
+
* The container is intentionally minimal (Map-based) — for richer DI
|
|
6
|
+
* (scoping, factory lifetimes) a template can wrap or replace it.
|
|
7
|
+
*/
|
|
8
|
+
export interface ModuleContainer {
|
|
9
|
+
/** Register a service by name. Overwrites any existing registration. */
|
|
10
|
+
register(name: string, service: unknown): void;
|
|
11
|
+
/** Resolve a service by name. Throws if not registered. */
|
|
12
|
+
resolve<T>(name: string): T;
|
|
13
|
+
/** Check if a service is registered. */
|
|
14
|
+
has(name: string): boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Create a new module container backed by an in-memory Map.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createContainer(): ModuleContainer;
|
|
20
|
+
//# sourceMappingURL=container.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../src/container.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;IAE9C,2DAA2D;IAC3D,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAAA;IAE3B,wCAAwC;IACxC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;CAC3B;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,eAAe,CAiBjD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a new module container backed by an in-memory Map.
|
|
3
|
+
*/
|
|
4
|
+
export function createContainer() {
|
|
5
|
+
const services = new Map();
|
|
6
|
+
return {
|
|
7
|
+
register(name, service) {
|
|
8
|
+
services.set(name, service);
|
|
9
|
+
},
|
|
10
|
+
resolve(name) {
|
|
11
|
+
if (!services.has(name)) {
|
|
12
|
+
throw new Error(`Service "${name}" is not registered in the container`);
|
|
13
|
+
}
|
|
14
|
+
return services.get(name);
|
|
15
|
+
},
|
|
16
|
+
has(name) {
|
|
17
|
+
return services.has(name);
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=container.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container.js","sourceRoot":"","sources":["../src/container.ts"],"names":[],"mappings":"AAkBA;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAmB,CAAA;IAE3C,OAAO;QACL,QAAQ,CAAC,IAAI,EAAE,OAAO;YACpB,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QAC7B,CAAC;QACD,OAAO,CAAI,IAAY;YACrB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,YAAY,IAAI,sCAAsC,CAAC,CAAA;YACzE,CAAC;YACD,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAM,CAAA;QAChC,CAAC;QACD,GAAG,CAAC,IAAI;YACN,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAC3B,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/dist/env.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type VoyantCallerType = "session" | "api_key" | "internal";
|
|
2
|
+
/**
|
|
3
|
+
* Who the request represents. Routes under `/v1/admin/*` expect `"staff"`;
|
|
4
|
+
* `/v1/public/*` expects customer/partner/supplier actors.
|
|
5
|
+
*
|
|
6
|
+
* When unset, middleware treats the request as `"staff"` to preserve
|
|
7
|
+
* backwards compatibility with internal-only deployments.
|
|
8
|
+
*/
|
|
9
|
+
export type Actor = "staff" | "customer" | "partner" | "supplier";
|
|
10
|
+
export interface VoyantAuthContext {
|
|
11
|
+
userId?: string;
|
|
12
|
+
sessionId?: string;
|
|
13
|
+
organizationId?: string | null;
|
|
14
|
+
callerType?: VoyantCallerType;
|
|
15
|
+
actor?: Actor;
|
|
16
|
+
scopes?: string[] | null;
|
|
17
|
+
isInternalRequest?: boolean;
|
|
18
|
+
apiKeyId?: string;
|
|
19
|
+
email?: string | null;
|
|
20
|
+
}
|
|
21
|
+
export interface VoyantPermission {
|
|
22
|
+
resource: string;
|
|
23
|
+
action: string;
|
|
24
|
+
}
|
|
25
|
+
export type VoyantVariables = VoyantAuthContext & {
|
|
26
|
+
db: unknown;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,CAAA;AAEjE;;;;;;GAMG;AACH,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,CAAA;AAEjE,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,UAAU,CAAC,EAAE,gBAAgB,CAAA;IAC7B,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IACxB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,eAAe,GAAG,iBAAiB,GAAG;IAChD,EAAE,EAAE,OAAO,CAAA;CACZ,CAAA"}
|
package/dist/env.js
ADDED
package/dist/env.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":""}
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event handler callback invoked when a subscribed event is emitted.
|
|
3
|
+
*/
|
|
4
|
+
export type EventHandler<TData = unknown> = (data: TData) => Promise<void> | void;
|
|
5
|
+
/**
|
|
6
|
+
* Subscription handle returned from {@link EventBus.subscribe}.
|
|
7
|
+
*
|
|
8
|
+
* Call `unsubscribe()` to remove the handler.
|
|
9
|
+
*/
|
|
10
|
+
export interface Subscription {
|
|
11
|
+
unsubscribe(): void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Abstract event bus interface. Implementations live in templates or plugins.
|
|
15
|
+
*
|
|
16
|
+
* Adapter examples:
|
|
17
|
+
* - In-process (default, ships with core)
|
|
18
|
+
* - Hatchet — emit enqueues a durable task
|
|
19
|
+
* - Cloudflare Queues — edge-native
|
|
20
|
+
*
|
|
21
|
+
* Event naming convention: `<resource>.<pastTenseAction>` in dot-case.
|
|
22
|
+
* Examples: `booking.created`, `quote.accepted`, `payment.received`.
|
|
23
|
+
*/
|
|
24
|
+
export interface EventBus {
|
|
25
|
+
/** Emit an event. Fire-and-forget; subscribers cannot affect the emitter. */
|
|
26
|
+
emit(event: string, data: unknown): Promise<void>;
|
|
27
|
+
/** Subscribe to an event by name. Returns an unsubscribe handle. */
|
|
28
|
+
subscribe(event: string, handler: EventHandler): Subscription;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Create an in-process event bus.
|
|
32
|
+
*
|
|
33
|
+
* Handlers run sequentially in the order they were subscribed. Errors
|
|
34
|
+
* thrown by a handler are caught and logged but do not block subsequent
|
|
35
|
+
* handlers from running, matching the "subscribers are fire-and-forget"
|
|
36
|
+
* contract.
|
|
37
|
+
*/
|
|
38
|
+
export declare function createEventBus(): EventBus;
|
|
39
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,KAAK,GAAG,OAAO,IAAI,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;AAEjF;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,WAAW,IAAI,IAAI,CAAA;CACpB;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,QAAQ;IACvB,6EAA6E;IAC7E,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEjD,oEAAoE;IACpE,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,YAAY,CAAA;CAC9D;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,IAAI,QAAQ,CA+BzC"}
|
package/dist/events.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create an in-process event bus.
|
|
3
|
+
*
|
|
4
|
+
* Handlers run sequentially in the order they were subscribed. Errors
|
|
5
|
+
* thrown by a handler are caught and logged but do not block subsequent
|
|
6
|
+
* handlers from running, matching the "subscribers are fire-and-forget"
|
|
7
|
+
* contract.
|
|
8
|
+
*/
|
|
9
|
+
export function createEventBus() {
|
|
10
|
+
const handlers = new Map();
|
|
11
|
+
return {
|
|
12
|
+
async emit(event, data) {
|
|
13
|
+
const set = handlers.get(event);
|
|
14
|
+
if (!set)
|
|
15
|
+
return;
|
|
16
|
+
for (const handler of set) {
|
|
17
|
+
try {
|
|
18
|
+
await handler(data);
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
// Subscribers are fire-and-forget — log and continue.
|
|
22
|
+
// biome-ignore lint/suspicious/noConsole: runtime diagnostics
|
|
23
|
+
console.error(`[events] subscriber error for "${event}":`, err);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
subscribe(event, handler) {
|
|
28
|
+
let set = handlers.get(event);
|
|
29
|
+
if (!set) {
|
|
30
|
+
set = new Set();
|
|
31
|
+
handlers.set(event, set);
|
|
32
|
+
}
|
|
33
|
+
set.add(handler);
|
|
34
|
+
return {
|
|
35
|
+
unsubscribe() {
|
|
36
|
+
set?.delete(handler);
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAiCA;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA6B,CAAA;IAErD,OAAO;QACL,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI;YACpB,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;YAC/B,IAAI,CAAC,GAAG;gBAAE,OAAM;YAChB,KAAK,MAAM,OAAO,IAAI,GAAG,EAAE,CAAC;gBAC1B,IAAI,CAAC;oBACH,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;gBACrB,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,sDAAsD;oBACtD,8DAA8D;oBAC9D,OAAO,CAAC,KAAK,CAAC,kCAAkC,KAAK,IAAI,EAAE,GAAG,CAAC,CAAA;gBACjE,CAAC;YACH,CAAC;QACH,CAAC;QACD,SAAS,CAAC,KAAK,EAAE,OAAO;YACtB,IAAI,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;YAC7B,IAAI,CAAC,GAAG,EAAE,CAAC;gBACT,GAAG,GAAG,IAAI,GAAG,EAAE,CAAA;gBACf,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;YAC1B,CAAC;YACD,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YAChB,OAAO;gBACL,WAAW;oBACT,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;gBACtB,CAAC;aACF,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
|