@scalar/oas-utils 0.2.73 → 0.2.74

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @scalar/oas-utils
2
2
 
3
+ ## 0.2.74
4
+
5
+ ### Patch Changes
6
+
7
+ - ac55d0f: chore: add time logging for the workspace store
8
+ - Updated dependencies [0c07766]
9
+ - @scalar/themes@0.9.48
10
+
3
11
  ## 0.2.73
4
12
 
5
13
  ### Patch Changes
@@ -15,12 +15,17 @@ export type ImportSpecToWorkspaceArgs = Pick<CollectionPayload, 'documentUrl' |
15
15
  setCollectionSecurity?: boolean;
16
16
  };
17
17
  /**
18
- * Import an OpenAPI spec file and convert it to workspace entities
18
+ * Imports an OpenAPI document and converts it to workspace entities (Collection, Request, Server, etc.)
19
19
  *
20
- * We will aim to keep the entities as close to the specification as possible
21
- * to leverage bi-directional translation. Where entities are able to be
22
- * created and used at various levels we will index via the uids to create
23
- * the relationships
20
+ * The imported entities maintain a close mapping to the original OpenAPI specification to enable:
21
+ * - Bi-directional translation between spec and workspace entities
22
+ * - Preservation of specification details and structure
23
+ * - Accurate representation of relationships between components
24
+ *
25
+ * Relationships between entities are maintained through unique identifiers (UIDs) which allow:
26
+ * - Flexible organization at different levels (workspace, collection, request)
27
+ * - Proper linking between related components
28
+ * - Easy lookup and reference of dependent entities
24
29
  */
25
30
  export declare function importSpecToWorkspace(spec: string | UnknownObject, { authentication, baseServerURL, documentUrl, servers: overloadServers, setCollectionSecurity, watchMode, }?: ImportSpecToWorkspaceArgs): Promise<{
26
31
  error: false;
@@ -1 +1 @@
1
- {"version":3,"file":"import-spec.d.ts","sourceRoot":"","sources":["../../src/transforms/import-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,cAAc,EAGnB,KAAK,MAAM,EACX,KAAK,GAA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;GAYG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,MAAM,GAAG,aAAa,EAC5B,EACE,cAAc,EACd,aAAa,EACb,WAAW,EACX,OAAO,EAAE,eAAe,EACxB,qBAA6B,EAC7B,SAAiB,GAClB,GAAE,yBAA8B,GAChC,OAAO,CACN;IACE,KAAK,EAAE,KAAK,CAAA;IACZ,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,MAAM,EAAE,SAAS,CAAC,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAA;IACjD,QAAQ,EAAE,cAAc,EAAE,CAAA;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,IAAI,EAAE,GAAG,EAAE,CAAA;IACX,eAAe,EAAE,cAAc,EAAE,CAAA;CAClC,GACD;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,cAAc,EAAE,MAAM,EAAE,CAAA;CAAE,CAC5C,CA8SA"}
@@ -86,18 +86,25 @@ const getBaseAuthValues = (scheme, auth) => {
86
86
  };
87
87
  /** Takes a string or object and parses it into an openapi spec compliant schema */
88
88
  const parseSchema = async (spec) => {
89
+ // TODO: Plugins for URLs and files with the proxy is missing here.
90
+ // @see packages/api-reference/src/helpers/parse.ts
89
91
  const { filesystem } = await load(spec);
90
92
  const { specification } = upgrade(filesystem);
91
93
  const { schema, errors = [] } = await dereference(specification);
92
94
  return { schema: schema, errors };
93
95
  };
94
96
  /**
95
- * Import an OpenAPI spec file and convert it to workspace entities
97
+ * Imports an OpenAPI document and converts it to workspace entities (Collection, Request, Server, etc.)
96
98
  *
97
- * We will aim to keep the entities as close to the specification as possible
98
- * to leverage bi-directional translation. Where entities are able to be
99
- * created and used at various levels we will index via the uids to create
100
- * the relationships
99
+ * The imported entities maintain a close mapping to the original OpenAPI specification to enable:
100
+ * - Bi-directional translation between spec and workspace entities
101
+ * - Preservation of specification details and structure
102
+ * - Accurate representation of relationships between components
103
+ *
104
+ * Relationships between entities are maintained through unique identifiers (UIDs) which allow:
105
+ * - Flexible organization at different levels (workspace, collection, request)
106
+ * - Proper linking between related components
107
+ * - Easy lookup and reference of dependent entities
101
108
  */
102
109
  async function importSpecToWorkspace(spec, { authentication, baseServerURL, documentUrl, servers: overloadServers, setCollectionSecurity = false, watchMode = false, } = {}) {
103
110
  const { schema, errors } = await parseSchema(spec);
@@ -106,6 +113,7 @@ async function importSpecToWorkspace(spec, { authentication, baseServerURL, docu
106
113
  return { importWarnings, error: true };
107
114
  // ---------------------------------------------------------------------------
108
115
  // Some entities will be broken out as individual lists for modification in the workspace
116
+ const start = performance.now();
109
117
  const requests = [];
110
118
  // Grab the base server URL for relative servers
111
119
  const backupBaseServerUrl = typeof window !== 'undefined' ? window.location.origin : 'http://localhost';
@@ -324,6 +332,8 @@ async function importSpecToWorkspace(spec, { authentication, baseServerURL, docu
324
332
  },
325
333
  securitySchemes: securitySchemes.map((s) => s.uid),
326
334
  });
335
+ const end = performance.now();
336
+ console.log(`workspace: ${Math.round(end - start)} ms`);
327
337
  /**
328
338
  * Servers and requests will be saved in top level maps and indexed via UID to
329
339
  * maintain specification relationships
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "specification",
17
17
  "yaml"
18
18
  ],
19
- "version": "0.2.73",
19
+ "version": "0.2.74",
20
20
  "engines": {
21
21
  "node": ">=18"
22
22
  },
@@ -108,7 +108,7 @@
108
108
  "zod": "^3.23.8",
109
109
  "@scalar/object-utils": "1.1.12",
110
110
  "@scalar/openapi-types": "0.1.5",
111
- "@scalar/themes": "0.9.47",
111
+ "@scalar/themes": "0.9.48",
112
112
  "@scalar/types": "0.0.19"
113
113
  },
114
114
  "devDependencies": {