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

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
@@ -2525,14 +2525,25 @@ var HttpControllerClass = class extends DocumentElement {
2525
2525
  return this.controllers.get(arg0);
2526
2526
  }
2527
2527
  findParameter(paramName, location) {
2528
- paramName = paramName.toLowerCase();
2529
- for (const prm of this.parameters) {
2530
- if ((!location || location === prm.location) && (prm.name instanceof RegExp && prm.name.test(paramName) || typeof prm.name === "string" && prm.name.toLowerCase() === paramName))
2528
+ const paramNameLower = paramName.toLowerCase();
2529
+ let prm;
2530
+ for (prm of this.parameters) {
2531
+ if (location && location !== prm.location)
2532
+ continue;
2533
+ if (typeof prm.name === "string") {
2534
+ prm._nameLower = prm._nameLower || prm.name.toLowerCase();
2535
+ if (prm._nameLower === paramNameLower)
2536
+ return prm;
2537
+ }
2538
+ if (prm.name instanceof RegExp && prm.name.test(paramName))
2531
2539
  return prm;
2532
2540
  }
2533
2541
  if (this.node.parent && this.node.parent.element instanceof HttpController2)
2534
2542
  return this.node.parent.element.findParameter(paramName, location);
2535
2543
  }
2544
+ getFullUrl() {
2545
+ return (this.owner instanceof HttpController2 ? this.owner.getFullUrl() : "/") + this.path;
2546
+ }
2536
2547
  /**
2537
2548
  *
2538
2549
  */
@@ -2726,6 +2737,7 @@ var HttpMultipartField = class extends HttpMediaType {
2726
2737
  };
2727
2738
 
2728
2739
  // ../../build/common/esm/document/http/http-operation.js
2740
+ import nodePath from "node:path";
2729
2741
  import { asMutable as asMutable12 } from "ts-gems";
2730
2742
 
2731
2743
  // ../../build/common/esm/document/decorators/http-operation.decorator.js
@@ -3140,12 +3152,24 @@ var HttpOperationClass = class extends DocumentElement {
3140
3152
  __name(this, "HttpOperationClass");
3141
3153
  }
3142
3154
  findParameter(paramName, location) {
3143
- paramName = paramName.toLowerCase();
3144
- for (const prm of this.parameters) {
3145
- if ((!location || location === prm.location) && (prm.name instanceof RegExp && prm.name.test(paramName) || prm.name === paramName))
3155
+ const paramNameLower = paramName.toLowerCase();
3156
+ let prm;
3157
+ for (prm of this.parameters) {
3158
+ if (location && location !== prm.location)
3159
+ continue;
3160
+ if (typeof prm.name === "string") {
3161
+ prm._nameLower = prm._nameLower || prm.name.toLowerCase();
3162
+ if (prm._nameLower === paramNameLower)
3163
+ return prm;
3164
+ }
3165
+ if (prm.name instanceof RegExp && prm.name.test(paramName))
3146
3166
  return prm;
3147
3167
  }
3148
3168
  }
3169
+ getFullUrl() {
3170
+ const out = this.owner.getFullUrl();
3171
+ return out ? this.path ? nodePath.posix.join(out, this.path) : out : this.path || "/";
3172
+ }
3149
3173
  toJSON() {
3150
3174
  const out = omitUndefined({
3151
3175
  kind: OpraSchema.HttpOperation.Kind,
@@ -3368,6 +3392,7 @@ var HttpApiFactory = class {
3368
3392
  */
3369
3393
  static async createApi(context, document, init) {
3370
3394
  const api = new HttpApi(document);
3395
+ api.name = init.name;
3371
3396
  api.description = init.description;
3372
3397
  api.url = init.url;
3373
3398
  if (init.controllers) {
@@ -24,6 +24,7 @@ class HttpApiFactory {
24
24
  */
25
25
  static async createApi(context, document, init) {
26
26
  const api = new http_api_js_1.HttpApi(document);
27
+ api.name = init.name;
27
28
  api.description = init.description;
28
29
  api.url = init.url;
29
30
  if (init.controllers) {
@@ -82,16 +82,25 @@ class HttpControllerClass extends document_element_js_1.DocumentElement {
82
82
  return this.controllers.get(arg0);
83
83
  }
84
84
  findParameter(paramName, location) {
85
- paramName = paramName.toLowerCase();
86
- for (const prm of this.parameters) {
87
- if ((!location || location === prm.location) &&
88
- ((prm.name instanceof RegExp && prm.name.test(paramName)) ||
89
- (typeof prm.name === 'string' && prm.name.toLowerCase() === paramName)))
85
+ const paramNameLower = paramName.toLowerCase();
86
+ let prm;
87
+ for (prm of this.parameters) {
88
+ if (location && location !== prm.location)
89
+ continue;
90
+ if (typeof prm.name === 'string') {
91
+ prm._nameLower = prm._nameLower || prm.name.toLowerCase();
92
+ if (prm._nameLower === paramNameLower)
93
+ return prm;
94
+ }
95
+ if (prm.name instanceof RegExp && prm.name.test(paramName))
90
96
  return prm;
91
97
  }
92
98
  if (this.node.parent && this.node.parent.element instanceof exports.HttpController)
93
99
  return this.node.parent.element.findParameter(paramName, location);
94
100
  }
101
+ getFullUrl() {
102
+ return (this.owner instanceof exports.HttpController ? this.owner.getFullUrl() : '/') + this.path;
103
+ }
95
104
  /**
96
105
  *
97
106
  */
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HttpOperation = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const node_path_1 = tslib_1.__importDefault(require("node:path"));
4
6
  const ts_gems_1 = require("ts-gems");
5
7
  const index_js_1 = require("../../helpers/index.js");
6
8
  const index_js_2 = require("../../schema/index.js");
@@ -39,13 +41,24 @@ exports.HttpOperation = function (...args) {
39
41
  */
40
42
  class HttpOperationClass extends document_element_js_1.DocumentElement {
41
43
  findParameter(paramName, location) {
42
- paramName = paramName.toLowerCase();
43
- for (const prm of this.parameters) {
44
- if ((!location || location === prm.location) &&
45
- ((prm.name instanceof RegExp && prm.name.test(paramName)) || prm.name === paramName))
44
+ const paramNameLower = paramName.toLowerCase();
45
+ let prm;
46
+ for (prm of this.parameters) {
47
+ if (location && location !== prm.location)
48
+ continue;
49
+ if (typeof prm.name === 'string') {
50
+ prm._nameLower = prm._nameLower || prm.name.toLowerCase();
51
+ if (prm._nameLower === paramNameLower)
52
+ return prm;
53
+ }
54
+ if (prm.name instanceof RegExp && prm.name.test(paramName))
46
55
  return prm;
47
56
  }
48
57
  }
58
+ getFullUrl() {
59
+ const out = this.owner.getFullUrl();
60
+ return out ? (this.path ? node_path_1.default.posix.join(out, this.path) : out) : this.path || '/';
61
+ }
49
62
  toJSON() {
50
63
  const out = (0, index_js_1.omitUndefined)({
51
64
  kind: index_js_2.OpraSchema.HttpOperation.Kind,
@@ -21,6 +21,7 @@ export class HttpApiFactory {
21
21
  */
22
22
  static async createApi(context, document, init) {
23
23
  const api = new HttpApi(document);
24
+ api.name = init.name;
24
25
  api.description = init.description;
25
26
  api.url = init.url;
26
27
  if (init.controllers) {
@@ -79,16 +79,25 @@ class HttpControllerClass extends DocumentElement {
79
79
  return this.controllers.get(arg0);
80
80
  }
81
81
  findParameter(paramName, location) {
82
- paramName = paramName.toLowerCase();
83
- for (const prm of this.parameters) {
84
- if ((!location || location === prm.location) &&
85
- ((prm.name instanceof RegExp && prm.name.test(paramName)) ||
86
- (typeof prm.name === 'string' && prm.name.toLowerCase() === paramName)))
82
+ const paramNameLower = paramName.toLowerCase();
83
+ let prm;
84
+ for (prm of this.parameters) {
85
+ if (location && location !== prm.location)
86
+ continue;
87
+ if (typeof prm.name === 'string') {
88
+ prm._nameLower = prm._nameLower || prm.name.toLowerCase();
89
+ if (prm._nameLower === paramNameLower)
90
+ return prm;
91
+ }
92
+ if (prm.name instanceof RegExp && prm.name.test(paramName))
87
93
  return prm;
88
94
  }
89
95
  if (this.node.parent && this.node.parent.element instanceof HttpController)
90
96
  return this.node.parent.element.findParameter(paramName, location);
91
97
  }
98
+ getFullUrl() {
99
+ return (this.owner instanceof HttpController ? this.owner.getFullUrl() : '/') + this.path;
100
+ }
92
101
  /**
93
102
  *
94
103
  */
@@ -1,3 +1,4 @@
1
+ import nodePath from 'node:path';
1
2
  import { asMutable } from 'ts-gems';
2
3
  import { cloneObject, omitUndefined } from '../../helpers/index.js';
3
4
  import { OpraSchema } from '../../schema/index.js';
@@ -36,13 +37,24 @@ export const HttpOperation = function (...args) {
36
37
  */
37
38
  class HttpOperationClass extends DocumentElement {
38
39
  findParameter(paramName, location) {
39
- paramName = paramName.toLowerCase();
40
- for (const prm of this.parameters) {
41
- if ((!location || location === prm.location) &&
42
- ((prm.name instanceof RegExp && prm.name.test(paramName)) || prm.name === paramName))
40
+ const paramNameLower = paramName.toLowerCase();
41
+ let prm;
42
+ for (prm of this.parameters) {
43
+ if (location && location !== prm.location)
44
+ continue;
45
+ if (typeof prm.name === 'string') {
46
+ prm._nameLower = prm._nameLower || prm.name.toLowerCase();
47
+ if (prm._nameLower === paramNameLower)
48
+ return prm;
49
+ }
50
+ if (prm.name instanceof RegExp && prm.name.test(paramName))
43
51
  return prm;
44
52
  }
45
53
  }
54
+ getFullUrl() {
55
+ const out = this.owner.getFullUrl();
56
+ return out ? (this.path ? nodePath.posix.join(out, this.path) : out) : this.path || '/';
57
+ }
46
58
  toJSON() {
47
59
  const out = omitUndefined({
48
60
  kind: OpraSchema.HttpOperation.Kind,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/common",
3
- "version": "1.0.0-alpha.5",
3
+ "version": "1.0.0-alpha.7",
4
4
  "description": "Opra common package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -76,6 +76,7 @@ declare class HttpControllerClass extends DocumentElement {
76
76
  findController(controller: Type): HttpController | undefined;
77
77
  findController(resourcePath: string): HttpController | undefined;
78
78
  findParameter(paramName: string, location?: OpraSchema.HttpParameterLocation): HttpParameter | undefined;
79
+ getFullUrl(): string;
79
80
  /**
80
81
  *
81
82
  */
@@ -79,6 +79,7 @@ declare class HttpOperationClass extends DocumentElement {
79
79
  composition?: string;
80
80
  compositionOptions?: Record<string, any>;
81
81
  findParameter(paramName: string, location?: OpraSchema.HttpParameterLocation): HttpParameter | undefined;
82
+ getFullUrl(): string;
82
83
  toJSON(): OpraSchema.HttpOperation;
83
84
  }
84
85
  export {};
@@ -1,6 +1,5 @@
1
1
  import { Combine, StrictOmit, TypeThunkAsync } from 'ts-gems';
2
2
  import type { OpraSchema } from '../../schema/index.js';
3
- import { HttpParameterLocation } from '../../schema/types.js';
4
3
  import { DocumentElement } from '../common/document-element.js';
5
4
  import { Value } from '../common/value.js';
6
5
  import { DataType } from '../data-type/data-type.js';
@@ -46,7 +45,7 @@ declare class HttpParameterClass extends Value {
46
45
  deprecated?: boolean | string;
47
46
  required?: boolean;
48
47
  arraySeparator?: string;
49
- location: HttpParameterLocation;
48
+ location: OpraSchema.HttpParameterLocation;
50
49
  toJSON(): OpraSchema.HttpParameter;
51
50
  }
52
51
  export {};