@superblocksteam/ai-service-templates 2.0.123 → 2.0.124-next.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.
- package/package.json +2 -2
- package/templates.js +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superblocksteam/ai-service-templates",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.124-next.1",
|
|
4
4
|
"files": [
|
|
5
5
|
"reify-template.js",
|
|
6
6
|
"templates.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/node": "^24",
|
|
27
|
-
"vitest": "
|
|
27
|
+
"vitest": "4.0.17"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"registry": "https://registry.npmjs.org"
|
package/templates.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
export const templates = {
|
|
3
3
|
"api-builder-to-yaml": {
|
|
4
4
|
"bootstrap.mjs": "import { register } from \"node:module\";\nimport { pathToFileURL } from \"node:url\";\n\nregister(\"./shim-loader.mjs\", pathToFileURL(\"./\"));\n",
|
|
5
|
-
"package.json": "{\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"tsc\",\n \"test\": \"pnpm build && vitest run src/superblocks-library-shim/*.test.ts\"\n },\n \"dependencies\": {\n \"@types/node\": \"^24\",\n \"@typescript-eslint/parser\": \"^8.54.0\",\n \"acorn\": \"^8.14.0\",\n \"eslint\": \"^9.39.2\",\n \"prettier\": \"^3.7.4\",\n \"typescript\": \"^5.9.3\",\n \"yaml\": \"^2.7.1\"\n },\n \"devDependencies\": {\n \"vitest\": \"
|
|
5
|
+
"package.json": "{\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"tsc\",\n \"test\": \"pnpm build && vitest run src/superblocks-library-shim/*.test.ts\"\n },\n \"dependencies\": {\n \"@types/node\": \"^24\",\n \"@typescript-eslint/parser\": \"^8.54.0\",\n \"acorn\": \"^8.14.0\",\n \"eslint\": \"^9.39.2\",\n \"prettier\": \"^3.7.4\",\n \"typescript\": \"^5.9.3\",\n \"yaml\": \"^2.7.1\"\n },\n \"devDependencies\": {\n \"vitest\": \"4.0.17\"\n }\n}\n",
|
|
6
|
+
"pnpm-workspace.yaml": "packages:\n - .\n\n# Template prefetch installs this package without the repo lockfile in /tmp.\n# Keep Vitest's tinyexec transitive on the trust-policy-safe version.\noverrides:\n tinyexec: 1.0.2\n",
|
|
6
7
|
"shim-loader.mjs": "import path from \"path\";\nimport { pathToFileURL } from \"url\";\n\nconst overrideMap = {\n \"@superblocksteam/library\": \"./dist/superblocks-library-shim/index.js\",\n};\n\nexport async function resolve(specifier, context, nextResolve) {\n if (overrideMap[specifier]) {\n const fullPath = path.resolve(overrideMap[specifier]);\n return {\n shortCircuit: true,\n url: pathToFileURL(fullPath).href,\n };\n }\n\n return nextResolve(specifier, context);\n}\n",
|
|
7
8
|
"src/do-eval-to-sdk.ts": "import fs from \"fs\";\nimport path from \"path\";\nimport { fileURLToPath } from \"url\";\n\n// finds all JavaScript files in the specified directory,\n// imports each module, converts its JSON representation to SDK,\n// and returns a map with filenames as keys and SDK content as values.\nexport async function processSdkFiles(\n apisDir: string,\n): Promise<Record<string, string>> {\n const files = fs.readdirSync(apisDir);\n const jsFiles = files.filter(\n (file) => file.endsWith(\".js\") && file !== \"__template__.js\",\n );\n const results: Record<string, string> = {};\n\n for (const jsFile of jsFiles) {\n const filePath = path.join(apisDir, jsFile);\n const absolutePath = path.resolve(filePath);\n\n try {\n const fileUrl = new URL(`file://${absolutePath}`);\n const module = await import(fileUrl.href);\n\n const defaultExport = module.default;\n\n if (defaultExport && typeof defaultExport.toSDK === \"function\") {\n const sdkData = await defaultExport.toSDK();\n\n results[jsFile] = sdkData;\n } else {\n console.warn(`${jsFile}: Default export doesn't have a toSDK method`);\n }\n } catch (error) {\n console.error(`Error processing ${jsFile}:`, error);\n }\n }\n\n return results;\n}\n\nasync function main() {\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = path.dirname(__filename);\n const apisDir = path.resolve(__dirname, \"./to-sdk\");\n\n const results = await processSdkFiles(apisDir);\n console.log(JSON.stringify(results, null, 2));\n}\n\nmain().catch((error) => {\n console.error(\"Error:\", error);\n process.exit(1);\n});\n",
|
|
8
9
|
"src/do-eval-to-yaml.ts": "import fs from \"fs\";\nimport path from \"path\";\nimport { fileURLToPath } from \"url\";\n\nimport yaml from \"yaml\";\n\nimport { Global } from \"./superblocks-library-shim/index.js\";\n\n/**\n * Initialize global context from environment variables.\n * This allows the transformer to pass plugin version information\n * to the shim classes for version-aware output generation.\n *\n * The PLUGIN_EXECUTION_VERSIONS env var is set by ApiBuilderToYamlTransformer\n * (in to-yaml-transformer.ts) when spawning the eval process. The versions\n * originate from the SDK/UserInfo and flow through AiService -> IntegrationStore.\n */\nfunction initializeGlobalContext(): void {\n const pluginVersionsEnv = process.env.PLUGIN_EXECUTION_VERSIONS;\n if (pluginVersionsEnv) {\n try {\n Global.pluginExecutionVersions = JSON.parse(pluginVersionsEnv);\n } catch {\n console.warn(\n \"Failed to parse PLUGIN_EXECUTION_VERSIONS environment variable\",\n );\n }\n }\n}\n\n// finds all JavaScript files in the specified directory,\n// imports each module, converts its JSON representation to YAML,\n// and returns a map with filenames as keys and YAML content as values.\n\nexport async function processYamlFiles(\n apisDir: string,\n): Promise<Record<string, string>> {\n const files = fs.readdirSync(apisDir);\n const jsFiles = files.filter((file) => file.endsWith(\".js\"));\n const results: Record<string, string> = {};\n\n for (const jsFile of jsFiles) {\n const filePath = path.join(apisDir, jsFile);\n const absolutePath = path.resolve(filePath);\n\n try {\n const fileUrl = new URL(`file://${absolutePath}`);\n const module = await import(fileUrl.href);\n\n const defaultExport = module.default;\n\n if (defaultExport && typeof defaultExport.toJSON === \"function\") {\n const jsonData = await defaultExport.toJSON();\n const yamlContent = yaml.stringify(jsonData);\n results[jsFile] = yamlContent;\n } else {\n console.warn(`${jsFile}: Default export doesn't have a toJSON method`);\n }\n } catch (error) {\n console.error(`Error processing ${jsFile}:`, error);\n }\n }\n\n return results;\n}\n\nasync function main() {\n // Initialize global context before processing\n initializeGlobalContext();\n\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = path.dirname(__filename);\n const apisDir = path.resolve(__dirname, \"./to-yaml\");\n\n const results = await processYamlFiles(apisDir);\n console.log(JSON.stringify(results, null, 2));\n}\n\nmain().catch((error) => {\n console.error(\"Error:\", error);\n process.exit(1);\n});\n",
|