@cdktn/provider-generator 0.26.0-pre.20 → 0.26.0-pre.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/build/get/generator/models/scope.js +2 -14
  2. package/jest.config.js +0 -1
  3. package/package.json +5 -5
  4. package/package.sh +0 -0
  5. package/src/__tests__/edge-provider-schema/builder.ts +0 -201
  6. package/src/__tests__/edge-provider-schema/cli.ts +0 -51
  7. package/src/__tests__/edge-provider-schema/index.ts +0 -284
  8. package/src/__tests__/edge-provider-schema.test.ts +0 -24
  9. package/src/__tests__/erasable-syntax.test.ts +0 -81
  10. package/src/__tests__/provider.test.ts +0 -208
  11. package/src/get/__tests__/constructs-maker.test.ts +0 -242
  12. package/src/get/__tests__/generator/complex-computed-types.test.ts +0 -28
  13. package/src/get/__tests__/generator/deep-nested-attributes.test.ts +0 -56
  14. package/src/get/__tests__/generator/description-escaping.test.ts +0 -84
  15. package/src/get/__tests__/generator/empty-provider-resources.test.ts +0 -26
  16. package/src/get/__tests__/generator/ephemeral-resources.test.ts +0 -46
  17. package/src/get/__tests__/generator/export-sharding.test.ts +0 -169
  18. package/src/get/__tests__/generator/import-style.test.ts +0 -129
  19. package/src/get/__tests__/generator/module-docs-registry.test.ts +0 -89
  20. package/src/get/__tests__/generator/module-generator.test.ts +0 -528
  21. package/src/get/__tests__/generator/nested-types.test.ts +0 -54
  22. package/src/get/__tests__/generator/provider-functions-name-collision.test.ts +0 -84
  23. package/src/get/__tests__/generator/provider-functions.test.ts +0 -262
  24. package/src/get/__tests__/generator/provider-source-matching.test.ts +0 -84
  25. package/src/get/__tests__/generator/provider.test.ts +0 -59
  26. package/src/get/__tests__/generator/resource-types.test.ts +0 -118
  27. package/src/get/__tests__/generator/skipped-attributes.test.ts +0 -72
  28. package/src/get/__tests__/generator/supported-stored-classes.test.ts +0 -147
  29. package/src/get/__tests__/generator/types.test.ts +0 -686
  30. package/src/get/__tests__/generator/versions-file.test.ts +0 -77
  31. package/src/get/__tests__/generator/write-only.test.ts +0 -71
  32. package/src/get/__tests__/registry-class-invalidation.test.ts +0 -123
  33. package/src/get/__tests__/target-versions.test.ts +0 -249
  34. package/src/get/__tests__/util.ts +0 -80
  35. package/src/get/constructs-maker.ts +0 -991
  36. package/src/get/generator/custom-defaults.ts +0 -494
  37. package/src/get/generator/emitter/attributes-emitter.ts +0 -316
  38. package/src/get/generator/emitter/index.ts +0 -6
  39. package/src/get/generator/emitter/provider-functions-emitter.ts +0 -117
  40. package/src/get/generator/emitter/resource-emitter.ts +0 -330
  41. package/src/get/generator/emitter/struct-emitter.ts +0 -683
  42. package/src/get/generator/loop-detection.ts +0 -81
  43. package/src/get/generator/models/attribute-model.ts +0 -273
  44. package/src/get/generator/models/attribute-type-model.ts +0 -559
  45. package/src/get/generator/models/index.ts +0 -8
  46. package/src/get/generator/models/provider-function-model.ts +0 -872
  47. package/src/get/generator/models/resource-model.ts +0 -206
  48. package/src/get/generator/models/scope.ts +0 -54
  49. package/src/get/generator/models/struct.ts +0 -124
  50. package/src/get/generator/models/supported-stored-classes.ts +0 -88
  51. package/src/get/generator/module-generator.ts +0 -236
  52. package/src/get/generator/provider-generator.ts +0 -451
  53. package/src/get/generator/resource-parser.ts +0 -782
  54. package/src/get/generator/sanitized-comments.ts +0 -49
  55. package/src/get/generator/skipped-attributes.ts +0 -27
  56. package/src/index.ts +0 -40
  57. package/src/util.ts +0 -26
