lombok-typescript 0.7.0 → 0.8.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.md +18 -6
- package/dist/cli/index.cjs +149 -5
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +149 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/codegen/index.cjs +149 -5
- package/dist/codegen/index.cjs.map +1 -1
- package/dist/codegen/index.js +149 -5
- package/dist/codegen/index.js.map +1 -1
- package/dist/legacy/index.cjs +106 -0
- package/dist/legacy/index.cjs.map +1 -1
- package/dist/legacy/index.d.cts +18 -3
- package/dist/legacy/index.d.ts +18 -3
- package/dist/legacy/index.js +100 -1
- package/dist/legacy/index.js.map +1 -1
- package/dist/stage3/index.cjs +118 -1
- package/dist/stage3/index.cjs.map +1 -1
- package/dist/stage3/index.d.cts +18 -3
- package/dist/stage3/index.d.ts +18 -3
- package/dist/stage3/index.js +112 -2
- package/dist/stage3/index.js.map +1 -1
- package/dist/{proxy-BJ6_DDQ0.d.cts → visitor-B5ByGIWE.d.cts} +17 -1
- package/dist/{proxy-BQ3WvvT_.d.ts → visitor-BqARKwCX.d.ts} +17 -1
- package/package.json +2 -2
package/dist/stage3/index.cjs
CHANGED
|
@@ -103,8 +103,10 @@ var MetadataKeys = {
|
|
|
103
103
|
// Class-level (GoF)
|
|
104
104
|
SINGLETON: `${PREFIX}singleton`,
|
|
105
105
|
FACTORY: `${PREFIX}factory`,
|
|
106
|
+
ABSTRACT_FACTORY: `${PREFIX}abstractFactory`,
|
|
106
107
|
PROTOTYPE: `${PREFIX}prototype`,
|
|
107
108
|
COMPOSITE: `${PREFIX}composite`,
|
|
109
|
+
WRAPS: `${PREFIX}wraps`,
|
|
108
110
|
FLYWEIGHT: `${PREFIX}flyweight`,
|
|
109
111
|
PROXY: `${PREFIX}proxy`,
|
|
110
112
|
CHAIN_OF_RESPONSIBILITY: `${PREFIX}chainOfResponsibility`,
|
|
@@ -114,6 +116,9 @@ var MetadataKeys = {
|
|
|
114
116
|
MEMENTO_EXCLUDE: `${PREFIX}memento:exclude`,
|
|
115
117
|
STATE: `${PREFIX}state`,
|
|
116
118
|
STRATEGY: `${PREFIX}strategy`,
|
|
119
|
+
TEMPLATE_METHOD: `${PREFIX}templateMethod`,
|
|
120
|
+
VISITABLE: `${PREFIX}visitable`,
|
|
121
|
+
VISITOR: `${PREFIX}visitor`,
|
|
117
122
|
// Field-level
|
|
118
123
|
GETTER: `${PREFIX}getter`,
|
|
119
124
|
SETTER: `${PREFIX}setter`,
|
|
@@ -125,7 +130,8 @@ var MetadataKeys = {
|
|
|
125
130
|
// Method-level
|
|
126
131
|
MEMOIZE: `${PREFIX}memoize`,
|
|
127
132
|
HANDLER: `${PREFIX}handler`,
|
|
128
|
-
TRANSITION: `${PREFIX}transition
|
|
133
|
+
TRANSITION: `${PREFIX}transition`,
|
|
134
|
+
HOOK: `${PREFIX}hook`};
|
|
129
135
|
|
|
130
136
|
// src/decorators/shared/factory.ts
|
|
131
137
|
var factoryRegistry = /* @__PURE__ */ new Map();
|
|
@@ -1001,6 +1007,83 @@ function proxyClassStage3(backend, value, context, hooks = {}) {
|
|
|
1001
1007
|
return wrapProxyClass(value, hooks);
|
|
1002
1008
|
}
|
|
1003
1009
|
|
|
1010
|
+
// src/decorators/shared/wraps.ts
|
|
1011
|
+
var INNER = /* @__PURE__ */ Symbol("lombok-ts:wraps-inner");
|
|
1012
|
+
function wrapWrapsClass(target, InnerClass) {
|
|
1013
|
+
if (typeof InnerClass !== "function") {
|
|
1014
|
+
throw new TypeError("@Wraps requires a constructor function");
|
|
1015
|
+
}
|
|
1016
|
+
const WrapsClass = class extends target {
|
|
1017
|
+
inner;
|
|
1018
|
+
constructor(...args) {
|
|
1019
|
+
super();
|
|
1020
|
+
const inner = args[0];
|
|
1021
|
+
if (inner === void 0 || !(inner instanceof InnerClass)) {
|
|
1022
|
+
throw new TypeError(`@Wraps(${InnerClass.name}) expects an instance as the first argument`);
|
|
1023
|
+
}
|
|
1024
|
+
this.inner = inner;
|
|
1025
|
+
this[INNER] = inner;
|
|
1026
|
+
}
|
|
1027
|
+
};
|
|
1028
|
+
return WrapsClass;
|
|
1029
|
+
}
|
|
1030
|
+
function wrapsClassStage3(backend, value, context, InnerClass) {
|
|
1031
|
+
backend.metadata.set(MetadataKeys.WRAPS, context.metadata, void 0, InnerClass);
|
|
1032
|
+
return wrapWrapsClass(value, InnerClass);
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
// src/decorators/shared/template-method.ts
|
|
1036
|
+
function templateMethodClassStage3(backend, _value, context, options) {
|
|
1037
|
+
if (!Array.isArray(options?.steps) || options.steps.length === 0) {
|
|
1038
|
+
throw new Error("@TemplateMethod requires a non-empty `steps` array");
|
|
1039
|
+
}
|
|
1040
|
+
backend.metadata.set(
|
|
1041
|
+
MetadataKeys.TEMPLATE_METHOD,
|
|
1042
|
+
context.metadata,
|
|
1043
|
+
void 0,
|
|
1044
|
+
options
|
|
1045
|
+
);
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
// src/decorators/shared/hook.ts
|
|
1049
|
+
function hookMethodStage3(backend, _value, context, options) {
|
|
1050
|
+
backend.metadata.set(MetadataKeys.HOOK, context.metadata, context.name, options);
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
// src/decorators/shared/abstract-factory.ts
|
|
1054
|
+
function normalizeProducts(productsOrOptions) {
|
|
1055
|
+
const products = Array.isArray(productsOrOptions) ? productsOrOptions : productsOrOptions.products;
|
|
1056
|
+
if (!Array.isArray(products) || products.length === 0) {
|
|
1057
|
+
throw new Error("@AbstractFactory requires a non-empty product list");
|
|
1058
|
+
}
|
|
1059
|
+
return products;
|
|
1060
|
+
}
|
|
1061
|
+
function abstractFactoryClassStage3(backend, _value, context, productsOrOptions) {
|
|
1062
|
+
const products = normalizeProducts(productsOrOptions);
|
|
1063
|
+
backend.metadata.set(MetadataKeys.ABSTRACT_FACTORY, context.metadata, void 0, {
|
|
1064
|
+
products
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
// src/decorators/shared/visitor.ts
|
|
1069
|
+
var visitableRegistry = /* @__PURE__ */ new Map();
|
|
1070
|
+
function registerVisitable(name, ctor) {
|
|
1071
|
+
visitableRegistry.set(name, ctor);
|
|
1072
|
+
}
|
|
1073
|
+
function getVisitableRegistry() {
|
|
1074
|
+
return visitableRegistry;
|
|
1075
|
+
}
|
|
1076
|
+
function visitorClassStage3(backend, _value, context, options) {
|
|
1077
|
+
if (!options?.visitMethods || typeof options.visitMethods !== "object") {
|
|
1078
|
+
throw new Error("@Visitor requires a `visitMethods` map");
|
|
1079
|
+
}
|
|
1080
|
+
backend.metadata.set(MetadataKeys.VISITOR, context.metadata, void 0, options);
|
|
1081
|
+
}
|
|
1082
|
+
function visitableClassStage3(backend, value, context, options = {}) {
|
|
1083
|
+
backend.metadata.set(MetadataKeys.VISITABLE, context.metadata, void 0, options);
|
|
1084
|
+
registerVisitable(value.name, value);
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1004
1087
|
// src/decorators/stage3/index.ts
|
|
1005
1088
|
var NonNull = defineFieldDecorator(nonNullFieldStage3);
|
|
1006
1089
|
var Singleton = defineClassDecorator(singletonClassStage3);
|
|
@@ -1123,12 +1206,40 @@ function Proxy2(hooks = {}) {
|
|
|
1123
1206
|
(backend, value, context) => proxyClassStage3(backend, value, context, hooks)
|
|
1124
1207
|
);
|
|
1125
1208
|
}
|
|
1209
|
+
function Wraps(InnerClass) {
|
|
1210
|
+
return defineClassDecorator(
|
|
1211
|
+
(backend, value, context) => wrapsClassStage3(backend, value, context, InnerClass)
|
|
1212
|
+
);
|
|
1213
|
+
}
|
|
1214
|
+
function TemplateMethod(options) {
|
|
1215
|
+
return defineClassDecorator(
|
|
1216
|
+
(backend, value, context) => templateMethodClassStage3(backend, value, context, options)
|
|
1217
|
+
);
|
|
1218
|
+
}
|
|
1219
|
+
function Hook(options) {
|
|
1220
|
+
return defineMethodDecorator((backend, value, context) => {
|
|
1221
|
+
const name = options?.name ?? String(context.name);
|
|
1222
|
+
hookMethodStage3(backend, value, context, { name });
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1225
|
+
function AbstractFactory(products) {
|
|
1226
|
+
return defineClassDecorator(
|
|
1227
|
+
(backend, value, context) => abstractFactoryClassStage3(backend, value, context, products)
|
|
1228
|
+
);
|
|
1229
|
+
}
|
|
1230
|
+
function Visitor(options) {
|
|
1231
|
+
return defineClassDecorator(
|
|
1232
|
+
(backend, value, context) => visitorClassStage3(backend, value, context, options)
|
|
1233
|
+
);
|
|
1234
|
+
}
|
|
1235
|
+
var Visitable = defineClassDecorator(visitableClassStage3);
|
|
1126
1236
|
|
|
1127
1237
|
// src/stage3/index.ts
|
|
1128
1238
|
function getClassMetadata(cls) {
|
|
1129
1239
|
return cls[Symbol.metadata];
|
|
1130
1240
|
}
|
|
1131
1241
|
|
|
1242
|
+
exports.AbstractFactory = AbstractFactory;
|
|
1132
1243
|
exports.Accessors = Accessors;
|
|
1133
1244
|
exports.Builder = Builder;
|
|
1134
1245
|
exports.ChainOfResponsibility = ChainOfResponsibility;
|
|
@@ -1144,6 +1255,7 @@ exports.FieldDefaults = FieldDefaults;
|
|
|
1144
1255
|
exports.Flyweight = Flyweight;
|
|
1145
1256
|
exports.Getter = Getter;
|
|
1146
1257
|
exports.Handler = Handler;
|
|
1258
|
+
exports.Hook = Hook;
|
|
1147
1259
|
exports.Iterable = Iterable;
|
|
1148
1260
|
exports.IterateOver = IterateOver;
|
|
1149
1261
|
exports.Log = Log;
|
|
@@ -1160,11 +1272,15 @@ exports.Stage3Backend = Stage3Backend;
|
|
|
1160
1272
|
exports.State = State;
|
|
1161
1273
|
exports.Strategy = Strategy;
|
|
1162
1274
|
exports.StrategyRegistry = StrategyRegistry;
|
|
1275
|
+
exports.TemplateMethod = TemplateMethod;
|
|
1163
1276
|
exports.ToString = ToString;
|
|
1164
1277
|
exports.Transition = Transition;
|
|
1165
1278
|
exports.UtilityClass = UtilityClass;
|
|
1166
1279
|
exports.Value = Value;
|
|
1280
|
+
exports.Visitable = Visitable;
|
|
1281
|
+
exports.Visitor = Visitor;
|
|
1167
1282
|
exports.With = With;
|
|
1283
|
+
exports.Wraps = Wraps;
|
|
1168
1284
|
exports.createFromFactory = createFromFactory;
|
|
1169
1285
|
exports.defineClassDecorator = defineClassDecorator;
|
|
1170
1286
|
exports.defineFieldDecorator = defineFieldDecorator;
|
|
@@ -1175,6 +1291,7 @@ exports.getClassMetadata = getClassMetadata;
|
|
|
1175
1291
|
exports.getFactoryRegistry = getFactoryRegistry;
|
|
1176
1292
|
exports.getStrategyFromRegistry = getStrategyFromRegistry;
|
|
1177
1293
|
exports.getStrategyRegistry = getStrategyRegistry;
|
|
1294
|
+
exports.getVisitableRegistry = getVisitableRegistry;
|
|
1178
1295
|
exports.listStrategies = listStrategies;
|
|
1179
1296
|
exports.registerFactory = registerFactory;
|
|
1180
1297
|
exports.registerStrategy = registerStrategy;
|