@opra/common 1.0.0-alpha.4 → 1.0.0-alpha.5

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/browser.js CHANGED
@@ -2428,6 +2428,26 @@ function HttpControllerDecoratorFactory(options) {
2428
2428
  });
2429
2429
  return decorator;
2430
2430
  };
2431
+ decorator.KeyParam = (name, arg1) => {
2432
+ decoratorChain.push((meta) => {
2433
+ if (!meta.path?.includes(":" + name))
2434
+ meta.path = (meta.path || "") + "@:" + name;
2435
+ const paramMeta = typeof arg1 === "string" || typeof arg1 === "function" ? {
2436
+ name,
2437
+ location: "path",
2438
+ type: arg1,
2439
+ keyParam: true
2440
+ } : {
2441
+ ...arg1,
2442
+ name,
2443
+ location: "path",
2444
+ keyParam: true
2445
+ };
2446
+ meta.parameters = meta.parameters || [];
2447
+ meta.parameters.push(paramMeta);
2448
+ });
2449
+ return decorator;
2450
+ };
2431
2451
  decorator.UseType = (...type) => {
2432
2452
  decoratorChain.push((meta) => {
2433
2453
  meta.types = meta.types || [];
@@ -2530,20 +2550,20 @@ var HttpControllerClass = class extends DocumentElement {
2530
2550
  });
2531
2551
  if (this.operations.size) {
2532
2552
  out.operations = {};
2533
- for (const [name, v] of this.operations.entries()) {
2534
- out.operations[name] = v.toJSON();
2553
+ for (const v of this.operations.values()) {
2554
+ out.operations[v.name] = v.toJSON();
2535
2555
  }
2536
2556
  }
2537
2557
  if (this.controllers.size) {
2538
2558
  out.controllers = {};
2539
- for (const [name, v] of this.controllers.entries()) {
2540
- out.controllers[name] = v.toJSON();
2559
+ for (const v of this.controllers.values()) {
2560
+ out.controllers[v.name] = v.toJSON();
2541
2561
  }
2542
2562
  }
2543
2563
  if (this.types.size) {
2544
2564
  out.types = {};
2545
- for (const [name, v] of this.types.entries()) {
2546
- out.types[name] = v.toJSON();
2565
+ for (const v of this.types.values()) {
2566
+ out.types[v.name] = v.toJSON();
2547
2567
  }
2548
2568
  }
2549
2569
  if (this.parameters.length) {
@@ -2592,8 +2612,8 @@ var HttpApi = class extends ApiBase {
2592
2612
  url: this.url,
2593
2613
  controllers: {}
2594
2614
  };
2595
- for (const [name, v] of this.controllers.entries()) {
2596
- out.controllers[name] = v.toJSON();
2615
+ for (const v of this.controllers.values()) {
2616
+ out.controllers[v.name] = v.toJSON();
2597
2617
  }
2598
2618
  return out;
2599
2619
  }
@@ -3294,6 +3314,7 @@ var HttpParameter = /* @__PURE__ */ __name(function(owner, initArgs) {
3294
3314
  _this.deprecated = initArgs.deprecated;
3295
3315
  _this.required = initArgs.required;
3296
3316
  _this.arraySeparator = initArgs.arraySeparator;
3317
+ _this.keyParam = initArgs.keyParam;
3297
3318
  }, "HttpParameter");
3298
3319
  var HttpParameterClass = class extends Value {
3299
3320
  static {
@@ -3305,6 +3326,7 @@ var HttpParameterClass = class extends Value {
3305
3326
  name: this.name,
3306
3327
  location: this.location,
3307
3328
  arraySeparator: this.arraySeparator,
3329
+ keyParam: this.keyParam,
3308
3330
  required: this.required,
3309
3331
  deprecated: this.deprecated
3310
3332
  });
@@ -12710,11 +12732,21 @@ HttpOperation2.Entity.Delete = function(arg0, arg1) {
12710
12732
  if (typeof args.type === "function")
12711
12733
  decorator.UseType(args.type);
12712
12734
  decorator.KeyParam = (name, prmOptions) => {
12713
- decorator.PathParam(name, prmOptions);
12735
+ const paramMeta = typeof prmOptions === "string" || typeof prmOptions === "function" ? {
12736
+ name,
12737
+ location: "path",
12738
+ type: prmOptions,
12739
+ keyParam: true
12740
+ } : {
12741
+ ...prmOptions,
12742
+ name,
12743
+ location: "path",
12744
+ keyParam: true
12745
+ };
12746
+ decorator.PathParam(name, paramMeta);
12714
12747
  decoratorChain.push((meta) => {
12715
- meta.path = (meta.path || "") + "@:" + name;
12716
- meta.compositionOptions = meta.compositionOptions || {};
12717
- meta.compositionOptions.keyParameter = name;
12748
+ if (!meta.path?.includes(":" + name))
12749
+ meta.path = (meta.path || "") + "@:" + name;
12718
12750
  });
12719
12751
  return decorator;
12720
12752
  };
@@ -12880,11 +12912,21 @@ HttpOperation2.Entity.Get = function(arg0, arg1) {
12880
12912
  if (typeof args.type === "function")
12881
12913
  decorator.UseType(args.type);
12882
12914
  decorator.KeyParam = (name, prmOptions) => {
12883
- decorator.PathParam(name, prmOptions);
12915
+ const paramMeta = typeof prmOptions === "string" || typeof prmOptions === "function" ? {
12916
+ name,
12917
+ location: "path",
12918
+ type: prmOptions,
12919
+ keyParam: true
12920
+ } : {
12921
+ ...prmOptions,
12922
+ name,
12923
+ location: "path",
12924
+ keyParam: true
12925
+ };
12926
+ decorator.PathParam(name, paramMeta);
12884
12927
  decoratorChain.push((meta) => {
12885
- meta.path = (meta.path || "") + "@:" + name;
12886
- meta.compositionOptions = meta.compositionOptions || {};
12887
- meta.compositionOptions.keyParameter = name;
12928
+ if (!meta.path?.includes(":" + name))
12929
+ meta.path = (meta.path || "") + "@:" + name;
12888
12930
  });
12889
12931
  return decorator;
12890
12932
  };
@@ -12987,11 +13029,21 @@ HttpOperation2.Entity.Update = function(arg0, arg1) {
12987
13029
  if (typeof args.type === "function")
12988
13030
  decorator.UseType(args.type);
12989
13031
  decorator.KeyParam = (name, prmOptions) => {
12990
- decorator.PathParam(name, prmOptions);
13032
+ const paramMeta = typeof prmOptions === "string" || typeof prmOptions === "function" ? {
13033
+ name,
13034
+ location: "path",
13035
+ type: prmOptions,
13036
+ keyParam: true
13037
+ } : {
13038
+ ...prmOptions,
13039
+ name,
13040
+ location: "path",
13041
+ keyParam: true
13042
+ };
13043
+ decorator.PathParam(name, paramMeta);
12991
13044
  decoratorChain.push((meta) => {
12992
- meta.path = (meta.path || "") + "@:" + name;
12993
- meta.compositionOptions = meta.compositionOptions || {};
12994
- meta.compositionOptions.keyParameter = name;
13045
+ if (!meta.path?.includes(":" + name))
13046
+ meta.path = (meta.path || "") + "@:" + name;
12995
13047
  });
12996
13048
  return decorator;
12997
13049
  };
@@ -102,6 +102,31 @@ function HttpControllerDecoratorFactory(options) {
102
102
  });
103
103
  return decorator;
104
104
  };
105
+ /**
106
+ *
107
+ */
108
+ decorator.KeyParam = (name, arg1) => {
109
+ decoratorChain.push((meta) => {
110
+ if (!meta.path?.includes(':' + name))
111
+ meta.path = (meta.path || '') + '@:' + name;
112
+ const paramMeta = typeof arg1 === 'string' || typeof arg1 === 'function'
113
+ ? {
114
+ name,
115
+ location: 'path',
116
+ type: arg1,
117
+ keyParam: true,
118
+ }
119
+ : {
120
+ ...arg1,
121
+ name,
122
+ location: 'path',
123
+ keyParam: true,
124
+ };
125
+ meta.parameters = meta.parameters || [];
126
+ meta.parameters.push(paramMeta);
127
+ });
128
+ return decorator;
129
+ };
105
130
  /**
106
131
  *
107
132
  */
@@ -93,11 +93,23 @@ http_operation_js_1.HttpOperation.Entity.Delete = function (arg0, arg1) {
93
93
  *
94
94
  */
95
95
  decorator.KeyParam = (name, prmOptions) => {
96
- decorator.PathParam(name, prmOptions);
96
+ const paramMeta = typeof prmOptions === 'string' || typeof prmOptions === 'function'
97
+ ? {
98
+ name,
99
+ location: 'path',
100
+ type: prmOptions,
101
+ keyParam: true,
102
+ }
103
+ : {
104
+ ...prmOptions,
105
+ name,
106
+ location: 'path',
107
+ keyParam: true,
108
+ };
109
+ decorator.PathParam(name, paramMeta);
97
110
  decoratorChain.push((meta) => {
98
- meta.path = (meta.path || '') + '@:' + name;
99
- meta.compositionOptions = meta.compositionOptions || {};
100
- meta.compositionOptions.keyParameter = name;
111
+ if (!meta.path?.includes(':' + name))
112
+ meta.path = (meta.path || '') + '@:' + name;
101
113
  });
102
114
  return decorator;
103
115
  };
@@ -296,11 +308,23 @@ http_operation_js_1.HttpOperation.Entity.Get = function (arg0, arg1) {
296
308
  *
297
309
  */
298
310
  decorator.KeyParam = (name, prmOptions) => {
299
- decorator.PathParam(name, prmOptions);
311
+ const paramMeta = typeof prmOptions === 'string' || typeof prmOptions === 'function'
312
+ ? {
313
+ name,
314
+ location: 'path',
315
+ type: prmOptions,
316
+ keyParam: true,
317
+ }
318
+ : {
319
+ ...prmOptions,
320
+ name,
321
+ location: 'path',
322
+ keyParam: true,
323
+ };
324
+ decorator.PathParam(name, paramMeta);
300
325
  decoratorChain.push((meta) => {
301
- meta.path = (meta.path || '') + '@:' + name;
302
- meta.compositionOptions = meta.compositionOptions || {};
303
- meta.compositionOptions.keyParameter = name;
326
+ if (!meta.path?.includes(':' + name))
327
+ meta.path = (meta.path || '') + '@:' + name;
304
328
  });
305
329
  return decorator;
306
330
  };
@@ -425,11 +449,23 @@ http_operation_js_1.HttpOperation.Entity.Update = function (arg0, arg1) {
425
449
  *
426
450
  */
427
451
  decorator.KeyParam = (name, prmOptions) => {
428
- decorator.PathParam(name, prmOptions);
452
+ const paramMeta = typeof prmOptions === 'string' || typeof prmOptions === 'function'
453
+ ? {
454
+ name,
455
+ location: 'path',
456
+ type: prmOptions,
457
+ keyParam: true,
458
+ }
459
+ : {
460
+ ...prmOptions,
461
+ name,
462
+ location: 'path',
463
+ keyParam: true,
464
+ };
465
+ decorator.PathParam(name, paramMeta);
429
466
  decoratorChain.push((meta) => {
430
- meta.path = (meta.path || '') + '@:' + name;
431
- meta.compositionOptions = meta.compositionOptions || {};
432
- meta.compositionOptions.keyParameter = name;
467
+ if (!meta.path?.includes(':' + name))
468
+ meta.path = (meta.path || '') + '@:' + name;
433
469
  });
434
470
  return decorator;
435
471
  };
@@ -31,8 +31,8 @@ class HttpApi extends api_base_js_1.ApiBase {
31
31
  url: this.url,
32
32
  controllers: {},
33
33
  };
34
- for (const [name, v] of this.controllers.entries()) {
35
- out.controllers[name] = v.toJSON();
34
+ for (const v of this.controllers.values()) {
35
+ out.controllers[v.name] = v.toJSON();
36
36
  }
37
37
  return out;
38
38
  }
@@ -109,20 +109,20 @@ class HttpControllerClass extends document_element_js_1.DocumentElement {
109
109
  });
110
110
  if (this.operations.size) {
111
111
  out.operations = {};
112
- for (const [name, v] of this.operations.entries()) {
113
- out.operations[name] = v.toJSON();
112
+ for (const v of this.operations.values()) {
113
+ out.operations[v.name] = v.toJSON();
114
114
  }
115
115
  }
116
116
  if (this.controllers.size) {
117
117
  out.controllers = {};
118
- for (const [name, v] of this.controllers.entries()) {
119
- out.controllers[name] = v.toJSON();
118
+ for (const v of this.controllers.values()) {
119
+ out.controllers[v.name] = v.toJSON();
120
120
  }
121
121
  }
122
122
  if (this.types.size) {
123
123
  out.types = {};
124
- for (const [name, v] of this.types.entries()) {
125
- out.types[name] = v.toJSON();
124
+ for (const v of this.types.values()) {
125
+ out.types[v.name] = v.toJSON();
126
126
  }
127
127
  }
128
128
  if (this.parameters.length) {
@@ -25,6 +25,7 @@ exports.HttpParameter = function (owner, initArgs) {
25
25
  _this.deprecated = initArgs.deprecated;
26
26
  _this.required = initArgs.required;
27
27
  _this.arraySeparator = initArgs.arraySeparator;
28
+ _this.keyParam = initArgs.keyParam;
28
29
  };
29
30
  /**
30
31
  * @class HttpParameter
@@ -36,6 +37,7 @@ class HttpParameterClass extends value_js_1.Value {
36
37
  name: this.name,
37
38
  location: this.location,
38
39
  arraySeparator: this.arraySeparator,
40
+ keyParam: this.keyParam,
39
41
  required: this.required,
40
42
  deprecated: this.deprecated,
41
43
  });
@@ -98,6 +98,31 @@ export function HttpControllerDecoratorFactory(options) {
98
98
  });
99
99
  return decorator;
100
100
  };
101
+ /**
102
+ *
103
+ */
104
+ decorator.KeyParam = (name, arg1) => {
105
+ decoratorChain.push((meta) => {
106
+ if (!meta.path?.includes(':' + name))
107
+ meta.path = (meta.path || '') + '@:' + name;
108
+ const paramMeta = typeof arg1 === 'string' || typeof arg1 === 'function'
109
+ ? {
110
+ name,
111
+ location: 'path',
112
+ type: arg1,
113
+ keyParam: true,
114
+ }
115
+ : {
116
+ ...arg1,
117
+ name,
118
+ location: 'path',
119
+ keyParam: true,
120
+ };
121
+ meta.parameters = meta.parameters || [];
122
+ meta.parameters.push(paramMeta);
123
+ });
124
+ return decorator;
125
+ };
101
126
  /**
102
127
  *
103
128
  */
@@ -91,11 +91,23 @@ HttpOperation.Entity.Delete = function (arg0, arg1) {
91
91
  *
92
92
  */
93
93
  decorator.KeyParam = (name, prmOptions) => {
94
- decorator.PathParam(name, prmOptions);
94
+ const paramMeta = typeof prmOptions === 'string' || typeof prmOptions === 'function'
95
+ ? {
96
+ name,
97
+ location: 'path',
98
+ type: prmOptions,
99
+ keyParam: true,
100
+ }
101
+ : {
102
+ ...prmOptions,
103
+ name,
104
+ location: 'path',
105
+ keyParam: true,
106
+ };
107
+ decorator.PathParam(name, paramMeta);
95
108
  decoratorChain.push((meta) => {
96
- meta.path = (meta.path || '') + '@:' + name;
97
- meta.compositionOptions = meta.compositionOptions || {};
98
- meta.compositionOptions.keyParameter = name;
109
+ if (!meta.path?.includes(':' + name))
110
+ meta.path = (meta.path || '') + '@:' + name;
99
111
  });
100
112
  return decorator;
101
113
  };
@@ -294,11 +306,23 @@ HttpOperation.Entity.Get = function (arg0, arg1) {
294
306
  *
295
307
  */
296
308
  decorator.KeyParam = (name, prmOptions) => {
297
- decorator.PathParam(name, prmOptions);
309
+ const paramMeta = typeof prmOptions === 'string' || typeof prmOptions === 'function'
310
+ ? {
311
+ name,
312
+ location: 'path',
313
+ type: prmOptions,
314
+ keyParam: true,
315
+ }
316
+ : {
317
+ ...prmOptions,
318
+ name,
319
+ location: 'path',
320
+ keyParam: true,
321
+ };
322
+ decorator.PathParam(name, paramMeta);
298
323
  decoratorChain.push((meta) => {
299
- meta.path = (meta.path || '') + '@:' + name;
300
- meta.compositionOptions = meta.compositionOptions || {};
301
- meta.compositionOptions.keyParameter = name;
324
+ if (!meta.path?.includes(':' + name))
325
+ meta.path = (meta.path || '') + '@:' + name;
302
326
  });
303
327
  return decorator;
304
328
  };
@@ -423,11 +447,23 @@ HttpOperation.Entity.Update = function (arg0, arg1) {
423
447
  *
424
448
  */
425
449
  decorator.KeyParam = (name, prmOptions) => {
426
- decorator.PathParam(name, prmOptions);
450
+ const paramMeta = typeof prmOptions === 'string' || typeof prmOptions === 'function'
451
+ ? {
452
+ name,
453
+ location: 'path',
454
+ type: prmOptions,
455
+ keyParam: true,
456
+ }
457
+ : {
458
+ ...prmOptions,
459
+ name,
460
+ location: 'path',
461
+ keyParam: true,
462
+ };
463
+ decorator.PathParam(name, paramMeta);
427
464
  decoratorChain.push((meta) => {
428
- meta.path = (meta.path || '') + '@:' + name;
429
- meta.compositionOptions = meta.compositionOptions || {};
430
- meta.compositionOptions.keyParameter = name;
465
+ if (!meta.path?.includes(':' + name))
466
+ meta.path = (meta.path || '') + '@:' + name;
431
467
  });
432
468
  return decorator;
433
469
  };
@@ -28,8 +28,8 @@ export class HttpApi extends ApiBase {
28
28
  url: this.url,
29
29
  controllers: {},
30
30
  };
31
- for (const [name, v] of this.controllers.entries()) {
32
- out.controllers[name] = v.toJSON();
31
+ for (const v of this.controllers.values()) {
32
+ out.controllers[v.name] = v.toJSON();
33
33
  }
34
34
  return out;
35
35
  }
@@ -106,20 +106,20 @@ class HttpControllerClass extends DocumentElement {
106
106
  });
107
107
  if (this.operations.size) {
108
108
  out.operations = {};
109
- for (const [name, v] of this.operations.entries()) {
110
- out.operations[name] = v.toJSON();
109
+ for (const v of this.operations.values()) {
110
+ out.operations[v.name] = v.toJSON();
111
111
  }
112
112
  }
113
113
  if (this.controllers.size) {
114
114
  out.controllers = {};
115
- for (const [name, v] of this.controllers.entries()) {
116
- out.controllers[name] = v.toJSON();
115
+ for (const v of this.controllers.values()) {
116
+ out.controllers[v.name] = v.toJSON();
117
117
  }
118
118
  }
119
119
  if (this.types.size) {
120
120
  out.types = {};
121
- for (const [name, v] of this.types.entries()) {
122
- out.types[name] = v.toJSON();
121
+ for (const v of this.types.values()) {
122
+ out.types[v.name] = v.toJSON();
123
123
  }
124
124
  }
125
125
  if (this.parameters.length) {
@@ -22,6 +22,7 @@ export const HttpParameter = function (owner, initArgs) {
22
22
  _this.deprecated = initArgs.deprecated;
23
23
  _this.required = initArgs.required;
24
24
  _this.arraySeparator = initArgs.arraySeparator;
25
+ _this.keyParam = initArgs.keyParam;
25
26
  };
26
27
  /**
27
28
  * @class HttpParameter
@@ -33,6 +34,7 @@ class HttpParameterClass extends Value {
33
34
  name: this.name,
34
35
  location: this.location,
35
36
  arraySeparator: this.arraySeparator,
37
+ keyParam: this.keyParam,
36
38
  required: this.required,
37
39
  deprecated: this.deprecated,
38
40
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/common",
3
- "version": "1.0.0-alpha.4",
3
+ "version": "1.0.0-alpha.5",
4
4
  "description": "Opra common package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -6,6 +6,7 @@ export interface HttpControllerDecorator<T extends HttpControllerDecorator<any>
6
6
  Header(name: string | RegExp, optionsOrType?: StrictOmit<HttpParameter.Options, 'location'> | string | TypeThunkAsync | false): T;
7
7
  QueryParam(name: string | RegExp, optionsOrType?: StrictOmit<HttpParameter.Options, 'location'> | string | TypeThunkAsync | false): T;
8
8
  PathParam(name: string | RegExp, optionsOrType?: StrictOmit<HttpParameter.Options, 'location'> | string | TypeThunkAsync | false): T;
9
+ KeyParam(name: string | RegExp, optionsOrType?: StrictOmit<HttpParameter.Options, 'location'> | string | TypeThunkAsync | false): T;
9
10
  UseType(...type: TypeThunkAsync[]): T;
10
11
  }
11
12
  export interface HttpControllerDecoratorFactory {
@@ -12,6 +12,7 @@ export declare namespace HttpParameter {
12
12
  interface Metadata extends StrictOmit<OpraSchema.HttpParameter, 'type'> {
13
13
  name: string | RegExp;
14
14
  type?: string | TypeThunkAsync | EnumType.EnumObject | EnumType.EnumArray | object;
15
+ keyParam?: boolean;
15
16
  }
16
17
  interface Options extends Partial<StrictOmit<Metadata, 'type'>> {
17
18
  type?: string | TypeThunkAsync | object;
@@ -41,6 +42,7 @@ export declare const HttpParameter: HttpParameterStatic;
41
42
  */
42
43
  declare class HttpParameterClass extends Value {
43
44
  readonly owner: DocumentElement;
45
+ keyParam?: boolean;
44
46
  deprecated?: boolean | string;
45
47
  required?: boolean;
46
48
  arraySeparator?: string;
@@ -13,6 +13,10 @@ export interface HttpParameter extends Value {
13
13
  * Name of the parameter. RegExp pattern can be used matching parameter name
14
14
  */
15
15
  name: string | RegExp;
16
+ /**
17
+ * Determines if parameter is key
18
+ */
19
+ keyParam?: boolean;
16
20
  /**
17
21
  * Defines array separator
18
22
  */