@@ -17,20 +17,8 @@ class Scope {
17
17
  return `${this.baseName}.${attributeName}`;
18
18
  }
19
19
  get baseName() {
20
- // eslint-disable-next-line @typescript-eslint/no-this-alias
21
- let scope = this;
22
- let name = "";
23
- while (scope) {
24
- if (name === "") {
25
- name = scope.name;
26
- }
27
- else {
28
- name = `${scope.name}.${name}`;
29
- }
30
- scope = scope.parent;
31
- }
32
- return name;
20
+ return this.parent ? `${this.parent.baseName}.${this.name}` : this.name;
33
21
  }
34
22
  }
35
23
  exports.Scope = Scope;
36
-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VybiB0aGlzLnBhcmVudCA/IGAke3RoaXMucGFyZW50LmJhc2VOYW1lfS4ke3RoaXMubmFtZX1gIDogdGhpcy5uYW1lO1xuICB9XG59XG4iXX0=
package/jest.config.js CHANGED
@@ -2,7 +2,6 @@
2
2
  * Copyright (c) HashiCorp, Inc.
3
3
  * SPDX-License-Identifier: MPL-2.0
4
4
  */
5
- /* eslint-disable */
6
5
  const { readFileSync } = require('fs');
7
6
 
8
7
  const swcJestConfig = JSON.parse(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdktn/provider-generator",
3
- "version": "0.26.0-pre.20",
3
+ "version": "0.26.0-pre.21",
4
4
  "description": "Exposes API to generate Terraform CDK provider bindings",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -52,15 +52,15 @@
52
52
  ],
53
53
  "license": "MPL-2.0",
