@prisma/ts-builders 6.6.0-dev.100

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 (171) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +5 -0
  3. package/dist/AnyDeclarationBuilder.d.ts +6 -0
  4. package/dist/AnyDeclarationBuilder.js +16 -0
  5. package/dist/AnyDeclarationBuilder.mjs +0 -0
  6. package/dist/ArraySpread.d.ts +8 -0
  7. package/dist/ArraySpread.js +42 -0
  8. package/dist/ArraySpread.mjs +17 -0
  9. package/dist/ArrayType.d.ts +8 -0
  10. package/dist/ArrayType.js +43 -0
  11. package/dist/ArrayType.mjs +18 -0
  12. package/dist/ArrayType.test.d.ts +1 -0
  13. package/dist/ArrayType.test.js +24 -0
  14. package/dist/ArrayType.test.mjs +23 -0
  15. package/dist/BasicBuilder.d.ts +4 -0
  16. package/dist/BasicBuilder.js +16 -0
  17. package/dist/BasicBuilder.mjs +0 -0
  18. package/dist/Class.d.ts +22 -0
  19. package/dist/Class.js +79 -0
  20. package/dist/Class.mjs +54 -0
  21. package/dist/Class.test.d.ts +1 -0
  22. package/dist/Class.test.js +56 -0
  23. package/dist/Class.test.mjs +55 -0
  24. package/dist/ConstDeclaration.d.ts +16 -0
  25. package/dist/ConstDeclaration.js +60 -0
  26. package/dist/ConstDeclaration.mjs +35 -0
  27. package/dist/ConstDeclaration.test.d.ts +1 -0
  28. package/dist/ConstDeclaration.test.js +19 -0
  29. package/dist/ConstDeclaration.test.mjs +18 -0
  30. package/dist/DocComment.d.ts +11 -0
  31. package/dist/DocComment.js +101 -0
  32. package/dist/DocComment.mjs +76 -0
  33. package/dist/DocComment.test.d.ts +1 -0
  34. package/dist/DocComment.test.js +80 -0
  35. package/dist/DocComment.test.mjs +79 -0
  36. package/dist/Export.d.ts +12 -0
  37. package/dist/Export.js +48 -0
  38. package/dist/Export.mjs +23 -0
  39. package/dist/ExportFrom.d.ts +34 -0
  40. package/dist/ExportFrom.js +106 -0
  41. package/dist/ExportFrom.mjs +77 -0
  42. package/dist/ExportFrom.test.d.ts +1 -0
  43. package/dist/ExportFrom.test.js +25 -0
  44. package/dist/ExportFrom.test.mjs +24 -0
  45. package/dist/File.d.ts +15 -0
  46. package/dist/File.js +57 -0
  47. package/dist/File.mjs +32 -0
  48. package/dist/FunctionCall.d.ts +9 -0
  49. package/dist/FunctionCall.js +49 -0
  50. package/dist/FunctionCall.mjs +24 -0
  51. package/dist/FunctionType.d.ts +17 -0
  52. package/dist/FunctionType.js +60 -0
  53. package/dist/FunctionType.mjs +35 -0
  54. package/dist/FunctionType.test.d.ts +1 -0
  55. package/dist/FunctionType.test.js +32 -0
  56. package/dist/FunctionType.test.mjs +31 -0
  57. package/dist/GenericParameter.d.ts +15 -0
  58. package/dist/GenericParameter.js +60 -0
  59. package/dist/GenericParameter.mjs +35 -0
  60. package/dist/GenericParameter.test.d.ts +1 -0
  61. package/dist/GenericParameter.test.js +19 -0
  62. package/dist/GenericParameter.test.mjs +18 -0
  63. package/dist/Import.d.ts +38 -0
  64. package/dist/Import.js +127 -0
  65. package/dist/Import.mjs +98 -0
  66. package/dist/Import.test.d.ts +1 -0
  67. package/dist/Import.test.js +33 -0
  68. package/dist/Import.test.mjs +32 -0
  69. package/dist/Interface.d.ts +22 -0
  70. package/dist/Interface.js +79 -0
  71. package/dist/Interface.mjs +54 -0
  72. package/dist/Interface.test.d.ts +1 -0
  73. package/dist/Interface.test.js +56 -0
  74. package/dist/Interface.test.mjs +55 -0
  75. package/dist/KeyType.d.ts +9 -0
  76. package/dist/KeyType.js +44 -0
  77. package/dist/KeyType.mjs +19 -0
  78. package/dist/KeyType.test.d.ts +1 -0
  79. package/dist/KeyType.test.js +28 -0
  80. package/dist/KeyType.test.mjs +27 -0
  81. package/dist/KeyofType.d.ts +8 -0
  82. package/dist/KeyofType.js +47 -0
  83. package/dist/KeyofType.mjs +22 -0
  84. package/dist/KeyofType.test.d.ts +1 -0
  85. package/dist/KeyofType.test.js +28 -0
  86. package/dist/KeyofType.test.mjs +27 -0
  87. package/dist/Method.d.ts +20 -0
  88. package/dist/Method.js +75 -0
  89. package/dist/Method.mjs +50 -0
  90. package/dist/Method.test.d.ts +1 -0
  91. package/dist/Method.test.js +43 -0
  92. package/dist/Method.test.mjs +42 -0
  93. package/dist/NamedType.d.ts +10 -0
  94. package/dist/NamedType.js +50 -0
  95. package/dist/NamedType.mjs +25 -0
  96. package/dist/NamedType.test.d.ts +1 -0
  97. package/dist/NamedType.test.js +15 -0
  98. package/dist/NamedType.test.mjs +14 -0
  99. package/dist/NamedValue.d.ts +8 -0
  100. package/dist/NamedValue.js +43 -0
  101. package/dist/NamedValue.mjs +18 -0
  102. package/dist/NamespaceDeclaration.d.ts +13 -0
  103. package/dist/NamespaceDeclaration.js +48 -0
  104. package/dist/NamespaceDeclaration.mjs +23 -0
  105. package/dist/ObjectType.d.ts +18 -0
  106. package/dist/ObjectType.js +71 -0
  107. package/dist/ObjectType.mjs +46 -0
  108. package/dist/ObjectType.test.d.ts +1 -0
  109. package/dist/ObjectType.test.js +32 -0
  110. package/dist/ObjectType.test.mjs +31 -0
  111. package/dist/Parameter.d.ts +12 -0
  112. package/dist/Parameter.js +50 -0
  113. package/dist/Parameter.mjs +25 -0
  114. package/dist/Parameter.test.d.ts +1 -0
  115. package/dist/Parameter.test.js +14 -0
  116. package/dist/Parameter.test.mjs +13 -0
  117. package/dist/PrimitiveType.d.ts +18 -0
  118. package/dist/PrimitiveType.js +70 -0
  119. package/dist/PrimitiveType.mjs +35 -0
  120. package/dist/Property.d.ts +18 -0
  121. package/dist/Property.js +75 -0
  122. package/dist/Property.mjs +50 -0
  123. package/dist/Property.test.d.ts +1 -0
  124. package/dist/Property.test.js +37 -0
  125. package/dist/Property.test.mjs +36 -0
  126. package/dist/StringLiteralType.d.ts +15 -0
  127. package/dist/StringLiteralType.js +58 -0
  128. package/dist/StringLiteralType.mjs +32 -0
  129. package/dist/TupleType.d.ts +17 -0
  130. package/dist/TupleType.js +69 -0
  131. package/dist/TupleType.mjs +42 -0
  132. package/dist/TupleType.test.d.ts +1 -0
  133. package/dist/TupleType.test.js +21 -0
  134. package/dist/TupleType.test.mjs +20 -0
  135. package/dist/TypeBuilder.d.ts +11 -0
  136. package/dist/TypeBuilder.js +47 -0
  137. package/dist/TypeBuilder.mjs +23 -0
  138. package/dist/TypeDeclaration.d.ts +17 -0
  139. package/dist/TypeDeclaration.js +62 -0
  140. package/dist/TypeDeclaration.mjs +37 -0
  141. package/dist/TypeDeclaration.test.d.ts +1 -0
  142. package/dist/TypeDeclaration.test.js +28 -0
  143. package/dist/TypeDeclaration.test.mjs +27 -0
  144. package/dist/UnionType.d.ts +13 -0
  145. package/dist/UnionType.js +74 -0
  146. package/dist/UnionType.mjs +49 -0
  147. package/dist/UnionType.test.d.ts +1 -0
  148. package/dist/UnionType.test.js +28 -0
  149. package/dist/UnionType.test.mjs +27 -0
  150. package/dist/ValueBuilder.d.ts +12 -0
  151. package/dist/ValueBuilder.js +46 -0
  152. package/dist/ValueBuilder.mjs +21 -0
  153. package/dist/WellKnownSymbol.d.ts +9 -0
  154. package/dist/WellKnownSymbol.js +43 -0
  155. package/dist/WellKnownSymbol.mjs +17 -0
  156. package/dist/Writer.d.ts +94 -0
  157. package/dist/Writer.js +175 -0
  158. package/dist/Writer.mjs +150 -0
  159. package/dist/Writer.test.d.ts +1 -0
  160. package/dist/Writer.test.js +100 -0
  161. package/dist/Writer.test.mjs +99 -0
  162. package/dist/helpers.d.ts +3 -0
  163. package/dist/helpers.js +31 -0
  164. package/dist/helpers.mjs +7 -0
  165. package/dist/index.d.ts +35 -0
  166. package/dist/index.js +90 -0
  167. package/dist/index.mjs +35 -0
  168. package/dist/stringify.d.ts +7 -0
  169. package/dist/stringify.js +44 -0
  170. package/dist/stringify.mjs +20 -0
  171. package/package.json +41 -0
