@opra/common 1.0.0-alpha.10 → 1.0.0-alpha.12

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
@@ -828,6 +828,7 @@ __name(ComplexTypeDecorator, "ComplexTypeDecorator");
828
828
  import { asMutable as asMutable4 } from "ts-gems";
829
829
 
830
830
  // ../../build/common/esm/document/common/document-element.js
831
+ import crypto from "node:crypto";
831
832
  import { asMutable } from "ts-gems";
832
833
 
833
834
  // ../../build/common/esm/document/common/document-node.js
@@ -953,6 +954,7 @@ var DocumentElement = /* @__PURE__ */ __name(function(owner) {
953
954
  if (!this)
954
955
  throw new TypeError('"this" should be passed to call class constructor');
955
956
  const _this = asMutable(this);
957
+ _this.id = crypto.randomBytes(16).toString("base64url");
956
958
  Object.defineProperty(_this, "node", {
957
959
  value: new DocumentNode(this, owner?.node),
958
960
  enumerable: false,
@@ -2316,7 +2318,6 @@ var ApiBase = class extends DocumentElement {
2316
2318
  };
2317
2319
 
2318
2320
  // ../../build/common/esm/document/http/http-controller.js
2319
- import nodePath from "node:path";
2320
2321
  import { asMutable as asMutable10 } from "ts-gems";
2321
2322
 
2322
2323
  // ../../build/common/esm/document/common/data-type-map.js
@@ -2572,7 +2573,8 @@ var HttpControllerClass = class extends DocumentElement {
2572
2573
  }
2573
2574
  }
2574
2575
  getFullUrl() {
2575
- return nodePath.posix.join(this.owner instanceof HttpController2 ? this.owner.getFullUrl() : "/", this.path);
2576
+ const out = this.owner instanceof HttpController2 ? this.owner.getFullUrl() : "/";
2577
+ return out + this.path;
2576
2578
  }
2577
2579
  /**
2578
2580
  *
@@ -2769,7 +2771,7 @@ var HttpMultipartField = class extends HttpMediaType {
2769
2771
  };
2770
2772
 
2771
2773
  // ../../build/common/esm/document/http/http-operation.js
2772
- import nodePath2 from "node:path";
2774
+ import nodePath from "node:path";
2773
2775
  import { asMutable as asMutable12 } from "ts-gems";
2774
2776
 
2775
2777
  // ../../build/common/esm/document/decorators/http-operation.decorator.js
@@ -3200,13 +3202,14 @@ var HttpOperationClass = class extends DocumentElement {
3200
3202
  }
3201
3203
  getFullUrl() {
3202
3204
  const out = this.owner.getFullUrl();
3203
- return out ? this.path ? nodePath2.posix.join(out, this.path) : out : this.path || "/";
3205
+ return out ? this.path ? nodePath.posix.join(out, this.path) : out : this.path || "/";
3204
3206
  }
3205
3207
  toJSON() {
3206
3208
  const out = omitUndefined({
3207
3209
  kind: OpraSchema.HttpOperation.Kind,
3208
3210
  description: this.description,
3209
3211
  method: this.method,
3212
+ path: this.path,
3210
3213
  composition: this.composition,
3211
3214
  requestBody: this.requestBody?.toJSON()
3212
3215
  });
@@ -13109,7 +13112,7 @@ function getDataTypeName(typ) {
13109
13112
  __name(getDataTypeName, "getDataTypeName");
13110
13113
 
13111
13114
  // ../../build/common/esm/document/factory/api-document.factory.js
13112
- import crypto from "node:crypto";
13115
+ import crypto2 from "node:crypto";
13113
13116
  import { asMutable as asMutable15 } from "ts-gems";
13114
13117
  var OPRA_SPEC_URL = "https://oprajs.com/spec/v" + OpraSchema.SpecVersion;
13115
13118
  var ApiDocumentFactory = class _ApiDocumentFactory {
@@ -13161,9 +13164,14 @@ var ApiDocumentFactory = class _ApiDocumentFactory {
13161
13164
  init.url = schemaOrUrl;
13162
13165
  } else
13163
13166
  init = schemaOrUrl;
13167
+ let builtinDocument;
13164
13168
  if (!document[BUILTIN]) {
13165
- const builtinDocument = await this.createBuiltinDocument(context);
13166
- document.references.set("opra", builtinDocument);
13169
+ const t = document.node.findDataType("string");
13170
+ builtinDocument = t?.node.getDocument();
13171
+ if (!builtinDocument) {
13172
+ builtinDocument = await this.createBuiltinDocument(context);
13173
+ document.references.set("opra", builtinDocument);
13174
+ }
13167
13175
  }
13168
13176
  init.spec = init.spec || OpraSchema.SpecVersion;
13169
13177
  document.url = init.url;
@@ -13183,6 +13191,8 @@ var ApiDocumentFactory = class _ApiDocumentFactory {
13183
13191
  return;
13184
13192
  }
13185
13193
  const refDoc = new ApiDocument();
13194
+ if (builtinDocument)
13195
+ refDoc.references.set("opra", builtinDocument);
13186
13196
  await this.initDocument(refDoc, context, r);
13187
13197
  document.references.set(ns, refDoc);
13188
13198
  });
@@ -13205,7 +13215,7 @@ var ApiDocumentFactory = class _ApiDocumentFactory {
13205
13215
  });
13206
13216
  }
13207
13217
  const x = document.export();
13208
- asMutable15(document).id = crypto.createHash("md5").update(JSON.stringify(x)).digest("base64url");
13218
+ asMutable15(document).id = crypto2.createHash("md5").update(JSON.stringify(x)).digest("base64url");
13209
13219
  }
13210
13220
  /**
13211
13221
  *
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DocumentElement = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const node_crypto_1 = tslib_1.__importDefault(require("node:crypto"));
4
6
  const ts_gems_1 = require("ts-gems");
5
7
  const document_node_js_1 = require("./document-node.js");
6
8
  /**
@@ -11,6 +13,7 @@ exports.DocumentElement = function (owner) {
11
13
  if (!this)
12
14
  throw new TypeError('"this" should be passed to call class constructor');
13
15
  const _this = (0, ts_gems_1.asMutable)(this);
16
+ _this.id = node_crypto_1.default.randomBytes(16).toString('base64url');
14
17
  Object.defineProperty(_this, 'node', {
15
18
  value: new document_node_js_1.DocumentNode(this, owner?.node),
16
19
  enumerable: false,
@@ -68,9 +68,14 @@ class ApiDocumentFactory {
68
68
  else
69
69
  init = schemaOrUrl;
70
70
  // Add builtin data types if this document is the root
71
+ let builtinDocument;
71
72
  if (!document[constants_js_1.BUILTIN]) {
72
- const builtinDocument = await this.createBuiltinDocument(context);
73
- document.references.set('opra', builtinDocument);
73
+ const t = document.node.findDataType('string');
74
+ builtinDocument = t?.node.getDocument();
75
+ if (!builtinDocument) {
76
+ builtinDocument = await this.createBuiltinDocument(context);
77
+ document.references.set('opra', builtinDocument);
78
+ }
74
79
  }
75
80
  init.spec = init.spec || index_js_2.OpraSchema.SpecVersion;
76
81
  document.url = init.url;
@@ -91,6 +96,8 @@ class ApiDocumentFactory {
91
96
  return;
92
97
  }
93
98
  const refDoc = new api_document_js_1.ApiDocument();
99
+ if (builtinDocument)
100
+ refDoc.references.set('opra', builtinDocument);
94
101
  await this.initDocument(refDoc, context, r);
95
102
  document.references.set(ns, refDoc);
96
103
  });
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HttpController = void 0;
4
- const tslib_1 = require("tslib");
5
- const node_path_1 = tslib_1.__importDefault(require("node:path"));
6
4
  const ts_gems_1 = require("ts-gems");
7
5
  const index_js_1 = require("../../helpers/index.js");
8
6
  const index_js_2 = require("../../schema/index.js");
@@ -102,7 +100,8 @@ class HttpControllerClass extends document_element_js_1.DocumentElement {
102
100
  }
103
101
  }
104
102
  getFullUrl() {
105
- return node_path_1.default.posix.join(this.owner instanceof exports.HttpController ? this.owner.getFullUrl() : '/', this.path);
103
+ const out = this.owner instanceof exports.HttpController ? this.owner.getFullUrl() : '/';
104
+ return out + this.path;
106
105
  }
107
106
  /**
108
107
  *
@@ -64,6 +64,7 @@ class HttpOperationClass extends document_element_js_1.DocumentElement {
64
64
  kind: index_js_2.OpraSchema.HttpOperation.Kind,
65
65
  description: this.description,
66
66
  method: this.method,
67
+ path: this.path,
67
68
  composition: this.composition,
68
69
  requestBody: this.requestBody?.toJSON(),
69
70
  });
@@ -1,3 +1,4 @@
1
+ import crypto from 'node:crypto';
1
2
  import { asMutable } from 'ts-gems';
2
3
  import { DocumentNode } from './document-node.js';
3
4
  /**
@@ -8,6 +9,7 @@ export const DocumentElement = function (owner) {
8
9
  if (!this)
9
10
  throw new TypeError('"this" should be passed to call class constructor');
10
11
  const _this = asMutable(this);
12
+ _this.id = crypto.randomBytes(16).toString('base64url');
11
13
  Object.defineProperty(_this, 'node', {
12
14
  value: new DocumentNode(this, owner?.node),
13
15
  enumerable: false,
@@ -64,9 +64,14 @@ export class ApiDocumentFactory {
64
64
  else
65
65
  init = schemaOrUrl;
66
66
  // Add builtin data types if this document is the root
67
+ let builtinDocument;
67
68
  if (!document[BUILTIN]) {
68
- const builtinDocument = await this.createBuiltinDocument(context);
69
- document.references.set('opra', builtinDocument);
69
+ const t = document.node.findDataType('string');
70
+ builtinDocument = t?.node.getDocument();
71
+ if (!builtinDocument) {
72
+ builtinDocument = await this.createBuiltinDocument(context);
73
+ document.references.set('opra', builtinDocument);
74
+ }
70
75
  }
71
76
  init.spec = init.spec || OpraSchema.SpecVersion;
72
77
  document.url = init.url;
@@ -87,6 +92,8 @@ export class ApiDocumentFactory {
87
92
  return;
88
93
  }
89
94
  const refDoc = new ApiDocument();
95
+ if (builtinDocument)
96
+ refDoc.references.set('opra', builtinDocument);
90
97
  await this.initDocument(refDoc, context, r);
91
98
  document.references.set(ns, refDoc);
92
99
  });
@@ -1,4 +1,3 @@
1
- import nodePath from 'node:path';
2
1
  import { asMutable } from 'ts-gems';
3
2
  import { omitUndefined, ResponsiveMap } from '../../helpers/index.js';
4
3
  import { OpraSchema } from '../../schema/index.js';
@@ -98,7 +97,8 @@ class HttpControllerClass extends DocumentElement {
98
97
  }
99
98
  }
100
99
  getFullUrl() {
101
- return nodePath.posix.join(this.owner instanceof HttpController ? this.owner.getFullUrl() : '/', this.path);
100
+ const out = this.owner instanceof HttpController ? this.owner.getFullUrl() : '/';
101
+ return out + this.path;
102
102
  }
103
103
  /**
104
104
  *
@@ -60,6 +60,7 @@ class HttpOperationClass extends DocumentElement {
60
60
  kind: OpraSchema.HttpOperation.Kind,
61
61
  description: this.description,
62
62
  method: this.method,
63
+ path: this.path,
63
64
  composition: this.composition,
64
65
  requestBody: this.requestBody?.toJSON(),
65
66
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/common",
3
- "version": "1.0.0-alpha.10",
3
+ "version": "1.0.0-alpha.12",
4
4
  "description": "Opra common package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -17,6 +17,7 @@ export declare const DocumentElement: DocumentElementConstructor;
17
17
  * @class DocumentElement
18
18
  */
19
19
  declare abstract class DocumentElementClass {
20
+ readonly id: string;
20
21
  readonly owner?: DocumentElement;
21
22
  readonly node: DocumentNode;
22
23
  }