54
54
  "dependencies": {
55
+ "@cdktn/commons": "0.26.0-pre.21",
56
+ "@cdktn/provider-schema": "0.26.0-pre.21",
57
+ "cdktn": "0.26.0-pre.21",
55
58
  "codemaker": "1.140.0",
56
59
  "constructs": "10.8.1",
57
60
  "fs-extra": "^11.3.6",
58
61
  "glob": "^13.0.6",
59
62
  "jsii": "~6.0.0",
60
- "jsii-pacmak": "1.140.0",
61
- "@cdktn/commons": "0.26.0-pre.20",
62
- "@cdktn/provider-schema": "0.26.0-pre.20",
63
- "cdktn": "0.26.0-pre.20"
63
+ "jsii-pacmak": "1.140.0"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@types/fs-extra": "11.0.4",
package/package.sh CHANGED
File without changes
@@ -1,201 +0,0 @@
1
- // Copyright (c) HashiCorp, Inc
2
- // SPDX-License-Identifier: MPL-2.0
3
- import {
4
- ProviderSchema,
5
- Schema,
6
- AttributeType,
7
- Block,
8
- FunctionSignature,
9
- } from "@cdktn/commons";
10
-
11
- type ResourceSchema = { [type: string]: Schema };
12
- type FunctionSchema = { [name: string]: FunctionSignature };
13
- export function schema({
14
- name,
15
- provider,
16
- resources = {},
17
- dataSources = {},
18
- ephemeralResources = {},
19
- functions = {},
20
- }: {
21
- name: string;
22
- provider: Schema;
23
- resources: ResourceSchema;
24
- dataSources: ResourceSchema;
25
- ephemeralResources?: ResourceSchema;
26
- functions?: FunctionSchema;
27
- }): ProviderSchema {
28
- return {
29
- format_version: "0.2",
30
- provider_schemas: {
31
- [`registry.terraform.io/cdktf/${name}`]: {
32
- provider: provider,
33
- resource_schemas: resources,
34
- data_source_schemas: dataSources,
35
- ephemeral_resource_schemas: ephemeralResources,
36
- functions: functions,
37
- },
38
- },
39
- };
40
- }
41
-
42
- export class SchemaBuilder {
43
- private schema: Schema;
44
-
45
- constructor() {
46
- this.schema = {
47
- version: 0,
48
- block: {
49
- attributes: {},
50
- block_types: {},
51
- },
52
- };
53
- }
54
-
55
- public attribute({
56
- name,
57
- type,
58
- required = false,
59
- computed = false,
60
- optional = !required,
61
- writeOnly = false,
62
- }: {
63
- name: string;
64
- type: AttributeType;
65
- required?: boolean;
66
- computed?: boolean;
67
- optional?: boolean;
68
- writeOnly?: boolean;
69
- }): SchemaBuilder {
70
- this.schema.block.attributes[name] = {
71
- type,
72
- optional,
73
- computed,
74
- required,
75
- write_only: writeOnly,
76
- };
77
- return this;
78
- }
79
-
80
- public listBlock({
81
- name,
82
- block,
83
- minItems,
84
- maxItems,
85
- }: {
86
- name: string;
87
- block: Block;
88
- minItems: number;
89
- maxItems: number;
90
- }): SchemaBuilder {
91
- this.schema.block.block_types[name] = {
92
- nesting_mode: "list",
93
- block,
94
- min_items: minItems,
95
- max_items: maxItems,
96
- };
97
- return this;
98
- }
99
-
100
- public mapBlock({
101
- name,
102
- block,
103
- }: {
104
- name: string;
105
- block: Block;
106
- }): SchemaBuilder {
107
- this.schema.block.block_types[name] = { nesting_mode: "map", block };
108
- return this;
109
- }
110
-
111
- public setBlock({
112
- name,
113
- block,
114
- }: {
115
- name: string;
116
- block: Block;
117
- }): SchemaBuilder {
118
- this.schema.block.block_types[name] = { nesting_mode: "set", block };
119
- return this;
120
- }
121
- public singleBlock({
122
- name,
123
- block,
124
- }: {
125
- name: string;
126
- block: Block;
127
- }): SchemaBuilder {
128
- this.schema.block.block_types[name] = { nesting_mode: "single", block };
129
- return this;
130
- }
131
-
132
- public build(): Schema {
133
- return this.schema;
134
- }
135
-
136
- public asBlock(): Block {
137
- return this.schema.block;
138
- }
139
-
140
- public addAllPrimitiveTypes({
141
- required,
142
- computed,
143
- prefix = "",
144
- }: {
145
- required: boolean;
146
- computed: boolean;
147
- prefix?: string;
148
- }): SchemaBuilder {
149
- this.attribute({ name: prefix + "str", type: "string", required, computed })
150
- .attribute({ name: prefix + "num", type: "number", required, computed })
151
- .attribute({ name: prefix + "bool", type: "bool", required, computed });
152
-
153
- return this;
154
- }
155
-
156
- public addAllPrimitivePermutations(): SchemaBuilder {
157
- this.addAllPrimitiveTypes({
158
- required: false,
159
- computed: false,
160
- prefix: "opt",
161
- })
162
- .addAllPrimitiveTypes({ required: true, computed: false, prefix: "req" })
163
- .addAllPrimitiveTypes({
164
- required: false,
165
- computed: true,
166
- prefix: "computed",
167
- });
168
- return this;
169
- }
170
-
171
- public addAllPrimitiveListTypes({
172
- required,
173
- computed,
174
- prefix = "",
175
- }: {
176
- required: boolean;
177
- computed: boolean;
178
- prefix?: string;
179
- }): SchemaBuilder {
180
- this.attribute({
181
- name: prefix + "strList",
182
- type: ["list", "string"],
183
- required,
184
- computed,
185
- })
186
- .attribute({
187
- name: prefix + "numList",
188
- type: ["list", "number"],
189
- required,
190
- computed,
191
- })
192
- .attribute({
193
- name: prefix + "boolList",
194
- type: ["list", "bool"],
195
- required,
196
- computed,
197
- });
198
-
199
- return this;
200
- }
201
- }
@@ -1,51 +0,0 @@
1
- // Copyright (c) HashiCorp, Inc
2
- // SPDX-License-Identifier: MPL-2.0
3
- import * as path from "path";
4
- import * as fs from "fs-extra";
5
- import { edgeSchema } from ".";
6
- import { generateProviderBindingsFromSchema } from "../..";
7
-
8
- // This script builds the schema for the edge provider into the given directory for all languages.
9
- const args = process.argv.slice(2);
10
- const targetPath = args[0];
11
-
12
- if (!targetPath) {
13
- console.error("No target path specified");
14
- process.exit(1);
15
- }
16
-
17
- // Clear / Create path
18
- fs.mkdirpSync(targetPath);
19
- fs.emptyDirSync(targetPath);
20
-
21
- // Static require.resolve calls so knip / pnpm strict isolation can see the deps.
22
- const deps = [
23
- path.dirname(require.resolve("@types/node/package.json")),
24
- path.dirname(require.resolve("constructs/package.json")),
25
- path.dirname(require.resolve("cdktn/package.json")),
26
- ];
27
-
28
- (async () => {
29
- await generateProviderBindingsFromSchema(targetPath, edgeSchema, {
30
- entrypoint: path.join("providers", "edge", "index.ts"),
31
- deps,
32
- moduleKey: "edge",
33
- python: {
34
- outdir: path.resolve(targetPath, "python"),
35
- moduleName: "edge",
36
- },
37
- java: {
38
- outdir: path.resolve(targetPath, "java"),
39
- package: `imports.edgeprovider`,
40
- },
41
- csharp: {
42
- outdir: path.resolve(targetPath, "csharp"),
43
- namespace: "Providers.Edge",
44
- },
45
- golang: {
46
- outdir: path.resolve(targetPath, "go"),
47
- moduleName: "cdk.tf/go/stack/generated/hashicorp",
48
- packageName: "edge",
49
- },
50
- });
51
- })();
@@ -1,284 +0,0 @@
1
- // Copyright (c) HashiCorp, Inc
2
- // SPDX-License-Identifier: MPL-2.0
3
- import { ProviderSchema, FunctionSignature } from "@cdktn/commons";
4
- import { schema, SchemaBuilder as S } from "./builder";
5
-
6
- const required_attribute_resource = new S()
7
- .addAllPrimitiveTypes({ required: true, computed: false })
8
- .addAllPrimitiveListTypes({ required: true, computed: false })
9
- .build();
10
-
11
- const optional_attribute_resource = new S()
12
- .addAllPrimitiveTypes({ required: false, computed: false })
13
- .addAllPrimitiveListTypes({ required: false, computed: false })
14
- // Write-only attribute (RFC-04 / protocol v6): exercises the deprecated
15
- // getter + the resolve-time `markWriteOnlyAttribute` wrapping in
16
- // synthesizeAttributes()/synthesizeHclAttributes() on an existing managed
17
- // resource. Left optional so no existing usage of
18
- // OptionalAttributeResource across the edge test suite needs updating
19
- // (and so it also generates a reset method).
20
- .attribute({
21
- name: "secretWo",
22
- type: "string",
23
- required: false,
24
- computed: false,
25
- writeOnly: true,
26
- })
27
- .build();
28
-
29
- const optional_computed_attribute_resource = new S()
30
- .addAllPrimitiveTypes({ required: false, computed: true })
31
- .addAllPrimitiveListTypes({ required: false, computed: true })
32
- .build();
33
-
34
- const list_block_resource = new S()
35
- .listBlock({
36
- name: "opt",
37
- block: new S().addAllPrimitivePermutations().asBlock(),
38
- minItems: 0,
39
- maxItems: 42,
40
- })
41
- .listBlock({
42
- name: "req",
43
- block: new S().addAllPrimitivePermutations().asBlock(),
44
- minItems: 1,
45
- maxItems: 42,
46
- })
47
- .listBlock({
48
- name: "singleopt",
49
- block: new S().addAllPrimitivePermutations().asBlock(),
50
- minItems: 0,
51
- maxItems: 1,
52
- })
53
- .listBlock({
54
- name: "singlereq",
55
- block: new S().addAllPrimitivePermutations().asBlock(),
56
- minItems: 1,
57
- maxItems: 1,
58
- })
59
- .listBlock({
60
- name: "singleComputedBlock",
61
- block: new S()
62
- .attribute({
63
- computed: true,
64
- name: "computed",
65
- type: "string",
66
- required: false,
67
- optional: false,
68
- })
69
- .attribute({
70
- computed: false,
71
- name: "configured",
72
- type: "string",
73
- required: false,
74
- })
75
- .asBlock(),
76
- minItems: 0,
77
- maxItems: 1,
78
- })
79
- .attribute({
80
- name: "computedListOfObject",
81
- type: [
82
- "list",
83
- [
84
- "object",
85
- {
86
- str: "string",
87
- },
88
- ],
89
- ],
90
- computed: true,
91
- optional: false,
92
- })
93
- .attribute({
94
- name: "computedListOfMapOfObject",
95
- type: [
96
- "list",
97
- [
98
- "map",
99
- [
100
- "object",
101
- {
102
- str: "string",
103
- other: "string",
104
- },
105
- ],
106
- ],
107
- ],
108
- computed: true,
109
- optional: false,
110
- })
111
- .build();
112
-
113
- const map_list_resource = new S()
114
- .attribute({
115
- name: "mapListOfObject",
116
- type: [
117
- "map",
118
- [
119
- "list",
120
- [
121
- "object",
122
- {
123
- hello: "string",
124
- },
125
- ],
126
- ],
127
- ],
128
- computed: false,
129
- optional: false,
130
- })
131
- .build();
132
-
133
- const map_resource = new S()
134
- .attribute({
135
- name: "optMap",
136
- type: ["map", "string"],
137
- required: false,
138
- computed: false,
139
- })
140
- .attribute({
141
- name: "reqMap",
142
- type: ["map", "bool"],
143
- required: true,
144
- computed: false,
145
- })
146
- .attribute({
147
- name: "computedMap",
148
- type: ["map", "number"],
149
- required: false,
150
- computed: true,
151
- })
152
- .build();
153
-
154
- const set_block_resource = new S()
155
- .setBlock({
156
- name: "set",
157
- block: new S().addAllPrimitivePermutations().asBlock(),
158
- })
159
- .build();
160
-
161
- // A modest ephemeral resource (plugin protocol v6 / RFC-04): a required
162
- // string, an optional number, a computed attribute, and a nested single
163
- // block - consistent with the primitive/nested-block conventions used by
164
- // the resources above.
165
- const cached_secret = new S()
166
- .attribute({ name: "str", type: "string", required: true })
167
- .attribute({ name: "num", type: "number", required: false })
168
- .attribute({
169
- name: "computedStr",
170
- type: "string",
171
- computed: true,
172
- optional: false,
173
- })
174
- .singleBlock({
175
- name: "nested",
176
- block: new S()
177
- .attribute({ name: "str", type: "string", required: false })
178
- .attribute({ name: "num", type: "number", required: false })
179
- .asBlock(),
180
- })
181
- .build();
182
-
183
- // Provider-defined functions (Terraform >=1.8 / protocol v6), each
184
- // exercising a distinct generator branch of `provider-function-model.ts`.
185
- // Reuses shapes from `provider-functions-synthetic.test.fixture.json` where
186
- // sensible, renamed to fit the edge fixture's naming.
187
- const functions: { [name: string]: FunctionSignature } = {
188
- // Simple string -> string function.
189
- greet: {
190
- description: "Returns a friendly greeting for the given name.",
191
- summary: "Greet a name",
192
- return_type: "string",
193
- parameters: [{ name: "name", type: "string" }],
194
- },
195
- // Nullable TRAILING fixed param: becomes jsii-optional.
196
- greet_with_title: {
197
- description: "Greets the given name, optionally with a title.",
198
- summary: "Greet with an optional title",
199
- return_type: "string",
200
- parameters: [
201
- { name: "name", type: "string" },
202
- { name: "title", type: "string", is_nullable: true },
203
- ],
204
- },
205
- // Nullable MID-POSITION fixed param followed by a required param: stays
206
- // positional, widens to `any` so a caller can still pass an explicit null.
207
- join_prefixed: {
208
- description: "Joins a possibly-null prefix with a required suffix.",
209
- summary: "Join with a nullable prefix",
210
- return_type: "string",
211
- parameters: [
212
- { name: "prefix", type: "string", is_nullable: true },
213
- { name: "suffix", type: "string" },
214
- ],
215
- },
216
- // Nullable VARIADIC param: rest parameter widens to `any[]`.
217
- describe_items: {
218
- description: "Joins a label with any number of possibly-null items.",
219
- summary: "Describe items with a label",
220
- return_type: "string",
221
- parameters: [{ name: "label", type: "string" }],
222
- variadic_parameter: { name: "items", type: "string", is_nullable: true },
223
- },
224
- // Variadic of bool: union element type -> Array<boolean | IResolvable>
225
- // rest param.
226
- all_true: {
227
- description: "Returns true if every given flag is true.",
228
- summary: "All flags true",
229
- return_type: "bool",
230
- variadic_parameter: { name: "flags", type: "bool" },
231
- },
232
- // deprecation_message present (Terraform >=1.8 only, see FunctionSignature
233
- // docstring) -> surfaced as an `@deprecated` JSDoc tag.
234
- legacy_greet: {
235
- description:
236
- "A deprecated greeting helper kept for backwards compatibility.",
237
- summary: "Legacy greet",
238
- deprecation_message: "Use greet instead.",
239
- return_type: "string",
240
- parameters: [{ name: "name", type: "string" }],
241
- },
242
- // Returns ["object", {...}].
243
- build_info: {
244
- description:
245
- "Returns an object describing the build that produced the given seed.",
246
- summary: "Build info",
247
- return_type: ["object", { version: "string", revision: "string" }],
248
- parameters: [{ name: "seed", type: "string" }],
249
- },
250
- // Returns ["list", "number"].
251
- list_squares: {
252
- description:
253
- "Returns the squares of the numbers from 1 to the given count.",
254
- summary: "List squares",
255
- return_type: ["list", "number"],
256
- parameters: [{ name: "count", type: "number" }],
257
- },
258
- // A ["map", "string"] param.
259
- render_tags: {
260
- description: "Renders the given map of string tags as a single string.",
261
- summary: "Render tags",
262
- return_type: "string",
263
- parameters: [{ name: "tags", type: ["map", "string"] }],
264
- },
265
- };
266
-
267
- export const edgeSchema: ProviderSchema = schema({
268
- name: "edge",
269
- provider: new S().addAllPrimitivePermutations().build(),
270
- resources: {
271
- required_attribute_resource,
272
- optional_attribute_resource,
273
- optional_computed_attribute_resource,
274
- list_block_resource,
275
- map_resource,
276
- set_block_resource,
277
- map_list_resource,
278
- },
279
- dataSources: {},
280
- ephemeralResources: {
281
- cached_secret,
282
- },
283
- functions,
284
- });
@@ -1,24 +0,0 @@
1
- // Copyright (c) HashiCorp, Inc
2
- // SPDX-License-Identifier: MPL-2.0
3
- import * as fs from "fs-extra";
4
- import * as path from "path";
5
- import { generateProviderBindingsFromSchema } from "..";
6
- import { mkdtemp } from "@cdktn/commons";
7
- import { edgeSchema } from "./edge-provider-schema";
8
-
9
- describe("Edge Provider Schema", () => {
10
- it("compiles to Typescript", async () => {
11
- return mkdtemp(async (dir) => {
12
- await generateProviderBindingsFromSchema(dir, edgeSchema);
13
-
14
- fs.readdirSync(path.join(dir, "providers", "edge")).forEach((file) => {
15
- if (!file.endsWith(".ts")) {
16
- return;
17
- }
18
- expect(
19
- fs.readFileSync(path.join(dir, "providers", "edge", file), "utf8"),
20
- ).toMatchSnapshot(file);
21
- });
22
- });
23
- });
24
- });