@epsilon-asi/foundation 0.0.1-rc3 → 0.0.2

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.
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
36
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
37
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
38
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
39
+ };
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.validationRegistry = exports.SignupInput = void 0;
42
+ exports.buildValidationSchema = buildValidationSchema;
43
+ const index_1 = require("../index");
44
+ const registry = (0, index_1.createDecoratorRegistry)({ namespace: 'validation-example' });
45
+ exports.validationRegistry = registry;
46
+ const Signup = registry.for();
47
+ const Schema = Signup.class('schema');
48
+ const Field = Signup.property('field');
49
+ const Required = Signup.property('required');
50
+ let SignupInput = (() => {
51
+ let _classDecorators = [Schema({ name: 'signup' })];
52
+ let _classDescriptor;
53
+ let _classExtraInitializers = [];
54
+ let _classThis;
55
+ let _email_decorators;
56
+ let _email_initializers = [];
57
+ let _email_extraInitializers = [];
58
+ let _displayName_decorators;
59
+ let _displayName_initializers = [];
60
+ let _displayName_extraInitializers = [];
61
+ let _age_decorators;
62
+ let _age_initializers = [];
63
+ let _age_extraInitializers = [];
64
+ var SignupInput = _classThis = class {
65
+ constructor() {
66
+ this.email = __runInitializers(this, _email_initializers, 'ray@example.com');
67
+ this.displayName = (__runInitializers(this, _email_extraInitializers), __runInitializers(this, _displayName_initializers, 'Ray'));
68
+ this.age = (__runInitializers(this, _displayName_extraInitializers), __runInitializers(this, _age_initializers, 42));
69
+ __runInitializers(this, _age_extraInitializers);
70
+ }
71
+ };
72
+ __setFunctionName(_classThis, "SignupInput");
73
+ (() => {
74
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
75
+ _email_decorators = [Required.on('email'), Field.on('email', { type: 'email' })];
76
+ _displayName_decorators = [Required.on('displayName'), Field.on('displayName', { type: 'string', minLength: 2 })];
77
+ _age_decorators = [Field.on('age', { type: 'number', min: 13 })];
78
+ __esDecorate(null, null, _email_decorators, { kind: "field", name: "email", static: false, private: false, access: { has: obj => "email" in obj, get: obj => obj.email, set: (obj, value) => { obj.email = value; } }, metadata: _metadata }, _email_initializers, _email_extraInitializers);
79
+ __esDecorate(null, null, _displayName_decorators, { kind: "field", name: "displayName", static: false, private: false, access: { has: obj => "displayName" in obj, get: obj => obj.displayName, set: (obj, value) => { obj.displayName = value; } }, metadata: _metadata }, _displayName_initializers, _displayName_extraInitializers);
80
+ __esDecorate(null, null, _age_decorators, { kind: "field", name: "age", static: false, private: false, access: { has: obj => "age" in obj, get: obj => obj.age, set: (obj, value) => { obj.age = value; } }, metadata: _metadata }, _age_initializers, _age_extraInitializers);
81
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
82
+ SignupInput = _classThis = _classDescriptor.value;
83
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
84
+ __runInitializers(_classThis, _classExtraInitializers);
85
+ })();
86
+ return SignupInput = _classThis;
87
+ })();
88
+ exports.SignupInput = SignupInput;
89
+ function buildValidationSchema() {
90
+ const snapshot = registry.read(SignupInput);
91
+ const schema = snapshot.firstClass('schema');
92
+ if (schema === undefined)
93
+ throw new Error('Missing @Schema metadata.');
94
+ const requiredMembers = new Set(snapshot.propertyRecords('required').map((record) => {
95
+ if (record.memberName === undefined)
96
+ throw new Error('Required record missing member.');
97
+ return record.memberName;
98
+ }));
99
+ const fields = snapshot.propertyRecords('field').map((record) => {
100
+ if (record.memberName === undefined)
101
+ throw new Error('Field record missing member.');
102
+ const metadata = record.metadata;
103
+ return Object.assign(Object.assign({ name: record.memberName, type: metadata.type, required: requiredMembers.has(record.memberName) }, (metadata.minLength !== undefined ? { minLength: metadata.minLength } : {})), (metadata.min !== undefined ? { min: metadata.min } : {}));
104
+ });
105
+ return {
106
+ name: schema.metadata.name,
107
+ fields,
108
+ };
109
+ }
@@ -0,0 +1,458 @@
1
+ "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
36
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
37
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
38
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
39
+ };
40
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
41
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
42
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
43
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
44
+ };
45
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
46
+ if (kind === "m") throw new TypeError("Private method is not writable");
47
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
48
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
49
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
50
+ };
51
+ Object.defineProperty(exports, "__esModule", { value: true });
52
+ const index_1 = require("../index");
53
+ const registry = (0, index_1.createDecoratorRegistry)();
54
+ const Entity = registry.class('entity');
55
+ const User = registry.for();
56
+ const ScopedEntity = User.class('entity');
57
+ const Column = User.property('column');
58
+ const Serializable = User.property('serializable');
59
+ const Route = User.method('route');
60
+ const Cached = User.accessor('cached');
61
+ let GoodUnscopedUserController = (() => {
62
+ let _classDecorators = [Entity({ table: 'users' })];
63
+ let _classDescriptor;
64
+ let _classExtraInitializers = [];
65
+ let _classThis;
66
+ var GoodUnscopedUserController = _classThis = class {
67
+ async getUser(id) {
68
+ return { id, email: this.email, age: this.age };
69
+ }
70
+ async createUser(input) {
71
+ return { id: 'new-id', email: input.email, age: input.age };
72
+ }
73
+ };
74
+ __setFunctionName(_classThis, "GoodUnscopedUserController");
75
+ (() => {
76
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
77
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
78
+ GoodUnscopedUserController = _classThis = _classDescriptor.value;
79
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
80
+ __runInitializers(_classThis, _classExtraInitializers);
81
+ })();
82
+ return GoodUnscopedUserController = _classThis;
83
+ })();
84
+ // @ts-expect-error missing contract members
85
+ let BadUnscopedUserController = (() => {
86
+ let _classDecorators = [Entity({ table: 'users' })];
87
+ let _classDescriptor;
88
+ let _classExtraInitializers = [];
89
+ let _classThis;
90
+ var BadUnscopedUserController = _classThis = class {
91
+ };
92
+ __setFunctionName(_classThis, "BadUnscopedUserController");
93
+ (() => {
94
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
95
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
96
+ BadUnscopedUserController = _classThis = _classDescriptor.value;
97
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
98
+ __runInitializers(_classThis, _classExtraInitializers);
99
+ })();
100
+ return BadUnscopedUserController = _classThis;
101
+ })();
102
+ // @ts-expect-error table must be string
103
+ let BadClassMetadataController = (() => {
104
+ let _classDecorators = [Entity({ table: 123 })];
105
+ let _classDescriptor;
106
+ let _classExtraInitializers = [];
107
+ let _classThis;
108
+ var BadClassMetadataController = _classThis = class {
109
+ async getUser(id) {
110
+ return { id, email: this.email, age: this.age };
111
+ }
112
+ async createUser(input) {
113
+ return { id: 'new-id', email: input.email, age: input.age };
114
+ }
115
+ };
116
+ __setFunctionName(_classThis, "BadClassMetadataController");
117
+ (() => {
118
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
119
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
120
+ BadClassMetadataController = _classThis = _classDescriptor.value;
121
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
122
+ __runInitializers(_classThis, _classExtraInitializers);
123
+ })();
124
+ return BadClassMetadataController = _classThis;
125
+ })();
126
+ let GoodScopedUserController = (() => {
127
+ let _classDecorators = [ScopedEntity({ table: 'users' })];
128
+ let _classDescriptor;
129
+ let _classExtraInitializers = [];
130
+ let _classThis;
131
+ let _instanceExtraInitializers = [];
132
+ let _id_decorators;
133
+ let _id_initializers = [];
134
+ let _id_extraInitializers = [];
135
+ let _email_decorators;
136
+ let _email_initializers = [];
137
+ let _email_extraInitializers = [];
138
+ let _getUser_decorators;
139
+ let _createUser_decorators;
140
+ var GoodScopedUserController = _classThis = class {
141
+ constructor() {
142
+ this.id = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _id_initializers, void 0));
143
+ this.email = (__runInitializers(this, _id_extraInitializers), __runInitializers(this, _email_initializers, void 0));
144
+ this.age = __runInitializers(this, _email_extraInitializers);
145
+ }
146
+ async getUser(id) {
147
+ return { id, email: this.email, age: this.age };
148
+ }
149
+ async createUser(input) {
150
+ return { id: 'new-id', email: input.email, age: input.age };
151
+ }
152
+ };
153
+ __setFunctionName(_classThis, "GoodScopedUserController");
154
+ (() => {
155
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
156
+ _id_decorators = [Column({ type: 'uuid', primary: true })];
157
+ _email_decorators = [Serializable(), Column('email', { type: 'varchar' })];
158
+ _getUser_decorators = [Route({ method: 'GET', path: '/users/:id' })];
159
+ _createUser_decorators = [Route.on('createUser', { method: 'POST', path: '/users' })];
160
+ __esDecorate(_classThis, null, _getUser_decorators, { kind: "method", name: "getUser", static: false, private: false, access: { has: obj => "getUser" in obj, get: obj => obj.getUser }, metadata: _metadata }, null, _instanceExtraInitializers);
161
+ __esDecorate(_classThis, null, _createUser_decorators, { kind: "method", name: "createUser", static: false, private: false, access: { has: obj => "createUser" in obj, get: obj => obj.createUser }, metadata: _metadata }, null, _instanceExtraInitializers);
162
+ __esDecorate(null, null, _id_decorators, { kind: "field", name: "id", static: false, private: false, access: { has: obj => "id" in obj, get: obj => obj.id, set: (obj, value) => { obj.id = value; } }, metadata: _metadata }, _id_initializers, _id_extraInitializers);
163
+ __esDecorate(null, null, _email_decorators, { kind: "field", name: "email", static: false, private: false, access: { has: obj => "email" in obj, get: obj => obj.email, set: (obj, value) => { obj.email = value; } }, metadata: _metadata }, _email_initializers, _email_extraInitializers);
164
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
165
+ GoodScopedUserController = _classThis = _classDescriptor.value;
166
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
167
+ __runInitializers(_classThis, _classExtraInitializers);
168
+ })();
169
+ return GoodScopedUserController = _classThis;
170
+ })();
171
+ let BadPropertyMetadata = (() => {
172
+ var _a;
173
+ let _id_decorators;
174
+ let _id_initializers = [];
175
+ let _id_extraInitializers = [];
176
+ return _a = class BadPropertyMetadata {
177
+ constructor() {
178
+ // @ts-expect-error type must be uuid or varchar
179
+ this.id = __runInitializers(this, _id_initializers, void 0);
180
+ this.email = __runInitializers(this, _id_extraInitializers);
181
+ }
182
+ async getUser(id) {
183
+ return { id, email: this.email, age: this.age };
184
+ }
185
+ async createUser(input) {
186
+ return { id: 'new-id', email: input.email, age: input.age };
187
+ }
188
+ },
189
+ (() => {
190
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
191
+ _id_decorators = [Column({ type: 'int' })];
192
+ __esDecorate(null, null, _id_decorators, { kind: "field", name: "id", static: false, private: false, access: { has: obj => "id" in obj, get: obj => obj.id, set: (obj, value) => { obj.id = value; } }, metadata: _metadata }, _id_initializers, _id_extraInitializers);
193
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
194
+ })(),
195
+ _a;
196
+ })();
197
+ let BadPropertyTarget = (() => {
198
+ var _a;
199
+ let _age_decorators;
200
+ let _age_initializers = [];
201
+ let _age_extraInitializers = [];
202
+ return _a = class BadPropertyTarget {
203
+ async getUser(id) {
204
+ return { id, email: this.email, age: this.age };
205
+ }
206
+ async createUser(input) {
207
+ return { id: 'new-id', email: input.email, age: input.age };
208
+ }
209
+ constructor() {
210
+ // @ts-expect-error column target is string but age is number
211
+ this.age = __runInitializers(this, _age_initializers, void 0);
212
+ __runInitializers(this, _age_extraInitializers);
213
+ }
214
+ },
215
+ (() => {
216
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
217
+ _age_decorators = [Column({ type: 'varchar' })];
218
+ __esDecorate(null, null, _age_decorators, { kind: "field", name: "age", static: false, private: false, access: { has: obj => "age" in obj, get: obj => obj.age, set: (obj, value) => { obj.age = value; } }, metadata: _metadata }, _age_initializers, _age_extraInitializers);
219
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
220
+ })(),
221
+ _a;
222
+ })();
223
+ let BadPropertyKey = (() => {
224
+ var _a;
225
+ let _id_decorators;
226
+ let _id_initializers = [];
227
+ let _id_extraInitializers = [];
228
+ return _a = class BadPropertyKey {
229
+ constructor() {
230
+ // @ts-expect-error decorator key does not match member name
231
+ this.id = __runInitializers(this, _id_initializers, void 0);
232
+ this.email = __runInitializers(this, _id_extraInitializers);
233
+ }
234
+ async getUser(id) {
235
+ return { id, email: this.email, age: this.age };
236
+ }
237
+ async createUser(input) {
238
+ return { id: 'new-id', email: input.email, age: input.age };
239
+ }
240
+ },
241
+ (() => {
242
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
243
+ _id_decorators = [Column('email', { type: 'varchar' })];
244
+ __esDecorate(null, null, _id_decorators, { kind: "field", name: "id", static: false, private: false, access: { has: obj => "id" in obj, get: obj => obj.id, set: (obj, value) => { obj.id = value; } }, metadata: _metadata }, _id_initializers, _id_extraInitializers);
245
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
246
+ })(),
247
+ _a;
248
+ })();
249
+ let BadNoMetadataArgs = (() => {
250
+ var _a;
251
+ let _email_decorators;
252
+ let _email_initializers = [];
253
+ let _email_extraInitializers = [];
254
+ return _a = class BadNoMetadataArgs {
255
+ constructor() {
256
+ // @ts-expect-error Serializable takes no metadata
257
+ this.email = __runInitializers(this, _email_initializers, void 0);
258
+ this.age = __runInitializers(this, _email_extraInitializers);
259
+ }
260
+ async getUser(id) {
261
+ return { id, email: this.email, age: this.age };
262
+ }
263
+ async createUser(input) {
264
+ return { id: 'new-id', email: input.email, age: input.age };
265
+ }
266
+ },
267
+ (() => {
268
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
269
+ _email_decorators = [Serializable({ enabled: true })];
270
+ __esDecorate(null, null, _email_decorators, { kind: "field", name: "email", static: false, private: false, access: { has: obj => "email" in obj, get: obj => obj.email, set: (obj, value) => { obj.email = value; } }, metadata: _metadata }, _email_initializers, _email_extraInitializers);
271
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
272
+ })(),
273
+ _a;
274
+ })();
275
+ let BadRequiredMetadataArgs = (() => {
276
+ var _a;
277
+ let _id_decorators;
278
+ let _id_initializers = [];
279
+ let _id_extraInitializers = [];
280
+ return _a = class BadRequiredMetadataArgs {
281
+ constructor() {
282
+ // @ts-expect-error Column requires metadata
283
+ this.id = __runInitializers(this, _id_initializers, void 0);
284
+ this.email = __runInitializers(this, _id_extraInitializers);
285
+ }
286
+ async getUser(id) {
287
+ return { id, email: this.email, age: this.age };
288
+ }
289
+ async createUser(input) {
290
+ return { id: 'new-id', email: input.email, age: input.age };
291
+ }
292
+ },
293
+ (() => {
294
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
295
+ _id_decorators = [Column()];
296
+ __esDecorate(null, null, _id_decorators, { kind: "field", name: "id", static: false, private: false, access: { has: obj => "id" in obj, get: obj => obj.id, set: (obj, value) => { obj.id = value; } }, metadata: _metadata }, _id_initializers, _id_extraInitializers);
297
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
298
+ })(),
299
+ _a;
300
+ })();
301
+ let BadMethodMetadata = (() => {
302
+ var _a;
303
+ let _instanceExtraInitializers = [];
304
+ let _getUser_decorators;
305
+ return _a = class BadMethodMetadata {
306
+ constructor() {
307
+ this.id = __runInitializers(this, _instanceExtraInitializers);
308
+ }
309
+ // @ts-expect-error DELETE is not allowed
310
+ async getUser(id) {
311
+ return { id, email: this.email, age: this.age };
312
+ }
313
+ async createUser(input) {
314
+ return { id: 'new-id', email: input.email, age: input.age };
315
+ }
316
+ },
317
+ (() => {
318
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
319
+ _getUser_decorators = [Route({ method: 'DELETE', path: '/users/:id' })];
320
+ __esDecorate(_a, null, _getUser_decorators, { kind: "method", name: "getUser", static: false, private: false, access: { has: obj => "getUser" in obj, get: obj => obj.getUser }, metadata: _metadata }, null, _instanceExtraInitializers);
321
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
322
+ })(),
323
+ _a;
324
+ })();
325
+ let BadMethodTarget = (() => {
326
+ var _a;
327
+ let _instanceExtraInitializers = [];
328
+ let _getUser_decorators;
329
+ return _a = class BadMethodTarget {
330
+ constructor() {
331
+ this.id = __runInitializers(this, _instanceExtraInitializers);
332
+ }
333
+ // @ts-expect-error route target requires Promise return
334
+ getUser(id) {
335
+ return { id, email: this.email, age: this.age };
336
+ }
337
+ async createUser(input) {
338
+ return { id: 'new-id', email: input.email, age: input.age };
339
+ }
340
+ },
341
+ (() => {
342
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
343
+ _getUser_decorators = [Route({ method: 'GET', path: '/users/:id' })];
344
+ __esDecorate(_a, null, _getUser_decorators, { kind: "method", name: "getUser", static: false, private: false, access: { has: obj => "getUser" in obj, get: obj => obj.getUser }, metadata: _metadata }, null, _instanceExtraInitializers);
345
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
346
+ })(),
347
+ _a;
348
+ })();
349
+ let BadMethodKey = (() => {
350
+ var _a;
351
+ let _instanceExtraInitializers = [];
352
+ let _getUser_decorators;
353
+ return _a = class BadMethodKey {
354
+ constructor() {
355
+ this.id = __runInitializers(this, _instanceExtraInitializers);
356
+ }
357
+ // @ts-expect-error decorator key does not match method name
358
+ async getUser(id) {
359
+ return { id, email: this.email, age: this.age };
360
+ }
361
+ async createUser(input) {
362
+ return { id: 'new-id', email: input.email, age: input.age };
363
+ }
364
+ },
365
+ (() => {
366
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
367
+ _getUser_decorators = [Route('createUser', { method: 'GET', path: '/users/:id' })];
368
+ __esDecorate(_a, null, _getUser_decorators, { kind: "method", name: "getUser", static: false, private: false, access: { has: obj => "getUser" in obj, get: obj => obj.getUser }, metadata: _metadata }, null, _instanceExtraInitializers);
369
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
370
+ })(),
371
+ _a;
372
+ })();
373
+ let GoodAccessor = (() => {
374
+ var _a, _GoodAccessor_email_accessor_storage;
375
+ let _email_decorators;
376
+ let _email_initializers = [];
377
+ let _email_extraInitializers = [];
378
+ return _a = class GoodAccessor {
379
+ get email() { return __classPrivateFieldGet(this, _GoodAccessor_email_accessor_storage, "f"); }
380
+ set email(value) { __classPrivateFieldSet(this, _GoodAccessor_email_accessor_storage, value, "f"); }
381
+ async getUser(id) {
382
+ return { id, email: this.email, age: this.age };
383
+ }
384
+ async createUser(input) {
385
+ return { id: 'new-id', email: input.email, age: input.age };
386
+ }
387
+ constructor() {
388
+ _GoodAccessor_email_accessor_storage.set(this, __runInitializers(this, _email_initializers, 'Ray'));
389
+ __runInitializers(this, _email_extraInitializers);
390
+ }
391
+ },
392
+ _GoodAccessor_email_accessor_storage = new WeakMap(),
393
+ (() => {
394
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
395
+ _email_decorators = [Cached('email', { ttlMs: 1000 })];
396
+ __esDecorate(_a, null, _email_decorators, { kind: "accessor", name: "email", static: false, private: false, access: { has: obj => "email" in obj, get: obj => obj.email, set: (obj, value) => { obj.email = value; } }, metadata: _metadata }, _email_initializers, _email_extraInitializers);
397
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
398
+ })(),
399
+ _a;
400
+ })();
401
+ let BadAccessorTarget = (() => {
402
+ var _a, _BadAccessorTarget_count_accessor_storage;
403
+ let _count_decorators;
404
+ let _count_initializers = [];
405
+ let _count_extraInitializers = [];
406
+ return _a = class BadAccessorTarget {
407
+ // @ts-expect-error cached target is string but count is number
408
+ get count() { return __classPrivateFieldGet(this, _BadAccessorTarget_count_accessor_storage, "f"); }
409
+ set count(value) { __classPrivateFieldSet(this, _BadAccessorTarget_count_accessor_storage, value, "f"); }
410
+ async getUser(id) {
411
+ return { id, email: this.email, age: this.age };
412
+ }
413
+ async createUser(input) {
414
+ return { id: 'new-id', email: input.email, age: input.age };
415
+ }
416
+ constructor() {
417
+ _BadAccessorTarget_count_accessor_storage.set(this, __runInitializers(this, _count_initializers, 1));
418
+ __runInitializers(this, _count_extraInitializers);
419
+ }
420
+ },
421
+ _BadAccessorTarget_count_accessor_storage = new WeakMap(),
422
+ (() => {
423
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
424
+ _count_decorators = [Cached({ ttlMs: 1000 })];
425
+ __esDecorate(_a, null, _count_decorators, { kind: "accessor", name: "count", static: false, private: false, access: { has: obj => "count" in obj, get: obj => obj.count, set: (obj, value) => { obj.count = value; } }, metadata: _metadata }, _count_initializers, _count_extraInitializers);
426
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
427
+ })(),
428
+ _a;
429
+ })();
430
+ let BadAccessorMetadata = (() => {
431
+ var _a, _BadAccessorMetadata_label_accessor_storage;
432
+ let _label_decorators;
433
+ let _label_initializers = [];
434
+ let _label_extraInitializers = [];
435
+ return _a = class BadAccessorMetadata {
436
+ // @ts-expect-error ttlMs must be number
437
+ get label() { return __classPrivateFieldGet(this, _BadAccessorMetadata_label_accessor_storage, "f"); }
438
+ set label(value) { __classPrivateFieldSet(this, _BadAccessorMetadata_label_accessor_storage, value, "f"); }
439
+ async getUser(id) {
440
+ return { id, email: this.email, age: this.age };
441
+ }
442
+ async createUser(input) {
443
+ return { id: 'new-id', email: input.email, age: input.age };
444
+ }
445
+ constructor() {
446
+ _BadAccessorMetadata_label_accessor_storage.set(this, __runInitializers(this, _label_initializers, 'Ray'));
447
+ __runInitializers(this, _label_extraInitializers);
448
+ }
449
+ },
450
+ _BadAccessorMetadata_label_accessor_storage = new WeakMap(),
451
+ (() => {
452
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
453
+ _label_decorators = [Cached({ ttlMs: '1000' })];
454
+ __esDecorate(_a, null, _label_decorators, { kind: "accessor", name: "label", static: false, private: false, access: { has: obj => "label" in obj, get: obj => obj.label, set: (obj, value) => { obj.label = value; } }, metadata: _metadata }, _label_initializers, _label_extraInitializers);
455
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
456
+ })(),
457
+ _a;
458
+ })();