@pulumi/pulumi 3.150.1-alpha.x17b9d6d → 3.150.1-alpha.x425a5d7
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 +1 -1
- package/provider/experimental/analyzer.d.ts +23 -0
- package/provider/experimental/analyzer.js +123 -0
- package/provider/experimental/analyzer.js.map +1 -0
- package/provider/experimental/index.d.ts +1 -0
- package/provider/experimental/index.js +20 -0
- package/provider/experimental/index.js.map +1 -0
- package/provider/experimental/provider.d.ts +15 -0
- package/provider/experimental/provider.js +112 -0
- package/provider/experimental/provider.js.map +1 -0
- package/provider/experimental/schema.d.ts +58 -0
- package/provider/experimental/schema.js +60 -0
- package/provider/experimental/schema.js.map +1 -0
- package/version.js +1 -1
package/package.json
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ComponentResource } from "../../resource";
|
|
2
|
+
export declare type ComponentDefinition = {
|
|
3
|
+
name: string;
|
|
4
|
+
};
|
|
5
|
+
export declare type TypeDefinition = {
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
export declare type AnalyzeResult = {
|
|
9
|
+
components: Record<string, ComponentDefinition>;
|
|
10
|
+
typeDefinitons: Record<string, TypeDefinition>;
|
|
11
|
+
};
|
|
12
|
+
export declare class Analyzer {
|
|
13
|
+
private path;
|
|
14
|
+
private checker;
|
|
15
|
+
private program;
|
|
16
|
+
private components;
|
|
17
|
+
private typeDefinitons;
|
|
18
|
+
constructor(dir: string);
|
|
19
|
+
analyze(): AnalyzeResult;
|
|
20
|
+
findComponent(name: string): Promise<typeof ComponentResource>;
|
|
21
|
+
private analyseFile;
|
|
22
|
+
private isPulumiComponent;
|
|
23
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2025-2025, Pulumi Corporation.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
16
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
17
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
18
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
19
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
20
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
21
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
28
|
+
result["default"] = mod;
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
const path = __importStar(require("path"));
|
|
33
|
+
// Use the TypeScript shim which allows us to fallback to a vendored version of
|
|
34
|
+
// TypeScript if the user has not installed it.
|
|
35
|
+
// TODO: we should consider requiring the user to install TypeScript and not
|
|
36
|
+
// rely on the shim. In any case, we should add tests for providers with
|
|
37
|
+
// different versions of TypeScript in their dependencies, to ensure the
|
|
38
|
+
// analyzer code is compatible with all of them.
|
|
39
|
+
const ts = require("../../typescript-shim");
|
|
40
|
+
class Analyzer {
|
|
41
|
+
constructor(dir) {
|
|
42
|
+
this.components = {};
|
|
43
|
+
this.typeDefinitons = {};
|
|
44
|
+
const configPath = `${dir}/tsconfig.json`;
|
|
45
|
+
const config = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
46
|
+
const parsedConfig = ts.parseJsonConfigFileContent(config.config, ts.sys, path.dirname(configPath));
|
|
47
|
+
this.path = dir;
|
|
48
|
+
this.program = ts.createProgram({
|
|
49
|
+
rootNames: parsedConfig.fileNames,
|
|
50
|
+
options: parsedConfig.options,
|
|
51
|
+
});
|
|
52
|
+
this.checker = this.program.getTypeChecker();
|
|
53
|
+
}
|
|
54
|
+
analyze() {
|
|
55
|
+
const sourceFiles = this.program.getSourceFiles();
|
|
56
|
+
for (const sourceFile of sourceFiles) {
|
|
57
|
+
if (sourceFile.fileName.includes("node_modules") || sourceFile.fileName.endsWith(".d.ts")) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
this.analyseFile(sourceFile);
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
components: this.components,
|
|
64
|
+
typeDefinitons: this.typeDefinitons,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
findComponent(name) {
|
|
68
|
+
var _a;
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const sourceFiles = this.program.getSourceFiles();
|
|
71
|
+
for (const sourceFile of sourceFiles) {
|
|
72
|
+
if (sourceFile.fileName.includes("node_modules") || sourceFile.fileName.endsWith(".d.ts")) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
for (const node of sourceFile.statements) {
|
|
76
|
+
if (ts.isClassDeclaration(node) && this.isPulumiComponent(node) && node.name) {
|
|
77
|
+
if (ts.isClassDeclaration(node) && this.isPulumiComponent(node) && ((_a = node.name) === null || _a === void 0 ? void 0 : _a.text) === name) {
|
|
78
|
+
try {
|
|
79
|
+
const module = yield Promise.resolve().then(() => __importStar(require(sourceFile.fileName)));
|
|
80
|
+
return module[name];
|
|
81
|
+
}
|
|
82
|
+
catch (e) {
|
|
83
|
+
throw new Error(`Failed to import component '${name}': ${e}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
throw new Error(`Component '${name}' not found`);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
analyseFile(sourceFile) {
|
|
93
|
+
// We intentionally visit only the top-level nodes, because we only
|
|
94
|
+
// support components defined at the top-level. We have no way to
|
|
95
|
+
// instantiate components defined inside functions or methods.
|
|
96
|
+
sourceFile.forEachChild((node) => {
|
|
97
|
+
if (ts.isClassDeclaration(node) && this.isPulumiComponent(node) && node.name) {
|
|
98
|
+
const componentName = node.name.text;
|
|
99
|
+
this.components[componentName] = {
|
|
100
|
+
name: componentName,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
isPulumiComponent(node) {
|
|
106
|
+
if (!node.heritageClauses) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
return node.heritageClauses.some((clause) => {
|
|
110
|
+
return clause.types.some((clauseNode) => {
|
|
111
|
+
var _a;
|
|
112
|
+
const type = this.checker.getTypeAtLocation(clauseNode);
|
|
113
|
+
const symbol = type.getSymbol();
|
|
114
|
+
const matchesName = (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) === "ComponentResource";
|
|
115
|
+
const sourceFile = (_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0].getSourceFile();
|
|
116
|
+
const matchesSourceFile = (sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.fileName.endsWith("resource.ts")) || (sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.fileName.endsWith("resource.d.ts"));
|
|
117
|
+
return matchesName && matchesSourceFile;
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.Analyzer = Analyzer;
|
|
123
|
+
//# sourceMappingURL=analyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyzer.js","sourceRoot":"","sources":["../../../provider/experimental/analyzer.ts"],"names":[],"mappings":";AAAA,2CAA2C;AAC3C,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;;;;;;;;;;;;;;;;AAKjC,2CAA6B;AAG7B,+EAA+E;AAC/E,+CAA+C;AAC/C,4EAA4E;AAC5E,wEAAwE;AACxE,wEAAwE;AACxE,gDAAgD;AAChD,MAAM,EAAE,GAAsB,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAe/D,MAAa,QAAQ;IAOjB,YAAY,GAAW;QAHf,eAAU,GAAwC,EAAE,CAAC;QACrD,mBAAc,GAAmC,EAAE,CAAC;QAGxD,MAAM,UAAU,GAAG,GAAG,GAAG,gBAAgB,CAAC;QAC1C,MAAM,MAAM,GAAG,EAAE,CAAC,cAAc,CAAC,UAAU,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC9D,MAAM,YAAY,GAAG,EAAE,CAAC,0BAA0B,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;QACpG,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC;YAC5B,SAAS,EAAE,YAAY,CAAC,SAAS;YACjC,OAAO,EAAE,YAAY,CAAC,OAAO;SAChC,CAAC,CAAC;QACH,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,EAA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U,uBAAV,UAAU,CAAE,QAAQ,CAAC,QAAQ,CAAC,aAAa,OAAK,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ,CAAC,QAAQ,CAAC,eAAe,EAAC,CAAC;gBACnG,OAAO,WAAW,IAAI,iBAAiB,CAAC;YAC5C,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAtFD,4BAsFC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./provider";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2025-2025, Pulumi Corporation.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
function __export(m) {
|
|
16
|
+
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
__export(require("./provider"));
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../provider/experimental/index.ts"],"names":[],"mappings":";AAAA,2CAA2C;AAC3C,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;;;AAEjC,gCAA2B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ComponentResourceOptions } from "../../resource";
|
|
2
|
+
import { ConstructResult, Provider } from "../provider";
|
|
3
|
+
import { Inputs } from "../../output";
|
|
4
|
+
export declare class ComponentProvider implements Provider {
|
|
5
|
+
readonly dir: string;
|
|
6
|
+
private packageJSON;
|
|
7
|
+
private path;
|
|
8
|
+
private analyzer;
|
|
9
|
+
version: string;
|
|
10
|
+
static validateResourceType(packageName: string, resourceType: string): void;
|
|
11
|
+
constructor(dir: string);
|
|
12
|
+
getSchema(): Promise<string>;
|
|
13
|
+
construct(name: string, type: string, inputs: Inputs, options: ComponentResourceOptions): Promise<ConstructResult>;
|
|
14
|
+
}
|
|
15
|
+
export declare function componentProviderHost(dirname?: string): Promise<void>;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2025-2025, Pulumi Corporation.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
16
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
17
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
18
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
19
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
20
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
21
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
28
|
+
result["default"] = mod;
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
const fs_1 = require("fs");
|
|
33
|
+
const path = __importStar(require("path"));
|
|
34
|
+
const server_1 = require("../server");
|
|
35
|
+
const schema_1 = require("./schema");
|
|
36
|
+
const analyzer_1 = require("./analyzer");
|
|
37
|
+
class ComponentProvider {
|
|
38
|
+
constructor(dir) {
|
|
39
|
+
this.dir = dir;
|
|
40
|
+
const absDir = path.resolve(dir);
|
|
41
|
+
const packStr = fs_1.readFileSync(`${absDir}/package.json`, { encoding: "utf-8" });
|
|
42
|
+
this.packageJSON = JSON.parse(packStr);
|
|
43
|
+
this.version = this.packageJSON.version;
|
|
44
|
+
this.path = absDir;
|
|
45
|
+
this.analyzer = new analyzer_1.Analyzer(this.path);
|
|
46
|
+
}
|
|
47
|
+
static validateResourceType(packageName, resourceType) {
|
|
48
|
+
const parts = resourceType.split(":");
|
|
49
|
+
if (parts.length !== 3) {
|
|
50
|
+
throw new Error(`Invalid resource type ${resourceType}`);
|
|
51
|
+
}
|
|
52
|
+
if (parts[0] !== packageName) {
|
|
53
|
+
throw new Error(`Invalid package name ${parts[0]}, expected '${packageName}'`);
|
|
54
|
+
}
|
|
55
|
+
// We might want to relax this limitation, but for now we only support the "index" module.
|
|
56
|
+
if (parts[1] !== "index" && parts[1] !== "") {
|
|
57
|
+
throw new Error(`Invalid module '${parts[1]}' in resource type '${resourceType}', expected 'index' or empty string`);
|
|
58
|
+
}
|
|
59
|
+
if (parts[2].length === 0) {
|
|
60
|
+
throw new Error(`Empty resource name in resource type '${resourceType}'`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
getSchema() {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
const { components, typeDefinitons } = this.analyzer.analyze();
|
|
66
|
+
const schema = schema_1.generateSchema(this.packageJSON, components, typeDefinitons);
|
|
67
|
+
return JSON.stringify(schema);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
construct(name, type, inputs, options) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
ComponentProvider.validateResourceType(this.packageJSON.name, type);
|
|
73
|
+
const componentName = type.split(":")[2];
|
|
74
|
+
const ComponentClass = yield this.analyzer.findComponent(componentName);
|
|
75
|
+
// The ComponentResource base class has a 4 argument constructor, but
|
|
76
|
+
// the user defined component has a 3 argument constructor without the
|
|
77
|
+
// typestring.
|
|
78
|
+
// @ts-ignore
|
|
79
|
+
const instance = new ComponentClass(name, inputs, options);
|
|
80
|
+
return {
|
|
81
|
+
urn: instance.urn,
|
|
82
|
+
state: {},
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.ComponentProvider = ComponentProvider;
|
|
88
|
+
function componentProviderHost(dirname) {
|
|
89
|
+
const args = process.argv.slice(2);
|
|
90
|
+
// If dirname is not provided, get it from the call stack
|
|
91
|
+
if (!dirname) {
|
|
92
|
+
// Get the stack trace
|
|
93
|
+
const stack = new Error().stack;
|
|
94
|
+
// Parse the stack to get the caller's file
|
|
95
|
+
// Stack format is like:
|
|
96
|
+
// Error
|
|
97
|
+
// at componentProviderHost (.../src/index.ts:3:16)
|
|
98
|
+
// at Object.<anonymous> (.../caller/index.ts:4:1)
|
|
99
|
+
const callerLine = stack === null || stack === void 0 ? void 0 : stack.split("\n")[2];
|
|
100
|
+
const match = callerLine === null || callerLine === void 0 ? void 0 : callerLine.match(/\((.+):[0-9]+:[0-9]+\)/);
|
|
101
|
+
if (match === null || match === void 0 ? void 0 : match[1]) {
|
|
102
|
+
dirname = path.dirname(match[1]);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
throw new Error("Could not determine caller directory");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const prov = new ComponentProvider(dirname);
|
|
109
|
+
return server_1.main(prov, args);
|
|
110
|
+
}
|
|
111
|
+
exports.componentProviderHost = componentProviderHost;
|
|
112
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../provider/experimental/provider.ts"],"names":[],"mappings":";AAAA,2CAA2C;AAC3C,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;;;;;;;;;;;;;;;;AAEjC,2BAAkC;AAClC,2CAA6B;AAI7B,sCAAiC;AACjC,qCAA0C;AAC1C,yCAAsC;AAEtC,MAAa,iBAAiB;IA0B1B,YAAqB,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;QAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjC,MAAM,OAAO,GAAG,iBAAY,CAAC,GAAG,MAAM,eAAe,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;QAC9E,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;QACnB,IAAI,CAAC,QAAQ,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CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC5B,CAAC;AAtBD,sDAsBC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ComponentDefinition, TypeDefinition } from "./analyzer";
|
|
2
|
+
export declare type PropertyType = "string" | "integer" | "number" | "boolean" | "array" | "object";
|
|
3
|
+
/**
|
|
4
|
+
* https://www.pulumi.com/docs/iac/using-pulumi/pulumi-packages/schema/#property
|
|
5
|
+
*/
|
|
6
|
+
export interface Property {
|
|
7
|
+
type: PropertyType;
|
|
8
|
+
items?: Property;
|
|
9
|
+
additionalProperties?: Property;
|
|
10
|
+
ref?: string;
|
|
11
|
+
plain?: boolean;
|
|
12
|
+
description?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* https://www.pulumi.com/docs/iac/using-pulumi/pulumi-packages/schema/#objecttype
|
|
16
|
+
*/
|
|
17
|
+
export interface ObjectType {
|
|
18
|
+
type: PropertyType;
|
|
19
|
+
description?: string;
|
|
20
|
+
properties?: {
|
|
21
|
+
[key: string]: Property;
|
|
22
|
+
};
|
|
23
|
+
required?: string[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* https://www.pulumi.com/docs/iac/using-pulumi/pulumi-packages/schema/#complextype
|
|
27
|
+
*/
|
|
28
|
+
export interface ComplexType extends ObjectType {
|
|
29
|
+
enum?: string[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* https://www.pulumi.com/docs/iac/using-pulumi/pulumi-packages/schema/#resource
|
|
33
|
+
*/
|
|
34
|
+
export interface Resource extends ObjectType {
|
|
35
|
+
isComponent?: boolean;
|
|
36
|
+
inputProperties?: {
|
|
37
|
+
[key: string]: Property;
|
|
38
|
+
};
|
|
39
|
+
requiredInputs?: string[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* https://www.pulumi.com/docs/iac/using-pulumi/pulumi-packages/schema/#package
|
|
43
|
+
*/
|
|
44
|
+
export interface PackageSpec {
|
|
45
|
+
name: string;
|
|
46
|
+
version?: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
resources: {
|
|
49
|
+
[key: string]: Resource;
|
|
50
|
+
};
|
|
51
|
+
types: {
|
|
52
|
+
[key: string]: ComplexType;
|
|
53
|
+
};
|
|
54
|
+
language?: {
|
|
55
|
+
[key: string]: any;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export declare function generateSchema(packageJSON: Record<string, any>, components: Record<string, ComponentDefinition>, typeDefinitons: Record<string, TypeDefinition>): PackageSpec;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2025-2025, Pulumi Corporation.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
function generateSchema(packageJSON, components, typeDefinitons) {
|
|
17
|
+
const providerName = packageJSON.name;
|
|
18
|
+
const result = {
|
|
19
|
+
name: providerName,
|
|
20
|
+
version: packageJSON.version,
|
|
21
|
+
description: packageJSON.description,
|
|
22
|
+
resources: {},
|
|
23
|
+
types: {},
|
|
24
|
+
language: {
|
|
25
|
+
nodejs: {
|
|
26
|
+
dependencies: {},
|
|
27
|
+
devDependencies: {
|
|
28
|
+
typescript: "^5.0.0",
|
|
29
|
+
},
|
|
30
|
+
respectSchemaVersion: true,
|
|
31
|
+
},
|
|
32
|
+
python: {
|
|
33
|
+
respectSchemaVersion: true,
|
|
34
|
+
},
|
|
35
|
+
csharp: {
|
|
36
|
+
respectSchemaVersion: true,
|
|
37
|
+
},
|
|
38
|
+
java: {
|
|
39
|
+
respectSchemaVersion: true,
|
|
40
|
+
},
|
|
41
|
+
go: {
|
|
42
|
+
respectSchemaVersion: true,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
for (const [name, component] of Object.entries(components)) {
|
|
47
|
+
result.resources[`${providerName}:index:${name}`] = {
|
|
48
|
+
type: "object",
|
|
49
|
+
isComponent: true,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
for (const [name, type] of Object.entries(typeDefinitons)) {
|
|
53
|
+
result.types[`${providerName}:index:${name}`] = {
|
|
54
|
+
type: "object",
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
exports.generateSchema = generateSchema;
|
|
60
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../provider/experimental/schema.ts"],"names":[],"mappings":";AAAA,2CAA2C;AAC3C,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAwDjC,SAAgB,cAAc,CAC1B,WAAgC,EAChC,UAA+C,EAC/C,cAA8C;IAE9C,MAAM,YAAY,GAAG,WAAW,CAAC,IAAI,CAAC;IACtC,MAAM,MAAM,GAAgB;QACxB,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,WAAW,CAAC,OAAO;QAC5B,WAAW,EAAE,WAAW,CAAC,WAAW;QACpC,SAAS,EAAE,EAAE;QACb,KAAK,EAAE,EAAE;QACT,QAAQ,EAAE;YACN,MAAM,EAAE;gBACJ,YAAY,EAAE,EAAE;gBAChB,eAAe,EAAE;oBACb,UAAU,EAAE,QAAQ;iBACvB;gBACD,oBAAoB,EAAE,IAAI;aAC7B;YACD,MAAM,EAAE;gBACJ,oBAAoB,EAAE,IAAI;aAC7B;YACD,MAAM,EAAE;gBACJ,oBAAoB,EAAE,IAAI;aAC7B;YACD,IAAI,EAAE;gBACF,oBAAoB,EAAE,IAAI;aAC7B;YACD,EAAE,EAAE;gBACA,oBAAoB,EAAE,IAAI;aAC7B;SACJ;KACJ,CAAC;IAEF,KAAK,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QACxD,MAAM,CAAC,SAAS,CAAC,GAAG,YAAY,UAAU,IAAI,EAAE,CAAC,GAAG;YAChD,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,IAAI;SACpB,CAAC;KACL;IAED,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE;QACvD,MAAM,CAAC,KAAK,CAAC,GAAG,YAAY,UAAU,IAAI,EAAE,CAAC,GAAG;YAC5C,IAAI,EAAE,QAAQ;SACjB,CAAC;KACL;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AAjDD,wCAiDC"}
|
package/version.js
CHANGED
|
@@ -13,5 +13,5 @@
|
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.version = "3.150.1-alpha.
|
|
16
|
+
exports.version = "3.150.1-alpha.x425a5d7";
|
|
17
17
|
//# sourceMappingURL=version.js.map
|