@@ -0,0 +1,15 @@
1
+ import { BasicBuilder } from './BasicBuilder';
2
+ import { NamedType } from './NamedType';
3
+ import { TypeBuilder } from './TypeBuilder';
4
+ import { Writer } from './Writer';
5
+ export declare class GenericParameter implements BasicBuilder {
6
+ private name;
7
+ private extendedType?;
8
+ private defaultType?;
9
+ constructor(name: string);
10
+ extends(type: TypeBuilder): this;
11
+ default(type: TypeBuilder): this;
12
+ toArgument(): NamedType;
13
+ write(writer: Writer): void;
14
+ }
15
+ export declare function genericParameter(name: string): GenericParameter;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var GenericParameter_exports = {};
20
+ __export(GenericParameter_exports, {
21
+ GenericParameter: () => GenericParameter,
22
+ genericParameter: () => genericParameter
23
+ });
24
+ module.exports = __toCommonJS(GenericParameter_exports);
25
+ var import_NamedType = require("./NamedType");
26
+ class GenericParameter {
27
+ constructor(name) {
28
+ this.name = name;
29
+ }
30
+ extendedType;
31
+ defaultType;
32
+ extends(type) {
33
+ this.extendedType = type;
34
+ return this;
35
+ }
36
+ default(type) {
37
+ this.defaultType = type;
38
+ return this;
39
+ }
40
+ toArgument() {
41
+ return new import_NamedType.NamedType(this.name);
42
+ }
43
+ write(writer) {
44
+ writer.write(this.name);
45
+ if (this.extendedType) {
46
+ writer.write(" extends ").write(this.extendedType);
47
+ }
48
+ if (this.defaultType) {
49
+ writer.write(" = ").write(this.defaultType);
50
+ }
51
+ }
52
+ }
53
+ function genericParameter(name) {
54
+ return new GenericParameter(name);
55
+ }
56
+ // Annotate the CommonJS export names for ESM import in node:
57
+ 0 && (module.exports = {
58
+ GenericParameter,
59
+ genericParameter
60
+ });
@@ -0,0 +1,35 @@
1
+ import { NamedType } from "./NamedType";
2
+ class GenericParameter {
3
+ constructor(name) {
4
+ this.name = name;
5
+ }
6
+ extendedType;
7
+ defaultType;
8
+ extends(type) {
9
+ this.extendedType = type;
10
+ return this;
11
+ }
12
+ default(type) {
13
+ this.defaultType = type;
14
+ return this;
15
+ }
16
+ toArgument() {
17
+ return new NamedType(this.name);
18
+ }
19
+ write(writer) {
20
+ writer.write(this.name);
21
+ if (this.extendedType) {
22
+ writer.write(" extends ").write(this.extendedType);
23
+ }
24
+ if (this.defaultType) {
25
+ writer.write(" = ").write(this.defaultType);
26
+ }
27
+ }
28
+ }
29
+ function genericParameter(name) {
30
+ return new GenericParameter(name);
31
+ }
32
+ export {
33
+ GenericParameter,
34
+ genericParameter
35
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var import_vitest = require("vitest");
3
+ var import_GenericParameter = require("./GenericParameter");
4
+ var import_NamedType = require("./NamedType");
5
+ var import_stringify = require("./stringify");
6
+ const A = (0, import_NamedType.namedType)("A");
7
+ const B = (0, import_NamedType.namedType)("B");
8
+ (0, import_vitest.test)("name only", () => {
9
+ (0, import_vitest.expect)((0, import_stringify.stringify)((0, import_GenericParameter.genericParameter)("T"))).toMatchInlineSnapshot(`"T"`);
10
+ });
11
+ (0, import_vitest.test)("with extends", () => {
12
+ (0, import_vitest.expect)((0, import_stringify.stringify)((0, import_GenericParameter.genericParameter)("T").extends(A))).toMatchInlineSnapshot(`"T extends A"`);
13
+ });
14
+ (0, import_vitest.test)("with default", () => {
15
+ (0, import_vitest.expect)((0, import_stringify.stringify)((0, import_GenericParameter.genericParameter)("T").default(B))).toMatchInlineSnapshot(`"T = B"`);
16
+ });
17
+ (0, import_vitest.test)("with extends + default", () => {
18
+ (0, import_vitest.expect)((0, import_stringify.stringify)((0, import_GenericParameter.genericParameter)("T").extends(A).default(B))).toMatchInlineSnapshot(`"T extends A = B"`);
19
+ });
@@ -0,0 +1,18 @@
1
+ import { expect, test } from "vitest";
2
+ import { genericParameter } from "./GenericParameter";
3
+ import { namedType } from "./NamedType";
4
+ import { stringify } from "./stringify";
5
+ const A = namedType("A");
6
+ const B = namedType("B");
7
+ test("name only", () => {
8
+ expect(stringify(genericParameter("T"))).toMatchInlineSnapshot(`"T"`);
9
+ });
10
+ test("with extends", () => {
11
+ expect(stringify(genericParameter("T").extends(A))).toMatchInlineSnapshot(`"T extends A"`);
12
+ });
13
+ test("with default", () => {
14
+ expect(stringify(genericParameter("T").default(B))).toMatchInlineSnapshot(`"T = B"`);
15
+ });
16
+ test("with extends + default", () => {
17
+ expect(stringify(genericParameter("T").extends(A).default(B))).toMatchInlineSnapshot(`"T extends A = B"`);
18
+ });
@@ -0,0 +1,38 @@
1
+ import { BasicBuilder } from './BasicBuilder';
2
+ import { Writer } from './Writer';
3
+ export type Import = NamespaceImport | BindingsImport | ModuleImport;
4
+ export declare class NamespaceImport implements BasicBuilder {
5
+ readonly alias: string;
6
+ readonly from: string;
7
+ constructor(alias: string, from: string);
8
+ write(writer: Writer<undefined>): void;
9
+ }
10
+ export declare class BindingsImport implements BasicBuilder {
11
+ readonly from: string;
12
+ private defaultImport;
13
+ private namedImports;
14
+ constructor(from: string);
15
+ default(name: string): this;
16
+ named(namedImport: string | NamedImport): this;
17
+ write(writer: Writer): void;
18
+ private hasNamedImports;
19
+ }
20
+ export declare class NamedImport implements BasicBuilder {
21
+ readonly name: string;
22
+ private alias;
23
+ private type;
24
+ constructor(name: string);
25
+ as(alias: string): this;
26
+ typeOnly(): this;
27
+ write(writer: Writer): void;
28
+ }
29
+ export declare class ModuleImport implements BasicBuilder {
30
+ readonly from: string;
31
+ constructor(from: string);
32
+ asNamespace(alias: string): NamespaceImport;
33
+ default(alias: string): BindingsImport;
34
+ named(namedImport: string | NamedImport): BindingsImport;
35
+ write(writer: Writer): void;
36
+ }
37
+ export declare function moduleImport(from: string): ModuleImport;
38
+ export declare function namedImport(name: string): NamedImport;
package/dist/Import.js ADDED
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var Import_exports = {};
20
+ __export(Import_exports, {
21
+ BindingsImport: () => BindingsImport,
22
+ ModuleImport: () => ModuleImport,
23
+ NamedImport: () => NamedImport,
24
+ NamespaceImport: () => NamespaceImport,
25
+ moduleImport: () => moduleImport,
26
+ namedImport: () => namedImport
27
+ });
28
+ module.exports = __toCommonJS(Import_exports);
29
+ class NamespaceImport {
30
+ constructor(alias, from) {
31
+ this.alias = alias;
32
+ this.from = from;
33
+ }
34
+ write(writer) {
35
+ writer.write("import * as ").write(this.alias).write(` from "${this.from}"`);
36
+ }
37
+ }
38
+ class BindingsImport {
39
+ constructor(from) {
40
+ this.from = from;
41
+ }
42
+ defaultImport;
43
+ namedImports = [];
44
+ default(name) {
45
+ this.defaultImport = name;
46
+ return this;
47
+ }
48
+ named(namedImport2) {
49
+ if (typeof namedImport2 === "string") {
50
+ namedImport2 = new NamedImport(namedImport2);
51
+ }
52
+ this.namedImports.push(namedImport2);
53
+ return this;
54
+ }
55
+ write(writer) {
56
+ writer.write("import ");
57
+ if (this.defaultImport) {
58
+ writer.write(this.defaultImport);
59
+ if (this.hasNamedImports()) {
60
+ writer.write(", ");
61
+ }
62
+ }
63
+ if (this.hasNamedImports()) {
64
+ writer.write("{ ").writeJoined(", ", this.namedImports).write(" }");
65
+ }
66
+ writer.write(` from "${this.from}"`);
67
+ }
68
+ hasNamedImports() {
69
+ return this.namedImports.length > 0;
70
+ }
71
+ }
72
+ class NamedImport {
73
+ constructor(name) {
74
+ this.name = name;
75
+ }
76
+ alias;
77
+ type = false;
78
+ as(alias) {
79
+ this.alias = alias;
80
+ return this;
81
+ }
82
+ typeOnly() {
83
+ this.type = true;
84
+ return this;
85
+ }
86
+ write(writer) {
87
+ if (this.type) {
88
+ writer.write("type ");
89
+ }
90
+ writer.write(this.name);
91
+ if (this.alias) {
92
+ writer.write(" as ").write(this.alias);
93
+ }
94
+ }
95
+ }
96
+ class ModuleImport {
97
+ constructor(from) {
98
+ this.from = from;
99
+ }
100
+ asNamespace(alias) {
101
+ return new NamespaceImport(alias, this.from);
102
+ }
103
+ default(alias) {
104
+ return new BindingsImport(this.from).default(alias);
105
+ }
106
+ named(namedImport2) {
107
+ return new BindingsImport(this.from).named(namedImport2);
108
+ }
109
+ write(writer) {
110
+ writer.write("import ").write(`"${this.from}"`);
111
+ }
112
+ }
113
+ function moduleImport(from) {
114
+ return new ModuleImport(from);
115
+ }
116
+ function namedImport(name) {
117
+ return new NamedImport(name);
118
+ }
119
+ // Annotate the CommonJS export names for ESM import in node:
120
+ 0 && (module.exports = {
121
+ BindingsImport,
122
+ ModuleImport,
123
+ NamedImport,
124
+ NamespaceImport,
125
+ moduleImport,
126
+ namedImport
127
+ });
@@ -0,0 +1,98 @@
1
+ class NamespaceImport {
2
+ constructor(alias, from) {
3
+ this.alias = alias;
4
+ this.from = from;
5
+ }
6
+ write(writer) {
7
+ writer.write("import * as ").write(this.alias).write(` from "${this.from}"`);
8
+ }
9
+ }
10
+ class BindingsImport {
11
+ constructor(from) {
12
+ this.from = from;
13
+ }
14
+ defaultImport;
15
+ namedImports = [];
16
+ default(name) {
17
+ this.defaultImport = name;
18
+ return this;
19
+ }
20
+ named(namedImport2) {
21
+ if (typeof namedImport2 === "string") {
22
+ namedImport2 = new NamedImport(namedImport2);
23
+ }
24
+ this.namedImports.push(namedImport2);
25
+ return this;
26
+ }
27
+ write(writer) {
28
+ writer.write("import ");
29
+ if (this.defaultImport) {
30
+ writer.write(this.defaultImport);
31
+ if (this.hasNamedImports()) {
32
+ writer.write(", ");
33
+ }
34
+ }
35
+ if (this.hasNamedImports()) {
36
+ writer.write("{ ").writeJoined(", ", this.namedImports).write(" }");
37
+ }
38
+ writer.write(` from "${this.from}"`);
39
+ }
40
+ hasNamedImports() {
41
+ return this.namedImports.length > 0;
42
+ }
43
+ }
44
+ class NamedImport {
45
+ constructor(name) {
46
+ this.name = name;
47
+ }
48
+ alias;
49
+ type = false;
50
+ as(alias) {
51
+ this.alias = alias;
52
+ return this;
53
+ }
54
+ typeOnly() {
55
+ this.type = true;
56
+ return this;
57
+ }
58
+ write(writer) {
59
+ if (this.type) {
60
+ writer.write("type ");
61
+ }
62
+ writer.write(this.name);
63
+ if (this.alias) {
64
+ writer.write(" as ").write(this.alias);
65
+ }
66
+ }
67
+ }
68
+ class ModuleImport {
69
+ constructor(from) {
70
+ this.from = from;
71
+ }
72
+ asNamespace(alias) {
73
+ return new NamespaceImport(alias, this.from);
74
+ }
75
+ default(alias) {
76
+ return new BindingsImport(this.from).default(alias);
77
+ }
78
+ named(namedImport2) {
79
+ return new BindingsImport(this.from).named(namedImport2);
80
+ }
81
+ write(writer) {
82
+ writer.write("import ").write(`"${this.from}"`);
83
+ }
84
+ }
85
+ function moduleImport(from) {
86
+ return new ModuleImport(from);
87
+ }
88
+ function namedImport(name) {
89
+ return new NamedImport(name);
90
+ }
91
+ export {
92
+ BindingsImport,
93
+ ModuleImport,
94
+ NamedImport,
95
+ NamespaceImport,
96
+ moduleImport,
97
+ namedImport
98
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var import_vitest = require("vitest");
3
+ var import_Import = require("./Import");
4
+ var import_stringify = require("./stringify");
5
+ (0, import_vitest.test)("module name only", () => {
6
+ (0, import_vitest.expect)((0, import_stringify.stringify)((0, import_Import.moduleImport)("someModule"))).toMatchInlineSnapshot(`"import "someModule""`);
7
+ });
8
+ (0, import_vitest.test)("default", () => {
9
+ const importDecl = (0, import_Import.moduleImport)("myModule").default("mod");
10
+ (0, import_vitest.expect)((0, import_stringify.stringify)(importDecl)).toMatchInlineSnapshot(`"import mod from "myModule""`);
11
+ });
12
+ (0, import_vitest.test)("namespace", () => {
13
+ const importDecl = (0, import_Import.moduleImport)("myModule").asNamespace("ns");
14
+ (0, import_vitest.expect)((0, import_stringify.stringify)(importDecl)).toMatchInlineSnapshot(`"import * as ns from "myModule""`);
15
+ });
16
+ (0, import_vitest.test)("named", () => {
17
+ const importDecl = (0, import_Import.moduleImport)("myModule").named("func");
18
+ (0, import_vitest.expect)((0, import_stringify.stringify)(importDecl)).toMatchInlineSnapshot(`"import { func } from "myModule""`);
19
+ });
20
+ (0, import_vitest.test)("named with alias", () => {
21
+ const importDecl = (0, import_Import.moduleImport)("myModule").named((0, import_Import.namedImport)("func").as("myFunc"));
22
+ (0, import_vitest.expect)((0, import_stringify.stringify)(importDecl)).toMatchInlineSnapshot(`"import { func as myFunc } from "myModule""`);
23
+ });
24
+ (0, import_vitest.test)("multiple named", () => {
25
+ const importDecl = (0, import_Import.moduleImport)("myModule").named("func1").named("func2").named((0, import_Import.namedImport)("func3").as("aliasedFunc3"));
26
+ (0, import_vitest.expect)((0, import_stringify.stringify)(importDecl)).toMatchInlineSnapshot(
27
+ `"import { func1, func2, func3 as aliasedFunc3 } from "myModule""`
28
+ );
29
+ });
30
+ (0, import_vitest.test)("default and named", () => {
31
+ const importDecl = (0, import_Import.moduleImport)("myModule").default("mod").named("func1").named("func2");
32
+ (0, import_vitest.expect)((0, import_stringify.stringify)(importDecl)).toMatchInlineSnapshot(`"import mod, { func1, func2 } from "myModule""`);
33
+ });
@@ -0,0 +1,32 @@
1
+ import { expect, test } from "vitest";
2
+ import { moduleImport, namedImport } from "./Import";
3
+ import { stringify } from "./stringify";
4
+ test("module name only", () => {
5
+ expect(stringify(moduleImport("someModule"))).toMatchInlineSnapshot(`"import "someModule""`);
6
+ });
7
+ test("default", () => {
8
+ const importDecl = moduleImport("myModule").default("mod");
9
+ expect(stringify(importDecl)).toMatchInlineSnapshot(`"import mod from "myModule""`);
10
+ });
11
+ test("namespace", () => {
12
+ const importDecl = moduleImport("myModule").asNamespace("ns");
13
+ expect(stringify(importDecl)).toMatchInlineSnapshot(`"import * as ns from "myModule""`);
14
+ });
15
+ test("named", () => {
16
+ const importDecl = moduleImport("myModule").named("func");
17
+ expect(stringify(importDecl)).toMatchInlineSnapshot(`"import { func } from "myModule""`);
18
+ });
19
+ test("named with alias", () => {
20
+ const importDecl = moduleImport("myModule").named(namedImport("func").as("myFunc"));
21
+ expect(stringify(importDecl)).toMatchInlineSnapshot(`"import { func as myFunc } from "myModule""`);
22
+ });
23
+ test("multiple named", () => {
24
+ const importDecl = moduleImport("myModule").named("func1").named("func2").named(namedImport("func3").as("aliasedFunc3"));
25
+ expect(stringify(importDecl)).toMatchInlineSnapshot(
26
+ `"import { func1, func2, func3 as aliasedFunc3 } from "myModule""`
27
+ );
28
+ });
29
+ test("default and named", () => {
30
+ const importDecl = moduleImport("myModule").default("mod").named("func1").named("func2");
31
+ expect(stringify(importDecl)).toMatchInlineSnapshot(`"import mod, { func1, func2 } from "myModule""`);
32
+ });
@@ -0,0 +1,22 @@
1
+ import { GenericParameter } from './GenericParameter';
2
+ import { Method } from './Method';
3
+ import { NamedType } from './NamedType';
4
+ import { Property } from './Property';
5
+ import { TypeBuilder } from './TypeBuilder';
6
+ import { Writer } from './Writer';
7
+ type InterfaceItem = Method | Property;
8
+ export declare class InterfaceDeclaration extends TypeBuilder {
9
+ readonly name: string;
10
+ needsParenthesisWhenIndexed: boolean;
11
+ private items;
12
+ private genericParameters;
13
+ private extendedTypes;
14
+ constructor(name: string);
15
+ add(item: InterfaceItem): this;
16
+ addMultiple(items: InterfaceItem[]): this;
17
+ addGenericParameter(param: GenericParameter): this;
18
+ extends(type: NamedType): this;
19
+ write(writer: Writer): void;
20
+ }
21
+ export declare function interfaceDeclaration(name: string): InterfaceDeclaration;
22
+ export {};
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var Interface_exports = {};
20
+ __export(Interface_exports, {
21
+ InterfaceDeclaration: () => InterfaceDeclaration,
22
+ interfaceDeclaration: () => interfaceDeclaration
23
+ });
24
+ module.exports = __toCommonJS(Interface_exports);
25
+ var import_TypeBuilder = require("./TypeBuilder");
26
+ class InterfaceDeclaration extends import_TypeBuilder.TypeBuilder {
27
+ constructor(name) {
28
+ super();
29
+ this.name = name;
30
+ }
31
+ needsParenthesisWhenIndexed = true;
32
+ items = [];
33
+ genericParameters = [];
34
+ extendedTypes = [];
35
+ add(item) {
36
+ this.items.push(item);
37
+ return this;
38
+ }
39
+ addMultiple(items) {
40
+ for (const item of items) {
41
+ this.add(item);
42
+ }
43
+ return this;
44
+ }
45
+ addGenericParameter(param) {
46
+ this.genericParameters.push(param);
47
+ return this;
48
+ }
49
+ extends(type) {
50
+ this.extendedTypes.push(type);
51
+ return this;
52
+ }
53
+ write(writer) {
54
+ writer.write("interface ").write(this.name);
55
+ if (this.genericParameters.length > 0) {
56
+ writer.write("<").writeJoined(", ", this.genericParameters).write(">");
57
+ }
58
+ if (this.extendedTypes.length > 0) {
59
+ writer.write(" extends ").writeJoined(", ", this.extendedTypes);
60
+ }
61
+ if (this.items.length === 0) {
62
+ writer.writeLine(" {}");
63
+ return;
64
+ }
65
+ writer.writeLine(" {").withIndent(() => {
66
+ for (const item of this.items) {
67
+ writer.writeLine(item);
68
+ }
69
+ }).write("}");
70
+ }
71
+ }
72
+ function interfaceDeclaration(name) {
73
+ return new InterfaceDeclaration(name);
74
+ }
75
+ // Annotate the CommonJS export names for ESM import in node:
76
+ 0 && (module.exports = {
77
+ InterfaceDeclaration,
78
+ interfaceDeclaration
79
+ });
@@ -0,0 +1,54 @@
1
+ import { TypeBuilder } from "./TypeBuilder";
2
+ class InterfaceDeclaration extends TypeBuilder {
3
+ constructor(name) {
4
+ super();
5
+ this.name = name;
6
+ }
7
+ needsParenthesisWhenIndexed = true;
8
+ items = [];
9
+ genericParameters = [];
10
+ extendedTypes = [];
11
+ add(item) {
12
+ this.items.push(item);
13
+ return this;
14
+ }
15
+ addMultiple(items) {
16
+ for (const item of items) {
17
+ this.add(item);
18
+ }
19
+ return this;
20
+ }
21
+ addGenericParameter(param) {
22
+ this.genericParameters.push(param);
23
+ return this;
24
+ }
25
+ extends(type) {
26
+ this.extendedTypes.push(type);
27
+ return this;
28
+ }
29
+ write(writer) {
30
+ writer.write("interface ").write(this.name);
31
+ if (this.genericParameters.length > 0) {
32
+ writer.write("<").writeJoined(", ", this.genericParameters).write(">");
33
+ }
34
+ if (this.extendedTypes.length > 0) {
35
+ writer.write(" extends ").writeJoined(", ", this.extendedTypes);
36
+ }
37
+ if (this.items.length === 0) {
38
+ writer.writeLine(" {}");
39
+ return;
40
+ }
41
+ writer.writeLine(" {").withIndent(() => {
42
+ for (const item of this.items) {
43
+ writer.writeLine(item);
44
+ }
45
+ }).write("}");
46
+ }
47
+ }
48
+ function interfaceDeclaration(name) {
49
+ return new InterfaceDeclaration(name);
50
+ }
51
+ export {
52
+ InterfaceDeclaration,
53
+ interfaceDeclaration
54
+ };
@@ -0,0 +1 @@
1
+ export {};