@noego/stitch 1.0.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-schema.md +139 -0
- package/bin/stitch.js +156 -0
- package/dist/browser/index.d.ts +4 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/cli/StitchCLI.d.ts +12 -0
- package/dist/cli/StitchCLI.d.ts.map +1 -0
- package/dist/client.cjs +2 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.mjs +83 -0
- package/dist/client.mjs.map +1 -0
- package/dist/core/ConfigParser.d.ts +16 -0
- package/dist/core/ConfigParser.d.ts.map +1 -0
- package/dist/core/StitchEngine.d.ts +31 -0
- package/dist/core/StitchEngine.d.ts.map +1 -0
- package/dist/core/Validator.d.ts +18 -0
- package/dist/core/Validator.d.ts.map +1 -0
- package/dist/core/ViteHelper.d.ts +33 -0
- package/dist/core/ViteHelper.d.ts.map +1 -0
- package/dist/core/YamlMerger.d.ts +29 -0
- package/dist/core/YamlMerger.d.ts.map +1 -0
- package/dist/core/YamlMergerBrowser.d.ts +18 -0
- package/dist/core/YamlMergerBrowser.d.ts.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/types/StitchTypes.d.ts +38 -0
- package/dist/types/StitchTypes.d.ts.map +1 -0
- package/dist-ssr/browser/index.d.ts +4 -0
- package/dist-ssr/browser/index.d.ts.map +1 -0
- package/dist-ssr/cli/StitchCLI.d.ts +12 -0
- package/dist-ssr/cli/StitchCLI.d.ts.map +1 -0
- package/dist-ssr/core/ConfigParser.d.ts +16 -0
- package/dist-ssr/core/ConfigParser.d.ts.map +1 -0
- package/dist-ssr/core/StitchEngine.d.ts +31 -0
- package/dist-ssr/core/StitchEngine.d.ts.map +1 -0
- package/dist-ssr/core/Validator.d.ts +18 -0
- package/dist-ssr/core/Validator.d.ts.map +1 -0
- package/dist-ssr/core/ViteHelper.d.ts +33 -0
- package/dist-ssr/core/ViteHelper.d.ts.map +1 -0
- package/dist-ssr/core/YamlMerger.d.ts +29 -0
- package/dist-ssr/core/YamlMerger.d.ts.map +1 -0
- package/dist-ssr/core/YamlMergerBrowser.d.ts +18 -0
- package/dist-ssr/core/YamlMergerBrowser.d.ts.map +1 -0
- package/dist-ssr/index.d.ts +15 -0
- package/dist-ssr/index.d.ts.map +1 -0
- package/dist-ssr/server.cjs +574 -0
- package/dist-ssr/server.cjs.map +1 -0
- package/dist-ssr/server.d.ts +2 -0
- package/dist-ssr/server.js +554 -0
- package/dist-ssr/server.js.map +1 -0
- package/dist-ssr/types/StitchTypes.d.ts +38 -0
- package/dist-ssr/types/StitchTypes.d.ts.map +1 -0
- package/docs/advanced_validation.md +188 -0
- package/docs/middleware.md +507 -0
- package/docs/modules.md +175 -0
- package/docs/project.md +856 -0
- package/docs/validation.md +77 -0
- package/package.json +67 -0
- package/readme.md +159 -0
- package/schemas/schema.json +360 -0
- package/schemas/stitch-schema.json +38 -0
package/README-schema.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# VSCode Schema Validation Setup
|
|
2
|
+
|
|
3
|
+
This project now has VSCode schema validation configured for OpenAPI YAML files using the Dinner framework schema.
|
|
4
|
+
|
|
5
|
+
## What's Configured
|
|
6
|
+
|
|
7
|
+
- **Schema**: `./schemas/schema.json` - Extended OpenAPI 3.0 schema with Dinner framework extensions
|
|
8
|
+
- **Target Files**: All `*.yaml` files in the project
|
|
9
|
+
- **VSCode Settings**: `.vscode/settings.json` automatically configured
|
|
10
|
+
|
|
11
|
+
## Supported Extensions
|
|
12
|
+
|
|
13
|
+
### Dinner Framework Extensions
|
|
14
|
+
|
|
15
|
+
#### Required for all operations:
|
|
16
|
+
- `x-controller`: Controller class path (e.g., `controllers/user.controller`) - **REQUIRED**
|
|
17
|
+
- `x-action`: Controller method name (e.g., `create`, `getAll`) - **REQUIRED**
|
|
18
|
+
|
|
19
|
+
#### Optional:
|
|
20
|
+
- `x-middleware`: Middleware chain array (e.g., `["auth.middleware", "validation.middleware"]`)
|
|
21
|
+
|
|
22
|
+
### Module System
|
|
23
|
+
- `module`: Object containing module definitions with `basePath` and `paths`
|
|
24
|
+
- Each module must have:
|
|
25
|
+
- `basePath`: Base URL path for the module (e.g., `"/users"`)
|
|
26
|
+
- `paths`: Object with route definitions (same structure as main `paths`)
|
|
27
|
+
|
|
28
|
+
## Example Valid YAML
|
|
29
|
+
|
|
30
|
+
```yaml
|
|
31
|
+
openapi: 3.0.0
|
|
32
|
+
info:
|
|
33
|
+
title: My API
|
|
34
|
+
version: 1.0.0
|
|
35
|
+
paths:
|
|
36
|
+
/users:
|
|
37
|
+
get:
|
|
38
|
+
x-controller: controllers/user.controller
|
|
39
|
+
x-action: getAll
|
|
40
|
+
summary: Get all users
|
|
41
|
+
responses:
|
|
42
|
+
'200':
|
|
43
|
+
description: Success
|
|
44
|
+
post:
|
|
45
|
+
x-controller: controllers/user.controller
|
|
46
|
+
x-action: create
|
|
47
|
+
x-middleware:
|
|
48
|
+
- auth.middleware
|
|
49
|
+
summary: Create user
|
|
50
|
+
responses:
|
|
51
|
+
'201':
|
|
52
|
+
description: Created
|
|
53
|
+
|
|
54
|
+
# Module system example
|
|
55
|
+
module:
|
|
56
|
+
posts:
|
|
57
|
+
basePath: "/posts"
|
|
58
|
+
paths:
|
|
59
|
+
"/":
|
|
60
|
+
get:
|
|
61
|
+
x-controller: controllers/post.controller
|
|
62
|
+
x-action: getAll
|
|
63
|
+
summary: Get all posts
|
|
64
|
+
responses:
|
|
65
|
+
'200':
|
|
66
|
+
description: Success
|
|
67
|
+
"/{id}":
|
|
68
|
+
get:
|
|
69
|
+
x-controller: controllers/post.controller
|
|
70
|
+
x-action: getById
|
|
71
|
+
x-middleware:
|
|
72
|
+
- auth.middleware
|
|
73
|
+
summary: Get post by ID
|
|
74
|
+
parameters:
|
|
75
|
+
- name: id
|
|
76
|
+
in: path
|
|
77
|
+
required: true
|
|
78
|
+
schema:
|
|
79
|
+
type: integer
|
|
80
|
+
responses:
|
|
81
|
+
'200':
|
|
82
|
+
description: Success
|
|
83
|
+
'404':
|
|
84
|
+
description: Post not found
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Features
|
|
88
|
+
|
|
89
|
+
- **Real-time validation** as you type in VSCode
|
|
90
|
+
- **Required field validation** - ensures `x-controller` and `x-action` are present
|
|
91
|
+
- **Autocomplete** for OpenAPI properties and Dinner extensions
|
|
92
|
+
- **Error highlighting** for invalid properties or structure
|
|
93
|
+
- **Module validation** - validates module structure and paths
|
|
94
|
+
- **Schema-based IntelliSense** with descriptions for all Dinner extensions
|
|
95
|
+
|
|
96
|
+
## Manual Installation
|
|
97
|
+
|
|
98
|
+
If you need to install the schema for a different project:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Using Stitch CLI (if available)
|
|
102
|
+
stitch install ./schemas/schema.json --target "**/*.yaml"
|
|
103
|
+
|
|
104
|
+
# Or manually add to .vscode/settings.json:
|
|
105
|
+
{
|
|
106
|
+
"yaml.schemas": {
|
|
107
|
+
"./schemas/schema.json": ["**/*.yaml"]
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Validation Examples
|
|
113
|
+
|
|
114
|
+
✅ **Valid Dinner operation**:
|
|
115
|
+
```yaml
|
|
116
|
+
get:
|
|
117
|
+
x-controller: controllers/user.controller
|
|
118
|
+
x-action: getAll
|
|
119
|
+
x-middleware: ["auth.middleware"]
|
|
120
|
+
summary: Get all users
|
|
121
|
+
responses:
|
|
122
|
+
'200':
|
|
123
|
+
description: Success
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
❌ **Invalid - missing required fields**:
|
|
127
|
+
```yaml
|
|
128
|
+
get:
|
|
129
|
+
# Error: missing required x-controller and x-action
|
|
130
|
+
summary: Get all users
|
|
131
|
+
responses:
|
|
132
|
+
'200':
|
|
133
|
+
description: Success
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Requirements
|
|
137
|
+
|
|
138
|
+
- VSCode with "YAML" extension by Red Hat
|
|
139
|
+
- Local `schemas/schema.json` file in project
|
package/bin/stitch.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Production CLI entry point - uses compiled JavaScript
|
|
4
|
+
// Import from built ESM bundle
|
|
5
|
+
import { StitchEngine } from '../dist-ssr/server.js';
|
|
6
|
+
import { StitchCLIFactory } from '../dist-ssr/server.js';
|
|
7
|
+
|
|
8
|
+
const args = StitchCLIFactory.setup(process.argv);
|
|
9
|
+
|
|
10
|
+
// Validate that at least one command is provided
|
|
11
|
+
if (!args.commands || args.commands.length === 0) {
|
|
12
|
+
console.error("Error: No command specified");
|
|
13
|
+
printUsage();
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const commands = args.commands;
|
|
18
|
+
const command = commands[0];
|
|
19
|
+
|
|
20
|
+
// Handle help command
|
|
21
|
+
if (command.toLowerCase() === 'help' || args.flags.help) {
|
|
22
|
+
printUsage();
|
|
23
|
+
process.exit(0);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Handle version command
|
|
27
|
+
if (command.toLowerCase() === 'version' || args.flags.version) {
|
|
28
|
+
// Read package.json from relative path
|
|
29
|
+
const packageJson = JSON.parse(
|
|
30
|
+
await import('fs').then(fs =>
|
|
31
|
+
fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8')
|
|
32
|
+
)
|
|
33
|
+
);
|
|
34
|
+
console.log(`stitch v${packageJson.version}`);
|
|
35
|
+
process.exit(0);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function main() {
|
|
39
|
+
try {
|
|
40
|
+
const engine = new StitchEngine();
|
|
41
|
+
|
|
42
|
+
switch(command.toLowerCase()){
|
|
43
|
+
case "build":
|
|
44
|
+
const inputFile = commands[1] || 'stitch.yaml';
|
|
45
|
+
const result = await engine.build(inputFile, {
|
|
46
|
+
output: args.flags.output,
|
|
47
|
+
format: args.flags.format || 'yaml',
|
|
48
|
+
validate: args.flags.validate,
|
|
49
|
+
quiet: args.flags.quiet
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (result.success) {
|
|
53
|
+
if (!args.flags.quiet) {
|
|
54
|
+
if (args.flags.output) {
|
|
55
|
+
console.log(result.message);
|
|
56
|
+
} else {
|
|
57
|
+
console.log(result.data); // Output to stdout
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
console.error(result.error);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
break;
|
|
65
|
+
|
|
66
|
+
case "watch":
|
|
67
|
+
const watchFile = commands[1] || 'stitch.yaml';
|
|
68
|
+
await engine.watch(watchFile, {
|
|
69
|
+
output: args.flags.output,
|
|
70
|
+
format: args.flags.format || 'yaml',
|
|
71
|
+
validate: args.flags.validate,
|
|
72
|
+
quiet: args.flags.quiet
|
|
73
|
+
});
|
|
74
|
+
break;
|
|
75
|
+
|
|
76
|
+
case "install":
|
|
77
|
+
const schemaFile = commands[1];
|
|
78
|
+
if (!schemaFile) {
|
|
79
|
+
throw new Error("Schema file is required for install command");
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (!args.flags.target) {
|
|
83
|
+
throw new Error("--target option is required for install command");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const targets = args.flags.target.split(',').map(t => t.trim());
|
|
87
|
+
const installResult = engine.install({
|
|
88
|
+
schemaPath: schemaFile,
|
|
89
|
+
targets: targets,
|
|
90
|
+
vscodeSettingsPath: args.flags.vscode
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
if (installResult.success) {
|
|
94
|
+
if (!args.flags.quiet) {
|
|
95
|
+
console.log(installResult.message);
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
console.error(installResult.error);
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
break;
|
|
102
|
+
|
|
103
|
+
default:
|
|
104
|
+
throw new Error(`Unknown command: ${command}`);
|
|
105
|
+
}
|
|
106
|
+
} catch (error) {
|
|
107
|
+
console.error(`Error: ${error.message}`);
|
|
108
|
+
if (error.stack && process.env.DEBUG) {
|
|
109
|
+
console.error(error.stack);
|
|
110
|
+
}
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function printUsage() {
|
|
116
|
+
console.log(`
|
|
117
|
+
Stitch - YAML modularization tool
|
|
118
|
+
|
|
119
|
+
Usage:
|
|
120
|
+
stitch <command> [input-file] [options]
|
|
121
|
+
|
|
122
|
+
Commands:
|
|
123
|
+
build [input-file] Build and output to stdout in YAML format (defaults to stitch.yaml)
|
|
124
|
+
watch [input-file] Watch for changes and rebuild (defaults to stitch.yaml)
|
|
125
|
+
install <schema-file> Install JSON schema for VSCode YAML validation
|
|
126
|
+
help Show this help message
|
|
127
|
+
version Show version information
|
|
128
|
+
|
|
129
|
+
Options:
|
|
130
|
+
--output <file> Write the result to the specified file instead of stdout
|
|
131
|
+
--format <json|yaml> Specify the output format (default: yaml)
|
|
132
|
+
--validate [schema] Validate the output (optionally against a schema, otherwise just valid YAML)
|
|
133
|
+
--target <patterns> Comma-separated list of file patterns for schema validation (install only)
|
|
134
|
+
--vscode <path> Custom path to .vscode/settings.json (install only, defaults to .vscode/settings.json)
|
|
135
|
+
--quiet Build and validate but don't emit content
|
|
136
|
+
-h, --help Show help
|
|
137
|
+
-v, --version Show version
|
|
138
|
+
|
|
139
|
+
Examples:
|
|
140
|
+
stitch build Build stitch.yaml and output YAML to stdout
|
|
141
|
+
stitch build my-config.yaml Build my-config.yaml and output to stdout
|
|
142
|
+
stitch watch Watch stitch.yaml for changes and rebuild
|
|
143
|
+
stitch build --output result.yaml Build and write to file
|
|
144
|
+
stitch build --format json Build and output JSON to stdout
|
|
145
|
+
stitch build --validate Build with YAML validation
|
|
146
|
+
stitch build --validate schema.json Build with schema validation
|
|
147
|
+
stitch build --quiet Build and validate without output
|
|
148
|
+
stitch install schema.json --target "*.yaml,openapi/*.yaml" Install schema for YAML files
|
|
149
|
+
stitch install openapi-schema.json --target "stitch.yaml" Install schema for specific file
|
|
150
|
+
`);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
main().catch(error => {
|
|
154
|
+
console.error('Unhandled error:', error);
|
|
155
|
+
process.exit(1);
|
|
156
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { YamlMerger } from '../core/YamlMergerBrowser';
|
|
2
|
+
export { stitchFromViteImports, stitchFromOrderedViteImports, stitchFromSortedViteImports, stitchFromContent, stitchFromRawContent } from '../core/ViteHelper';
|
|
3
|
+
export * from '../types/StitchTypes';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EACL,qBAAqB,EACrB,4BAA4B,EAC5B,2BAA2B,EAC3B,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,oBAAoB,CAAC;AAC5B,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class StitchCLIFactory {
|
|
2
|
+
/**
|
|
3
|
+
* Parse command line arguments into commands and flags
|
|
4
|
+
* @param argv Optional array of command line arguments. If not provided, process.argv will be used.
|
|
5
|
+
* @returns Object containing parsed commands and flags
|
|
6
|
+
*/
|
|
7
|
+
static setup(argv?: string[]): {
|
|
8
|
+
commands: string[];
|
|
9
|
+
flags: Record<string, any>;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=StitchCLI.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StitchCLI.d.ts","sourceRoot":"","sources":["../../src/cli/StitchCLI.ts"],"names":[],"mappings":"AAEA,qBAAa,gBAAgB;IACzB;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG;QAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE;CA8CpF"}
|
package/dist/client.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("js-yaml");function f(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,o.get?o:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const u=f(l);class s{mergeContent(e){let t={};for(const o of e){let n;try{n=u.load(o.content)}catch(i){const m=o.name||"unknown content";throw new Error(`Invalid YAML in ${m}: ${i instanceof Error?i.message:String(i)}`)}n!==null&&typeof n=="object"&&(t=this.deepMerge(t,n))}return t}deepMerge(e,t){if(t==null)return e;if(e==null||typeof t!="object"||Array.isArray(t)||typeof e!="object"||Array.isArray(e))return t;const o={...e};for(const n in t)t.hasOwnProperty(n)&&(n in o?o[n]=this.deepMerge(o[n],t[n]):o[n]=t[n]);return o}}async function d(r){const e=await Promise.all(Object.entries(r).map(async([o,n])=>({content:(await n()).default,name:o})));return new s().mergeContent(e)}async function c(r,e){const t=await Promise.all(r.map(async n=>{const i=e[n];if(!i)throw new Error(`Import not found for path: ${n}`);return{content:(await i()).default,name:n}}));return new s().mergeContent(t)}async function p(r){const e=Object.keys(r).sort();return c(e,r)}function a(r){return new s().mergeContent(r)}function y(r){const e=r.map((t,o)=>({content:t,name:`content-${o}`}));return a(e)}exports.YamlMerger=s;exports.stitchFromContent=a;exports.stitchFromOrderedViteImports=c;exports.stitchFromRawContent=y;exports.stitchFromSortedViteImports=p;exports.stitchFromViteImports=d;
|
|
2
|
+
//# sourceMappingURL=client.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.cjs","sources":["../src/core/YamlMergerBrowser.ts","../src/core/ViteHelper.ts"],"sourcesContent":["import * as yaml from 'js-yaml';\n\nexport class YamlMerger {\n /**\n * Merge multiple YAML content strings in order\n */\n mergeContent(contents: Array<{ content: string; name?: string }>): any {\n let result = {};\n\n for (const item of contents) {\n let parsedContent: any;\n\n try {\n parsedContent = yaml.load(item.content);\n } catch (error) {\n const name = item.name || 'unknown content';\n throw new Error(`Invalid YAML in ${name}: ${error instanceof Error ? error.message : String(error)}`);\n }\n\n if (parsedContent !== null && typeof parsedContent === 'object') {\n result = this.deepMerge(result, parsedContent);\n }\n }\n\n return result;\n }\n\n /**\n * Deep merge two objects\n * Rules:\n * - Objects: merge properties, source overrides target\n * - Arrays: source replaces target completely\n * - Primitives: source overrides target\n */\n deepMerge(target: any, source: any): any {\n // If source is null/undefined, return target\n if (source === null || source === undefined) {\n return target;\n }\n\n // If target is null/undefined, return source\n if (target === null || target === undefined) {\n return source;\n }\n\n // If source is not an object, it replaces target\n if (typeof source !== 'object' || Array.isArray(source)) {\n return source;\n }\n\n // If target is not an object, source replaces it\n if (typeof target !== 'object' || Array.isArray(target)) {\n return source;\n }\n\n // Both are objects, merge them\n const result = { ...target };\n\n for (const key in source) {\n if (source.hasOwnProperty(key)) {\n if (key in result) {\n result[key] = this.deepMerge(result[key], source[key]);\n } else {\n result[key] = source[key];\n }\n }\n }\n\n return result;\n }\n}","import { YamlMerger } from './YamlMergerBrowser';\n\n/**\n * Helper function for Vite environments\n * Works with import.meta.glob() to merge YAML files\n */\nexport async function stitchFromViteImports(\n imports: Record<string, () => Promise<{ default: string }>>\n): Promise<any> {\n const contents = await Promise.all(\n Object.entries(imports).map(async ([path, importFn]) => ({\n content: (await importFn()).default,\n name: path\n }))\n );\n \n const merger = new YamlMerger();\n return merger.mergeContent(contents);\n}\n\n/**\n * Helper function for ordered Vite imports\n * Ensures files are merged in a specific order based on the array\n */\nexport async function stitchFromOrderedViteImports(\n orderedPaths: string[],\n imports: Record<string, () => Promise<{ default: string }>>\n): Promise<any> {\n const contents = await Promise.all(\n orderedPaths.map(async (path) => {\n const importFn = imports[path];\n if (!importFn) {\n throw new Error(`Import not found for path: ${path}`);\n }\n return {\n content: (await importFn()).default,\n name: path\n };\n })\n );\n \n const merger = new YamlMerger();\n return merger.mergeContent(contents);\n}\n\n/**\n * Helper function for glob pattern imports with sorting\n * Useful when you want alphabetical ordering of files\n */\nexport async function stitchFromSortedViteImports(\n imports: Record<string, () => Promise<{ default: string }>>\n): Promise<any> {\n const sortedPaths = Object.keys(imports).sort();\n return stitchFromOrderedViteImports(sortedPaths, imports);\n}\n\n/**\n * Direct content merging for when you already have the YAML strings\n */\nexport function stitchFromContent(\n contents: Array<{ content: string; name?: string }>\n): any {\n const merger = new YamlMerger();\n return merger.mergeContent(contents);\n}\n\n/**\n * Convenience function for merging raw YAML strings without names\n */\nexport function stitchFromRawContent(yamlStrings: string[]): any {\n const contents = yamlStrings.map((content, index) => ({\n content,\n name: `content-${index}`\n }));\n \n return stitchFromContent(contents);\n}"],"names":["YamlMerger","contents","result","item","parsedContent","yaml","error","name","target","source","key","stitchFromViteImports","imports","path","importFn","stitchFromOrderedViteImports","orderedPaths","stitchFromSortedViteImports","sortedPaths","stitchFromContent","stitchFromRawContent","yamlStrings","content","index"],"mappings":"qYAEO,MAAMA,CAAW,CAItB,aAAaC,EAA0D,CACrE,IAAIC,EAAS,CAAC,EAEd,UAAWC,KAAQF,EAAU,CACvB,IAAAG,EAEA,GAAA,CACcA,EAAAC,EAAK,KAAKF,EAAK,OAAO,QAC/BG,EAAO,CACR,MAAAC,EAAOJ,EAAK,MAAQ,kBAC1B,MAAM,IAAI,MAAM,mBAAmBI,CAAI,KAAKD,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,CAAC,EAAE,CAAA,CAGlGF,IAAkB,MAAQ,OAAOA,GAAkB,WAC5CF,EAAA,KAAK,UAAUA,EAAQE,CAAa,EAC/C,CAGK,OAAAF,CAAA,CAUT,UAAUM,EAAaC,EAAkB,CAEnC,GAAAA,GAAW,KACN,OAAAD,EAcT,GAVIA,GAAW,MAKX,OAAOC,GAAW,UAAY,MAAM,QAAQA,CAAM,GAKlD,OAAOD,GAAW,UAAY,MAAM,QAAQA,CAAM,EAC7C,OAAAC,EAIH,MAAAP,EAAS,CAAE,GAAGM,CAAO,EAE3B,UAAWE,KAAOD,EACZA,EAAO,eAAeC,CAAG,IACvBA,KAAOR,EACFA,EAAAQ,CAAG,EAAI,KAAK,UAAUR,EAAOQ,CAAG,EAAGD,EAAOC,CAAG,CAAC,EAE9CR,EAAAQ,CAAG,EAAID,EAAOC,CAAG,GAKvB,OAAAR,CAAA,CAEX,CChEA,eAAsBS,EACpBC,EACc,CACR,MAAAX,EAAW,MAAM,QAAQ,IAC7B,OAAO,QAAQW,CAAO,EAAE,IAAI,MAAO,CAACC,EAAMC,CAAQ,KAAO,CACvD,SAAU,MAAMA,EAAA,GAAY,QAC5B,KAAMD,CAAA,EACN,CACJ,EAGO,OADQ,IAAIb,EAAW,EAChB,aAAaC,CAAQ,CACrC,CAMsB,eAAAc,EACpBC,EACAJ,EACc,CACR,MAAAX,EAAW,MAAM,QAAQ,IAC7Be,EAAa,IAAI,MAAOH,GAAS,CACzB,MAAAC,EAAWF,EAAQC,CAAI,EAC7B,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,8BAA8BD,CAAI,EAAE,EAE/C,MAAA,CACL,SAAU,MAAMC,EAAA,GAAY,QAC5B,KAAMD,CACR,CACD,CAAA,CACH,EAGO,OADQ,IAAIb,EAAW,EAChB,aAAaC,CAAQ,CACrC,CAMA,eAAsBgB,EACpBL,EACc,CACd,MAAMM,EAAc,OAAO,KAAKN,CAAO,EAAE,KAAK,EACvC,OAAAG,EAA6BG,EAAaN,CAAO,CAC1D,CAKO,SAASO,EACdlB,EACK,CAEE,OADQ,IAAID,EAAW,EAChB,aAAaC,CAAQ,CACrC,CAKO,SAASmB,EAAqBC,EAA4B,CAC/D,MAAMpB,EAAWoB,EAAY,IAAI,CAACC,EAASC,KAAW,CACpD,QAAAD,EACA,KAAM,WAAWC,CAAK,EAAA,EACtB,EAEF,OAAOJ,EAAkBlB,CAAQ,CACnC"}
|
package/dist/client.mjs
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import * as m from "js-yaml";
|
|
2
|
+
class s {
|
|
3
|
+
/**
|
|
4
|
+
* Merge multiple YAML content strings in order
|
|
5
|
+
*/
|
|
6
|
+
mergeContent(e) {
|
|
7
|
+
let t = {};
|
|
8
|
+
for (const r of e) {
|
|
9
|
+
let n;
|
|
10
|
+
try {
|
|
11
|
+
n = m.load(r.content);
|
|
12
|
+
} catch (i) {
|
|
13
|
+
const a = r.name || "unknown content";
|
|
14
|
+
throw new Error(`Invalid YAML in ${a}: ${i instanceof Error ? i.message : String(i)}`);
|
|
15
|
+
}
|
|
16
|
+
n !== null && typeof n == "object" && (t = this.deepMerge(t, n));
|
|
17
|
+
}
|
|
18
|
+
return t;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Deep merge two objects
|
|
22
|
+
* Rules:
|
|
23
|
+
* - Objects: merge properties, source overrides target
|
|
24
|
+
* - Arrays: source replaces target completely
|
|
25
|
+
* - Primitives: source overrides target
|
|
26
|
+
*/
|
|
27
|
+
deepMerge(e, t) {
|
|
28
|
+
if (t == null)
|
|
29
|
+
return e;
|
|
30
|
+
if (e == null || typeof t != "object" || Array.isArray(t) || typeof e != "object" || Array.isArray(e))
|
|
31
|
+
return t;
|
|
32
|
+
const r = { ...e };
|
|
33
|
+
for (const n in t)
|
|
34
|
+
t.hasOwnProperty(n) && (n in r ? r[n] = this.deepMerge(r[n], t[n]) : r[n] = t[n]);
|
|
35
|
+
return r;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async function l(o) {
|
|
39
|
+
const e = await Promise.all(
|
|
40
|
+
Object.entries(o).map(async ([r, n]) => ({
|
|
41
|
+
content: (await n()).default,
|
|
42
|
+
name: r
|
|
43
|
+
}))
|
|
44
|
+
);
|
|
45
|
+
return new s().mergeContent(e);
|
|
46
|
+
}
|
|
47
|
+
async function c(o, e) {
|
|
48
|
+
const t = await Promise.all(
|
|
49
|
+
o.map(async (n) => {
|
|
50
|
+
const i = e[n];
|
|
51
|
+
if (!i)
|
|
52
|
+
throw new Error(`Import not found for path: ${n}`);
|
|
53
|
+
return {
|
|
54
|
+
content: (await i()).default,
|
|
55
|
+
name: n
|
|
56
|
+
};
|
|
57
|
+
})
|
|
58
|
+
);
|
|
59
|
+
return new s().mergeContent(t);
|
|
60
|
+
}
|
|
61
|
+
async function y(o) {
|
|
62
|
+
const e = Object.keys(o).sort();
|
|
63
|
+
return c(e, o);
|
|
64
|
+
}
|
|
65
|
+
function f(o) {
|
|
66
|
+
return new s().mergeContent(o);
|
|
67
|
+
}
|
|
68
|
+
function p(o) {
|
|
69
|
+
const e = o.map((t, r) => ({
|
|
70
|
+
content: t,
|
|
71
|
+
name: `content-${r}`
|
|
72
|
+
}));
|
|
73
|
+
return f(e);
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
s as YamlMerger,
|
|
77
|
+
f as stitchFromContent,
|
|
78
|
+
c as stitchFromOrderedViteImports,
|
|
79
|
+
p as stitchFromRawContent,
|
|
80
|
+
y as stitchFromSortedViteImports,
|
|
81
|
+
l as stitchFromViteImports
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=client.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.mjs","sources":["../src/core/YamlMergerBrowser.ts","../src/core/ViteHelper.ts"],"sourcesContent":["import * as yaml from 'js-yaml';\n\nexport class YamlMerger {\n /**\n * Merge multiple YAML content strings in order\n */\n mergeContent(contents: Array<{ content: string; name?: string }>): any {\n let result = {};\n\n for (const item of contents) {\n let parsedContent: any;\n\n try {\n parsedContent = yaml.load(item.content);\n } catch (error) {\n const name = item.name || 'unknown content';\n throw new Error(`Invalid YAML in ${name}: ${error instanceof Error ? error.message : String(error)}`);\n }\n\n if (parsedContent !== null && typeof parsedContent === 'object') {\n result = this.deepMerge(result, parsedContent);\n }\n }\n\n return result;\n }\n\n /**\n * Deep merge two objects\n * Rules:\n * - Objects: merge properties, source overrides target\n * - Arrays: source replaces target completely\n * - Primitives: source overrides target\n */\n deepMerge(target: any, source: any): any {\n // If source is null/undefined, return target\n if (source === null || source === undefined) {\n return target;\n }\n\n // If target is null/undefined, return source\n if (target === null || target === undefined) {\n return source;\n }\n\n // If source is not an object, it replaces target\n if (typeof source !== 'object' || Array.isArray(source)) {\n return source;\n }\n\n // If target is not an object, source replaces it\n if (typeof target !== 'object' || Array.isArray(target)) {\n return source;\n }\n\n // Both are objects, merge them\n const result = { ...target };\n\n for (const key in source) {\n if (source.hasOwnProperty(key)) {\n if (key in result) {\n result[key] = this.deepMerge(result[key], source[key]);\n } else {\n result[key] = source[key];\n }\n }\n }\n\n return result;\n }\n}","import { YamlMerger } from './YamlMergerBrowser';\n\n/**\n * Helper function for Vite environments\n * Works with import.meta.glob() to merge YAML files\n */\nexport async function stitchFromViteImports(\n imports: Record<string, () => Promise<{ default: string }>>\n): Promise<any> {\n const contents = await Promise.all(\n Object.entries(imports).map(async ([path, importFn]) => ({\n content: (await importFn()).default,\n name: path\n }))\n );\n \n const merger = new YamlMerger();\n return merger.mergeContent(contents);\n}\n\n/**\n * Helper function for ordered Vite imports\n * Ensures files are merged in a specific order based on the array\n */\nexport async function stitchFromOrderedViteImports(\n orderedPaths: string[],\n imports: Record<string, () => Promise<{ default: string }>>\n): Promise<any> {\n const contents = await Promise.all(\n orderedPaths.map(async (path) => {\n const importFn = imports[path];\n if (!importFn) {\n throw new Error(`Import not found for path: ${path}`);\n }\n return {\n content: (await importFn()).default,\n name: path\n };\n })\n );\n \n const merger = new YamlMerger();\n return merger.mergeContent(contents);\n}\n\n/**\n * Helper function for glob pattern imports with sorting\n * Useful when you want alphabetical ordering of files\n */\nexport async function stitchFromSortedViteImports(\n imports: Record<string, () => Promise<{ default: string }>>\n): Promise<any> {\n const sortedPaths = Object.keys(imports).sort();\n return stitchFromOrderedViteImports(sortedPaths, imports);\n}\n\n/**\n * Direct content merging for when you already have the YAML strings\n */\nexport function stitchFromContent(\n contents: Array<{ content: string; name?: string }>\n): any {\n const merger = new YamlMerger();\n return merger.mergeContent(contents);\n}\n\n/**\n * Convenience function for merging raw YAML strings without names\n */\nexport function stitchFromRawContent(yamlStrings: string[]): any {\n const contents = yamlStrings.map((content, index) => ({\n content,\n name: `content-${index}`\n }));\n \n return stitchFromContent(contents);\n}"],"names":["YamlMerger","contents","result","item","parsedContent","yaml","error","name","target","source","key","stitchFromViteImports","imports","path","importFn","stitchFromOrderedViteImports","orderedPaths","stitchFromSortedViteImports","sortedPaths","stitchFromContent","stitchFromRawContent","yamlStrings","content","index"],"mappings":";AAEO,MAAMA,EAAW;AAAA;AAAA;AAAA;AAAA,EAItB,aAAaC,GAA0D;AACrE,QAAIC,IAAS,CAAC;AAEd,eAAWC,KAAQF,GAAU;AACvB,UAAAG;AAEA,UAAA;AACc,QAAAA,IAAAC,EAAK,KAAKF,EAAK,OAAO;AAAA,eAC/BG,GAAO;AACR,cAAAC,IAAOJ,EAAK,QAAQ;AAC1B,cAAM,IAAI,MAAM,mBAAmBI,CAAI,KAAKD,aAAiB,QAAQA,EAAM,UAAU,OAAOA,CAAK,CAAC,EAAE;AAAA,MAAA;AAGtG,MAAIF,MAAkB,QAAQ,OAAOA,KAAkB,aAC5CF,IAAA,KAAK,UAAUA,GAAQE,CAAa;AAAA,IAC/C;AAGK,WAAAF;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUT,UAAUM,GAAaC,GAAkB;AAEnC,QAAAA,KAAW;AACN,aAAAD;AAcT,QAVIA,KAAW,QAKX,OAAOC,KAAW,YAAY,MAAM,QAAQA,CAAM,KAKlD,OAAOD,KAAW,YAAY,MAAM,QAAQA,CAAM;AAC7C,aAAAC;AAIH,UAAAP,IAAS,EAAE,GAAGM,EAAO;AAE3B,eAAWE,KAAOD;AACZ,MAAAA,EAAO,eAAeC,CAAG,MACvBA,KAAOR,IACFA,EAAAQ,CAAG,IAAI,KAAK,UAAUR,EAAOQ,CAAG,GAAGD,EAAOC,CAAG,CAAC,IAE9CR,EAAAQ,CAAG,IAAID,EAAOC,CAAG;AAKvB,WAAAR;AAAA,EAAA;AAEX;AChEA,eAAsBS,EACpBC,GACc;AACR,QAAAX,IAAW,MAAM,QAAQ;AAAA,IAC7B,OAAO,QAAQW,CAAO,EAAE,IAAI,OAAO,CAACC,GAAMC,CAAQ,OAAO;AAAA,MACvD,UAAU,MAAMA,EAAA,GAAY;AAAA,MAC5B,MAAMD;AAAA,IAAA,EACN;AAAA,EACJ;AAGO,SADQ,IAAIb,EAAW,EAChB,aAAaC,CAAQ;AACrC;AAMsB,eAAAc,EACpBC,GACAJ,GACc;AACR,QAAAX,IAAW,MAAM,QAAQ;AAAA,IAC7Be,EAAa,IAAI,OAAOH,MAAS;AACzB,YAAAC,IAAWF,EAAQC,CAAI;AAC7B,UAAI,CAACC;AACH,cAAM,IAAI,MAAM,8BAA8BD,CAAI,EAAE;AAE/C,aAAA;AAAA,QACL,UAAU,MAAMC,EAAA,GAAY;AAAA,QAC5B,MAAMD;AAAA,MACR;AAAA,IACD,CAAA;AAAA,EACH;AAGO,SADQ,IAAIb,EAAW,EAChB,aAAaC,CAAQ;AACrC;AAMA,eAAsBgB,EACpBL,GACc;AACd,QAAMM,IAAc,OAAO,KAAKN,CAAO,EAAE,KAAK;AACvC,SAAAG,EAA6BG,GAAaN,CAAO;AAC1D;AAKO,SAASO,EACdlB,GACK;AAEE,SADQ,IAAID,EAAW,EAChB,aAAaC,CAAQ;AACrC;AAKO,SAASmB,EAAqBC,GAA4B;AAC/D,QAAMpB,IAAWoB,EAAY,IAAI,CAACC,GAASC,OAAW;AAAA,IACpD,SAAAD;AAAA,IACA,MAAM,WAAWC,CAAK;AAAA,EAAA,EACtB;AAEF,SAAOJ,EAAkBlB,CAAQ;AACnC;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { StitchConfig } from '../types/StitchTypes';
|
|
2
|
+
export declare class ConfigParser {
|
|
3
|
+
/**
|
|
4
|
+
* Parse a stitch.yaml configuration file
|
|
5
|
+
*/
|
|
6
|
+
parseConfig(configPath: string): StitchConfig;
|
|
7
|
+
/**
|
|
8
|
+
* Resolve file paths and expand globs relative to the config file directory
|
|
9
|
+
*/
|
|
10
|
+
resolveFilePaths(patterns: string[], baseDir: string): Promise<string[]>;
|
|
11
|
+
/**
|
|
12
|
+
* Get the directory containing the config file
|
|
13
|
+
*/
|
|
14
|
+
getConfigDir(configPath: string): string;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=ConfigParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigParser.d.ts","sourceRoot":"","sources":["../../src/core/ConfigParser.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,qBAAa,YAAY;IACvB;;OAEG;IACH,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY;IAqB7C;;OAEG;IACG,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IA6B9E;;OAEG;IACH,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;CAGzC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BuildOptions, WatchOptions, StitchResult, ContentItem, InstallOptions } from '../types/StitchTypes';
|
|
2
|
+
export declare class StitchEngine {
|
|
3
|
+
private configParser;
|
|
4
|
+
private yamlMerger;
|
|
5
|
+
private validator;
|
|
6
|
+
/**
|
|
7
|
+
* Build from a stitch configuration file (async)
|
|
8
|
+
*/
|
|
9
|
+
build(configPath: string, options?: BuildOptions): Promise<StitchResult>;
|
|
10
|
+
/**
|
|
11
|
+
* Build from a stitch configuration file (sync)
|
|
12
|
+
*/
|
|
13
|
+
buildSync(configPath: string, options?: BuildOptions): StitchResult;
|
|
14
|
+
/**
|
|
15
|
+
* Watch mode - rebuild when files change
|
|
16
|
+
*/
|
|
17
|
+
watch(configPath: string, options?: WatchOptions): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Build from content directly (no file system access)
|
|
20
|
+
*/
|
|
21
|
+
buildFromContent(contents: ContentItem[], options?: Omit<BuildOptions, 'input'>): StitchResult;
|
|
22
|
+
/**
|
|
23
|
+
* Synchronous version of file path resolution for buildSync
|
|
24
|
+
*/
|
|
25
|
+
private resolveFilePathsSync;
|
|
26
|
+
/**
|
|
27
|
+
* Install JSON schema for VSCode YAML validation
|
|
28
|
+
*/
|
|
29
|
+
install(options: InstallOptions): StitchResult;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=StitchEngine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StitchEngine.d.ts","sourceRoot":"","sources":["../../src/core/StitchEngine.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE7G,qBAAa,YAAY;IACvB,OAAO,CAAC,YAAY,CAAsB;IAC1C,OAAO,CAAC,UAAU,CAAoB;IACtC,OAAO,CAAC,SAAS,CAAmB;IAEpC;;OAEG;IACG,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,YAAY,CAAC;IA4DlF;;OAEG;IACH,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,YAAY;IA4DvE;;OAEG;IACG,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAqD1E;;OAEG;IACH,gBAAgB,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,OAAO,GAAE,IAAI,CAAC,YAAY,EAAE,OAAO,CAAM,GAAG,YAAY;IA+ClG;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA6B5B;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,YAAY;CA0D/C"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ValidationResult } from '../types/StitchTypes';
|
|
2
|
+
export declare class Validator {
|
|
3
|
+
private ajv;
|
|
4
|
+
constructor();
|
|
5
|
+
/**
|
|
6
|
+
* Validate YAML syntax
|
|
7
|
+
*/
|
|
8
|
+
validateYamlSyntax(yamlString: string): ValidationResult;
|
|
9
|
+
/**
|
|
10
|
+
* Validate against OpenAPI schema
|
|
11
|
+
*/
|
|
12
|
+
validateOpenAPI(yamlContent: any, schemaPath?: string): ValidationResult;
|
|
13
|
+
/**
|
|
14
|
+
* Validate against a JSON schema file
|
|
15
|
+
*/
|
|
16
|
+
private validateAgainstSchema;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=Validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Validator.d.ts","sourceRoot":"","sources":["../../src/core/Validator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,qBAAa,SAAS;IACpB,OAAO,CAAC,GAAG,CAAM;;IAOjB;;OAEG;IACH,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB;IAYxD;;OAEG;IACH,eAAe,CAAC,WAAW,EAAE,GAAG,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,gBAAgB;IAyBxE;;OAEG;IACH,OAAO,CAAC,qBAAqB;CAmC9B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper function for Vite environments
|
|
3
|
+
* Works with import.meta.glob() to merge YAML files
|
|
4
|
+
*/
|
|
5
|
+
export declare function stitchFromViteImports(imports: Record<string, () => Promise<{
|
|
6
|
+
default: string;
|
|
7
|
+
}>>): Promise<any>;
|
|
8
|
+
/**
|
|
9
|
+
* Helper function for ordered Vite imports
|
|
10
|
+
* Ensures files are merged in a specific order based on the array
|
|
11
|
+
*/
|
|
12
|
+
export declare function stitchFromOrderedViteImports(orderedPaths: string[], imports: Record<string, () => Promise<{
|
|
13
|
+
default: string;
|
|
14
|
+
}>>): Promise<any>;
|
|
15
|
+
/**
|
|
16
|
+
* Helper function for glob pattern imports with sorting
|
|
17
|
+
* Useful when you want alphabetical ordering of files
|
|
18
|
+
*/
|
|
19
|
+
export declare function stitchFromSortedViteImports(imports: Record<string, () => Promise<{
|
|
20
|
+
default: string;
|
|
21
|
+
}>>): Promise<any>;
|
|
22
|
+
/**
|
|
23
|
+
* Direct content merging for when you already have the YAML strings
|
|
24
|
+
*/
|
|
25
|
+
export declare function stitchFromContent(contents: Array<{
|
|
26
|
+
content: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
}>): any;
|
|
29
|
+
/**
|
|
30
|
+
* Convenience function for merging raw YAML strings without names
|
|
31
|
+
*/
|
|
32
|
+
export declare function stitchFromRawContent(yamlStrings: string[]): any;
|
|
33
|
+
//# sourceMappingURL=ViteHelper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ViteHelper.d.ts","sourceRoot":"","sources":["../../src/core/ViteHelper.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,GAC1D,OAAO,CAAC,GAAG,CAAC,CAUd;AAED;;;GAGG;AACH,wBAAsB,4BAA4B,CAChD,YAAY,EAAE,MAAM,EAAE,EACtB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,GAC1D,OAAO,CAAC,GAAG,CAAC,CAgBd;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,GAC1D,OAAO,CAAC,GAAG,CAAC,CAGd;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,KAAK,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GAClD,GAAG,CAGL;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,GAAG,CAO/D"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare class YamlMerger {
|
|
2
|
+
/**
|
|
3
|
+
* Merge multiple YAML files in order
|
|
4
|
+
*/
|
|
5
|
+
mergeFiles(filePaths: string[]): any;
|
|
6
|
+
/**
|
|
7
|
+
* Merge multiple YAML content strings in order
|
|
8
|
+
*/
|
|
9
|
+
mergeContent(contents: Array<{
|
|
10
|
+
content: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
}>): any;
|
|
13
|
+
/**
|
|
14
|
+
* Merge mixed items (files and content) in order
|
|
15
|
+
*/
|
|
16
|
+
merge(items: Array<string | {
|
|
17
|
+
content: string;
|
|
18
|
+
name?: string;
|
|
19
|
+
}>): any;
|
|
20
|
+
/**
|
|
21
|
+
* Deep merge two objects
|
|
22
|
+
* Rules:
|
|
23
|
+
* - Objects: merge properties, source overrides target
|
|
24
|
+
* - Arrays: source replaces target completely
|
|
25
|
+
* - Primitives: source overrides target
|
|
26
|
+
*/
|
|
27
|
+
deepMerge(target: any, source: any): any;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=YamlMerger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"YamlMerger.d.ts","sourceRoot":"","sources":["../../src/core/YamlMerger.ts"],"names":[],"mappings":"AAGA,qBAAa,UAAU;IACrB;;OAEG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,GAAG;IAyBpC;;OAEG;IACH,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,GAAG;IAqBtE;;OAEG;IACH,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,GAAG;IAwCrE;;;;;;OAMG;IACH,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,GAAG,GAAG;CAoCzC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare class YamlMerger {
|
|
2
|
+
/**
|
|
3
|
+
* Merge multiple YAML content strings in order
|
|
4
|
+
*/
|
|
5
|
+
mergeContent(contents: Array<{
|
|
6
|
+
content: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
}>): any;
|
|
9
|
+
/**
|
|
10
|
+
* Deep merge two objects
|
|
11
|
+
* Rules:
|
|
12
|
+
* - Objects: merge properties, source overrides target
|
|
13
|
+
* - Arrays: source replaces target completely
|
|
14
|
+
* - Primitives: source overrides target
|
|
15
|
+
*/
|
|
16
|
+
deepMerge(target: any, source: any): any;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=YamlMergerBrowser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"YamlMergerBrowser.d.ts","sourceRoot":"","sources":["../../src/core/YamlMergerBrowser.ts"],"names":[],"mappings":"AAEA,qBAAa,UAAU;IACrB;;OAEG;IACH,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,GAAG;IAqBtE;;;;;;OAMG;IACH,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,GAAG,GAAG;CAoCzC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BuildOptions, WatchOptions, ContentItem, InstallOptions } from './types/StitchTypes';
|
|
2
|
+
export { StitchEngine } from './core/StitchEngine';
|
|
3
|
+
export { ConfigParser } from './core/ConfigParser';
|
|
4
|
+
export { YamlMerger } from './core/YamlMerger';
|
|
5
|
+
export { Validator } from './core/Validator';
|
|
6
|
+
export { StitchCLIFactory } from './cli/StitchCLI';
|
|
7
|
+
export * from './types/StitchTypes';
|
|
8
|
+
export declare const stitch: {
|
|
9
|
+
build: (options: BuildOptions) => Promise<import('./browser').StitchResult>;
|
|
10
|
+
buildSync: (options: BuildOptions) => import('./browser').StitchResult;
|
|
11
|
+
buildFromContent: (contents: ContentItem[], options?: Omit<BuildOptions, "input">) => import('./browser').StitchResult;
|
|
12
|
+
watch: (options: WatchOptions) => Promise<void>;
|
|
13
|
+
install: (options: InstallOptions) => import('./browser').StitchResult;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,cAAc,qBAAqB,CAAC;AAIpC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE9F,eAAO,MAAM,MAAM;qBACM,YAAY;yBAKd,YAAY;iCAKJ,WAAW,EAAE,YAAW,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC;qBAKzD,YAAY;uBAKhB,cAAc;CAIlC,CAAC"}
|