@scalar/oas-utils 0.10.7 → 0.10.9

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.
Files changed (129) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/entities/cookie/cookie.js +11 -15
  3. package/dist/entities/cookie/index.js +1 -5
  4. package/dist/entities/environment/environment.js +7 -11
  5. package/dist/entities/environment/index.js +1 -5
  6. package/dist/entities/hotkeys/hotkeys.js +116 -111
  7. package/dist/entities/hotkeys/index.js +1 -6
  8. package/dist/entities/shared/index.js +1 -7
  9. package/dist/entities/shared/utility.js +9 -9
  10. package/dist/entities/spec/collection.js +91 -89
  11. package/dist/entities/spec/index.js +10 -59
  12. package/dist/entities/spec/operation.js +6 -6
  13. package/dist/entities/spec/parameters.js +38 -38
  14. package/dist/entities/spec/request-examples.js +421 -331
  15. package/dist/entities/spec/requests.js +102 -84
  16. package/dist/entities/spec/server.js +61 -46
  17. package/dist/entities/spec/spec-objects.js +121 -76
  18. package/dist/entities/spec/x-scalar-environments.js +18 -20
  19. package/dist/entities/spec/x-scalar-secrets.js +6 -8
  20. package/dist/entities/workspace/index.js +1 -7
  21. package/dist/entities/workspace/workspace.js +47 -46
  22. package/dist/helpers/client-plugins.js +13 -13
  23. package/dist/helpers/fetch-document.js +30 -25
  24. package/dist/helpers/fetch-with-proxy-fallback.js +26 -21
  25. package/dist/helpers/index.d.ts +1 -2
  26. package/dist/helpers/index.d.ts.map +1 -1
  27. package/dist/helpers/index.js +80 -119
  28. package/dist/helpers/normalize-mime-type-object.js +19 -18
  29. package/dist/helpers/normalize-mime-type.js +11 -9
  30. package/dist/helpers/operation-stability.js +25 -20
  31. package/dist/helpers/parse.d.ts +0 -4
  32. package/dist/helpers/parse.d.ts.map +1 -1
  33. package/dist/helpers/parse.js +77 -77
  34. package/dist/helpers/schema-model.js +13 -16
  35. package/dist/helpers/security/get-schemes.js +7 -8
  36. package/dist/helpers/security/has-token.js +18 -19
  37. package/dist/helpers/security/index.js +2 -7
  38. package/dist/helpers/servers.js +128 -79
  39. package/dist/helpers/should-ignore-entity.js +4 -5
  40. package/dist/migrations/data-version.js +15 -7
  41. package/dist/migrations/generate-types.js +34 -37
  42. package/dist/migrations/index.js +4 -18
  43. package/dist/migrations/local-storage.js +31 -29
  44. package/dist/migrations/migrate-to-indexdb.js +706 -529
  45. package/dist/migrations/migrator.js +58 -54
  46. package/dist/migrations/semver.js +24 -24
  47. package/dist/migrations/v-0.0.0/types.generated.js +1 -1
  48. package/dist/migrations/v-2.1.0/migration.js +272 -258
  49. package/dist/migrations/v-2.1.0/types.generated.js +1 -1
  50. package/dist/migrations/v-2.2.0/migration.js +99 -96
  51. package/dist/migrations/v-2.2.0/types.generated.js +1 -1
  52. package/dist/migrations/v-2.3.0/migration.js +45 -48
  53. package/dist/migrations/v-2.3.0/types.generated.js +1 -1
  54. package/dist/migrations/v-2.4.0/migration.js +25 -25
  55. package/dist/migrations/v-2.4.0/types.generated.js +1 -1
  56. package/dist/migrations/v-2.5.0/migration.js +122 -139
  57. package/dist/migrations/v-2.5.0/types.generated.js +1 -1
  58. package/dist/spec-getters/get-example-from-schema.js +489 -385
  59. package/dist/spec-getters/get-parameters-from-operation.js +39 -23
  60. package/dist/spec-getters/get-request-body-from-operation.d.ts.map +1 -1
  61. package/dist/spec-getters/get-request-body-from-operation.js +168 -126
  62. package/dist/spec-getters/get-server-variable-examples.js +10 -13
  63. package/dist/spec-getters/index.js +4 -11
  64. package/dist/transforms/import-spec.js +381 -291
  65. package/dist/transforms/index.js +1 -11
  66. package/package.json +15 -19
  67. package/dist/entities/cookie/cookie.js.map +0 -7
  68. package/dist/entities/cookie/index.js.map +0 -7
  69. package/dist/entities/environment/environment.js.map +0 -7
  70. package/dist/entities/environment/index.js.map +0 -7
  71. package/dist/entities/hotkeys/hotkeys.js.map +0 -7
  72. package/dist/entities/hotkeys/index.js.map +0 -7
  73. package/dist/entities/shared/index.js.map +0 -7
  74. package/dist/entities/shared/utility.js.map +0 -7
  75. package/dist/entities/spec/collection.js.map +0 -7
  76. package/dist/entities/spec/index.js.map +0 -7
  77. package/dist/entities/spec/operation.js.map +0 -7
  78. package/dist/entities/spec/parameters.js.map +0 -7
  79. package/dist/entities/spec/request-examples.js.map +0 -7
  80. package/dist/entities/spec/requests.js.map +0 -7
  81. package/dist/entities/spec/server.js.map +0 -7
  82. package/dist/entities/spec/spec-objects.js.map +0 -7
  83. package/dist/entities/spec/x-scalar-environments.js.map +0 -7
  84. package/dist/entities/spec/x-scalar-secrets.js.map +0 -7
  85. package/dist/entities/workspace/index.js.map +0 -7
  86. package/dist/entities/workspace/workspace.js.map +0 -7
  87. package/dist/helpers/client-plugins.js.map +0 -7
  88. package/dist/helpers/fetch-document.js.map +0 -7
  89. package/dist/helpers/fetch-with-proxy-fallback.js.map +0 -7
  90. package/dist/helpers/index.js.map +0 -7
  91. package/dist/helpers/normalize-mime-type-object.js.map +0 -7
  92. package/dist/helpers/normalize-mime-type.js.map +0 -7
  93. package/dist/helpers/operation-stability.js.map +0 -7
  94. package/dist/helpers/parse.js.map +0 -7
  95. package/dist/helpers/pretty-print-json.d.ts +0 -9
  96. package/dist/helpers/pretty-print-json.d.ts.map +0 -1
  97. package/dist/helpers/pretty-print-json.js +0 -38
  98. package/dist/helpers/pretty-print-json.js.map +0 -7
  99. package/dist/helpers/schema-model.js.map +0 -7
  100. package/dist/helpers/security/get-schemes.js.map +0 -7
  101. package/dist/helpers/security/has-token.js.map +0 -7
  102. package/dist/helpers/security/index.js.map +0 -7
  103. package/dist/helpers/servers.js.map +0 -7
  104. package/dist/helpers/should-ignore-entity.js.map +0 -7
  105. package/dist/migrations/data-version.js.map +0 -7
  106. package/dist/migrations/generate-types.js.map +0 -7
  107. package/dist/migrations/index.js.map +0 -7
  108. package/dist/migrations/local-storage.js.map +0 -7
  109. package/dist/migrations/migrate-to-indexdb.js.map +0 -7
  110. package/dist/migrations/migrator.js.map +0 -7
  111. package/dist/migrations/semver.js.map +0 -7
  112. package/dist/migrations/v-0.0.0/types.generated.js.map +0 -7
  113. package/dist/migrations/v-2.1.0/migration.js.map +0 -7
  114. package/dist/migrations/v-2.1.0/types.generated.js.map +0 -7
  115. package/dist/migrations/v-2.2.0/migration.js.map +0 -7
  116. package/dist/migrations/v-2.2.0/types.generated.js.map +0 -7
  117. package/dist/migrations/v-2.3.0/migration.js.map +0 -7
  118. package/dist/migrations/v-2.3.0/types.generated.js.map +0 -7
  119. package/dist/migrations/v-2.4.0/migration.js.map +0 -7
  120. package/dist/migrations/v-2.4.0/types.generated.js.map +0 -7
  121. package/dist/migrations/v-2.5.0/migration.js.map +0 -7
  122. package/dist/migrations/v-2.5.0/types.generated.js.map +0 -7
  123. package/dist/spec-getters/get-example-from-schema.js.map +0 -7
  124. package/dist/spec-getters/get-parameters-from-operation.js.map +0 -7
  125. package/dist/spec-getters/get-request-body-from-operation.js.map +0 -7
  126. package/dist/spec-getters/get-server-variable-examples.js.map +0 -7
  127. package/dist/spec-getters/index.js.map +0 -7
  128. package/dist/transforms/import-spec.js.map +0 -7
  129. package/dist/transforms/index.js.map +0 -7
@@ -1,105 +1,108 @@
1
+ /** Migrate security scheme from v-2.1.0 to v-2.2.0 */
1
2
  const migrateSecurityScheme = (scheme, auth) => {
2
- if (scheme.type === "apiKey" && auth.type === "apiKey") {
3
- return {
4
- ...scheme,
5
- value: auth.value
6
- };
7
- }
8
- if (scheme.type === "http" && auth.type === "http") {
9
- return {
10
- ...scheme,
11
- username: auth.username,
12
- password: auth.password,
13
- token: auth.token
14
- };
15
- }
16
- if (scheme.type === "oauth2") {
17
- const { flow, ..._scheme } = scheme;
18
- if (flow.type === "implicit" && auth.type === "oauth-implicit") {
19
- return {
20
- ..._scheme,
21
- flows: {
22
- implicit: {
23
- ...flow,
24
- "scopes": flow.scopes,
25
- "token": auth.token,
26
- "x-scalar-client-id": _scheme["x-scalar-client-id"]
27
- }
28
- }
29
- };
3
+ // API Key
4
+ if (scheme.type === 'apiKey' && auth.type === 'apiKey') {
5
+ return {
6
+ ...scheme,
7
+ value: auth.value,
8
+ };
30
9
  }
31
- if (flow.type === "password" && auth.type === "oauth-password") {
32
- return {
33
- ..._scheme,
34
- flows: {
35
- password: {
36
- ...flow,
37
- "username": auth.username,
38
- "password": auth.password,
39
- "token": auth.token,
40
- "clientSecret": auth.clientSecret,
41
- "scopes": flow.scopes,
42
- "x-scalar-client-id": _scheme["x-scalar-client-id"]
43
- }
44
- }
45
- };
10
+ // HTTP
11
+ if (scheme.type === 'http' && auth.type === 'http') {
12
+ return {
13
+ ...scheme,
14
+ username: auth.username,
15
+ password: auth.password,
16
+ token: auth.token,
17
+ };
46
18
  }
47
- if (flow.type === "clientCredentials" && auth.type === "oauth-clientCredentials") {
48
- return {
49
- ..._scheme,
50
- flows: {
51
- clientCredentials: {
52
- ...flow,
53
- "token": auth.token,
54
- "clientSecret": auth.clientSecret,
55
- "scopes": flow.scopes,
56
- "x-scalar-client-id": _scheme["x-scalar-client-id"]
57
- }
19
+ // OAuth2
20
+ if (scheme.type === 'oauth2') {
21
+ const { flow, ..._scheme } = scheme;
22
+ // Implicit
23
+ if (flow.type === 'implicit' && auth.type === 'oauth-implicit') {
24
+ return {
25
+ ..._scheme,
26
+ flows: {
27
+ implicit: {
28
+ ...flow,
29
+ 'scopes': flow.scopes,
30
+ 'token': auth.token,
31
+ 'x-scalar-client-id': _scheme['x-scalar-client-id'],
32
+ },
33
+ },
34
+ };
58
35
  }
59
- };
60
- }
61
- if (flow.type === "authorizationCode" && auth.type === "oauth-authorizationCode") {
62
- return {
63
- ..._scheme,
64
- flows: {
65
- authorizationCode: {
66
- ...flow,
67
- "token": auth.token,
68
- "clientSecret": auth.clientSecret,
69
- "scopes": flow.scopes,
70
- "x-scalar-client-id": _scheme["x-scalar-client-id"]
71
- }
36
+ // Password
37
+ if (flow.type === 'password' && auth.type === 'oauth-password') {
38
+ return {
39
+ ..._scheme,
40
+ flows: {
41
+ password: {
42
+ ...flow,
43
+ 'username': auth.username,
44
+ 'password': auth.password,
45
+ 'token': auth.token,
46
+ 'clientSecret': auth.clientSecret,
47
+ 'scopes': flow.scopes,
48
+ 'x-scalar-client-id': _scheme['x-scalar-client-id'],
49
+ },
50
+ },
51
+ };
52
+ }
53
+ // Client Credentials
54
+ if (flow.type === 'clientCredentials' && auth.type === 'oauth-clientCredentials') {
55
+ return {
56
+ ..._scheme,
57
+ flows: {
58
+ clientCredentials: {
59
+ ...flow,
60
+ 'token': auth.token,
61
+ 'clientSecret': auth.clientSecret,
62
+ 'scopes': flow.scopes,
63
+ 'x-scalar-client-id': _scheme['x-scalar-client-id'],
64
+ },
65
+ },
66
+ };
67
+ }
68
+ // Authorization Code
69
+ if (flow.type === 'authorizationCode' && auth.type === 'oauth-authorizationCode') {
70
+ return {
71
+ ..._scheme,
72
+ flows: {
73
+ authorizationCode: {
74
+ ...flow,
75
+ 'token': auth.token,
76
+ 'clientSecret': auth.clientSecret,
77
+ 'scopes': flow.scopes,
78
+ 'x-scalar-client-id': _scheme['x-scalar-client-id'],
79
+ },
80
+ },
81
+ };
72
82
  }
73
- };
74
83
  }
75
- }
76
- return null;
84
+ return null;
77
85
  };
78
- const migrate_v_2_2_0 = (data) => {
79
- console.info("Performing data migration v-2.1.0 to v-2.2.0");
80
- const securitySchemes = Object.values(data.securitySchemes).reduce(
81
- (prev, s) => {
82
- const collection = Object.values(data.collections).find((c) => c.securitySchemes.includes(s.uid));
83
- const auth = collection?.auth?.[s.uid];
84
- if (!auth) {
86
+ /** V-2.1.0 to V-2.2.0 migration */
87
+ export const migrate_v_2_2_0 = (data) => {
88
+ console.info('Performing data migration v-2.1.0 to v-2.2.0');
89
+ const securitySchemes = Object.values(data.securitySchemes).reduce((prev, s) => {
90
+ const collection = Object.values(data.collections).find((c) => c.securitySchemes.includes(s.uid));
91
+ const auth = collection?.auth?.[s.uid];
92
+ if (!auth) {
93
+ return prev;
94
+ }
95
+ const newScheme = migrateSecurityScheme(s, auth);
96
+ if (newScheme) {
97
+ prev[s.uid] = newScheme;
98
+ }
85
99
  return prev;
86
- }
87
- const newScheme = migrateSecurityScheme(s, auth);
88
- if (newScheme) {
89
- prev[s.uid] = newScheme;
90
- }
91
- return prev;
92
- },
93
- {}
94
- );
95
- const servers = data.servers;
96
- return {
97
- ...data,
98
- securitySchemes,
99
- servers
100
- };
101
- };
102
- export {
103
- migrate_v_2_2_0
100
+ }, {});
101
+ // No changes to servers
102
+ const servers = data.servers;
103
+ return {
104
+ ...data,
105
+ securitySchemes,
106
+ servers,
107
+ };
104
108
  };
105
- //# sourceMappingURL=migration.js.map
@@ -1 +1 @@
1
- //# sourceMappingURL=types.generated.js.map
1
+ export {};
@@ -1,51 +1,48 @@
1
- const migrate_v_2_3_0 = (data) => {
2
- console.info("Performing data migration v-2.2.0 to v-2.3.0");
3
- const environments = data.environments;
4
- const workspaces = Object.values(data.workspaces).reduce((prev, w) => {
5
- const workspaceEnvironments = {};
6
- Object.entries(environments).forEach(([envId, envData]) => {
7
- const parsedData = typeof envData.value === "string" ? JSON.parse(envData.value) : envData.value;
8
- if (envId === "default") {
9
- Object.assign(workspaceEnvironments, parsedData);
10
- }
11
- });
12
- prev[w.uid] = {
13
- ...w,
14
- environments: workspaceEnvironments
15
- };
16
- return prev;
17
- }, {});
18
- const collections = Object.values(data.collections).reduce((prev, c) => {
19
- prev[c.uid] = {
20
- ...c,
21
- "x-scalar-environments": c["x-scalar-environments"] || {}
22
- };
23
- return prev;
24
- }, {});
25
- Object.values(workspaces).forEach((workspace) => {
26
- Object.entries(environments).forEach(([envKey, envData]) => {
27
- if (envKey !== "default") {
28
- const parsedData = typeof envData.value === "string" ? JSON.parse(envData.value) : envData.value;
29
- const envName = envData.name;
30
- Object.values(collections).forEach((collection) => {
31
- collection["x-scalar-environments"] = collection["x-scalar-environments"] || {};
32
- collection["x-scalar-environments"][envName] = {
33
- variables: parsedData
34
- };
35
- if (workspace.activeEnvironmentId === envKey) {
36
- collection["x-scalar-active-environment"] = envName ?? "";
37
- }
1
+ /** V-2.2.0 to V-2.3.0 migration */
2
+ export const migrate_v_2_3_0 = (data) => {
3
+ console.info('Performing data migration v-2.2.0 to v-2.3.0');
4
+ const environments = data.environments;
5
+ const workspaces = Object.values(data.workspaces).reduce((prev, w) => {
6
+ const workspaceEnvironments = {};
7
+ Object.entries(environments).forEach(([envId, envData]) => {
8
+ const parsedData = typeof envData.value === 'string' ? JSON.parse(envData.value) : envData.value;
9
+ if (envId === 'default') {
10
+ Object.assign(workspaceEnvironments, parsedData);
11
+ }
12
+ });
13
+ prev[w.uid] = {
14
+ ...w,
15
+ environments: workspaceEnvironments,
16
+ };
17
+ return prev;
18
+ }, {});
19
+ const collections = Object.values(data.collections).reduce((prev, c) => {
20
+ prev[c.uid] = {
21
+ ...c,
22
+ 'x-scalar-environments': c['x-scalar-environments'] || {},
23
+ };
24
+ return prev;
25
+ }, {});
26
+ Object.values(workspaces).forEach((workspace) => {
27
+ Object.entries(environments).forEach(([envKey, envData]) => {
28
+ if (envKey !== 'default') {
29
+ const parsedData = typeof envData.value === 'string' ? JSON.parse(envData.value) : envData.value;
30
+ const envName = envData.name;
31
+ Object.values(collections).forEach((collection) => {
32
+ collection['x-scalar-environments'] = collection['x-scalar-environments'] || {};
33
+ collection['x-scalar-environments'][envName] = {
34
+ variables: parsedData,
35
+ };
36
+ if (workspace.activeEnvironmentId === envKey) {
37
+ collection['x-scalar-active-environment'] = envName ?? '';
38
+ }
39
+ });
40
+ }
38
41
  });
39
- }
40
42
  });
41
- });
42
- return {
43
- ...data,
44
- collections,
45
- workspaces
46
- };
47
- };
48
- export {
49
- migrate_v_2_3_0
43
+ return {
44
+ ...data,
45
+ collections,
46
+ workspaces,
47
+ };
50
48
  };
51
- //# sourceMappingURL=migration.js.map
@@ -1 +1 @@
1
- //# sourceMappingURL=types.generated.js.map
1
+ export {};
@@ -1,27 +1,27 @@
1
- const migrate_v_2_4_0 = (data) => {
2
- console.info("Performing data migration v-2.3.0 to v-2.4.0");
3
- const collections = Object.values(data.collections).reduce((prev, c) => {
4
- if (c.info?.title === "Drafts") {
5
- c.servers = [];
6
- Object.values(data.requests).forEach((request) => {
7
- if (request.selectedServerUid && c.requests.includes(request.uid)) {
8
- const server = data.servers[request.selectedServerUid];
9
- if (server) {
10
- request.path = `${server.url}${request.path}`;
11
- }
12
- request.selectedServerUid = "";
1
+ /** V-2.3.0 to V-2.4.0 migration */
2
+ export const migrate_v_2_4_0 = (data) => {
3
+ console.info('Performing data migration v-2.3.0 to v-2.4.0');
4
+ const collections = Object.values(data.collections).reduce((prev, c) => {
5
+ if (c.info?.title === 'Drafts') {
6
+ // Remove the servers from the draft collection
7
+ c.servers = [];
8
+ Object.values(data.requests).forEach((request) => {
9
+ if (request.selectedServerUid && c.requests.includes(request.uid)) {
10
+ const server = data.servers[request.selectedServerUid];
11
+ if (server) {
12
+ // Update the request paths to include the server URL
13
+ request.path = `${server.url}${request.path}`;
14
+ }
15
+ // Remove the selected server UID from the draft request
16
+ request.selectedServerUid = '';
17
+ }
18
+ });
13
19
  }
14
- });
15
- }
16
- prev[c.uid] = c;
17
- return prev;
18
- }, {});
19
- return {
20
- ...data,
21
- collections
22
- };
20
+ prev[c.uid] = c;
21
+ return prev;
22
+ }, {});
23
+ return {
24
+ ...data,
25
+ collections,
26
+ };
23
27
  };
24
- export {
25
- migrate_v_2_4_0
26
- };
27
- //# sourceMappingURL=migration.js.map
@@ -1 +1 @@
1
- //# sourceMappingURL=types.generated.js.map
1
+ export {};
@@ -1,144 +1,127 @@
1
- const migrate_v_2_5_0 = (data) => {
2
- console.info("Performing data migration v-2.4.0 to v-2.5.0");
3
- const cookies = Object.entries(data.cookies || {}).reduce((acc, [key, cookie]) => {
4
- acc[key] = {
5
- ...cookie,
6
- uid: cookie.uid
7
- };
8
- return acc;
9
- }, {});
10
- const collections = Object.entries(data.collections || {}).reduce(
11
- (acc, [key, collection]) => {
12
- acc[key] = {
13
- ...collection,
14
- info: collection.info ?? {
15
- title: "API",
16
- version: "1.0"
17
- },
18
- uid: collection.uid,
19
- selectedSecuritySchemeUids: collection.selectedSecuritySchemeUids,
20
- servers: collection.servers.map((uid) => uid),
21
- tags: collection.tags.map((uid) => uid),
22
- requests: collection.requests.map((uid) => uid),
23
- children: collection.children.map((uid) => uid),
24
- selectedServerUid: collection.selectedServerUid,
25
- useCollectionSecurity: false
26
- };
27
- return acc;
28
- },
29
- {}
30
- );
31
- const environments = Object.entries(data.environments || {}).reduce(
32
- (acc, [key, environment]) => {
33
- acc[key] = {
34
- ...environment,
35
- uid: environment.uid
36
- };
37
- return acc;
38
- },
39
- {}
40
- );
41
- const requests = Object.entries(data.requests || {}).reduce(
42
- (acc, [key, request]) => {
43
- if (request.method === "connect") {
1
+ /** V-2.4.0 to V-2.5.0 migration */
2
+ export const migrate_v_2_5_0 = (data) => {
3
+ console.info('Performing data migration v-2.4.0 to v-2.5.0');
4
+ const cookies = Object.entries(data.cookies || {}).reduce((acc, [key, cookie]) => {
5
+ acc[key] = {
6
+ ...cookie,
7
+ uid: cookie.uid,
8
+ };
9
+ return acc;
10
+ }, {});
11
+ const collections = Object.entries(data.collections || {}).reduce((acc, [key, collection]) => {
12
+ acc[key] = {
13
+ ...collection,
14
+ info: collection.info ?? {
15
+ title: 'API',
16
+ version: '1.0',
17
+ },
18
+ uid: collection.uid,
19
+ selectedSecuritySchemeUids: collection.selectedSecuritySchemeUids,
20
+ servers: collection.servers.map((uid) => uid),
21
+ tags: collection.tags.map((uid) => uid),
22
+ requests: collection.requests.map((uid) => uid),
23
+ children: collection.children.map((uid) => uid),
24
+ selectedServerUid: collection.selectedServerUid,
25
+ useCollectionSecurity: false,
26
+ };
27
+ return acc;
28
+ }, {});
29
+ const environments = Object.entries(data.environments || {}).reduce((acc, [key, environment]) => {
30
+ acc[key] = {
31
+ ...environment,
32
+ uid: environment.uid,
33
+ };
44
34
  return acc;
45
- }
46
- acc[key] = {
47
- ...request,
48
- uid: request.uid,
49
- servers: request.servers,
50
- selectedServerUid: request.selectedServerUid,
51
- examples: request.examples,
52
- selectedSecuritySchemeUids: request.selectedSecuritySchemeUids,
53
- method: request.method
54
- };
55
- return acc;
56
- },
57
- {}
58
- );
59
- const requestExamples = Object.entries(data.requestExamples || {}).reduce(
60
- (acc, [key, example]) => {
61
- const headers = example.parameters.headers;
62
- const hasAcceptHeader = headers.some((header) => header.key.toLowerCase() === "accept");
63
- if (!hasAcceptHeader) {
64
- headers.unshift({ key: "Accept", value: "*/*", enabled: true });
65
- }
66
- acc[key] = {
67
- ...example,
68
- uid: example.uid,
69
- requestUid: example.requestUid,
70
- parameters: {
71
- ...example.parameters,
72
- headers
35
+ }, {});
36
+ const requests = Object.entries(data.requests || {}).reduce((acc, [key, request]) => {
37
+ // Skip 'connect' operations as they are not supported in v-2.5.0
38
+ if (request.method === 'connect') {
39
+ return acc;
73
40
  }
74
- };
75
- return acc;
76
- },
77
- {}
78
- );
79
- const securitySchemes = Object.entries(data.securitySchemes || {}).reduce(
80
- (acc, [key, securityScheme]) => {
81
- acc[key] = {
82
- ...securityScheme,
83
- uid: securityScheme.uid
84
- };
85
- return acc;
86
- },
87
- {}
88
- );
89
- const servers = Object.entries(data.servers || {}).reduce((acc, [key, server]) => {
90
- acc[key] = {
91
- ...server,
92
- uid: server.uid,
93
- variables: Object.entries(server.variables || {}).reduce((variablesAcc, [variableKey, variable]) => {
94
- variablesAcc[variableKey] = {
95
- default: variable.default ?? "",
96
- description: variable.description ?? "",
97
- ...variable.enum?.length && { enum: variable.enum }
41
+ acc[key] = {
42
+ ...request,
43
+ uid: request.uid,
44
+ servers: request.servers,
45
+ selectedServerUid: request.selectedServerUid,
46
+ examples: request.examples,
47
+ selectedSecuritySchemeUids: request.selectedSecuritySchemeUids,
48
+ method: request.method,
98
49
  };
99
- return variablesAcc;
100
- }, {})
101
- };
102
- return acc;
103
- }, {});
104
- const tags = Object.entries(data.tags || {}).reduce((acc, [key, tag]) => {
105
- acc[key] = {
106
- ...tag,
107
- uid: tag.uid,
108
- children: tag.children
109
- };
110
- return acc;
111
- }, {});
112
- const workspaces = Object.entries(data.workspaces || {}).reduce(
113
- (acc, [key, workspace]) => {
114
- acc[key] = {
115
- ...workspace,
116
- uid: workspace.uid,
117
- collections: workspace.collections.map((uid) => uid),
118
- cookies: workspace.cookies.map((uid) => uid),
119
- selectedHttpClient: {
120
- targetKey: "shell",
121
- clientKey: "curl"
50
+ return acc;
51
+ }, {});
52
+ const requestExamples = Object.entries(data.requestExamples || {}).reduce((acc, [key, example]) => {
53
+ const headers = example.parameters.headers;
54
+ // Check if "Accept" header exists
55
+ const hasAcceptHeader = headers.some((header) => header.key.toLowerCase() === 'accept');
56
+ if (!hasAcceptHeader) {
57
+ // Add "Accept" header as the first entry
58
+ headers.unshift({ key: 'Accept', value: '*/*', enabled: true });
122
59
  }
123
- };
124
- return acc;
125
- },
126
- {}
127
- );
128
- return {
129
- ...data,
130
- collections,
131
- cookies,
132
- environments,
133
- requests,
134
- requestExamples,
135
- securitySchemes,
136
- servers,
137
- tags,
138
- workspaces
139
- };
140
- };
141
- export {
142
- migrate_v_2_5_0
60
+ // Update the example with potentially modified headers
61
+ acc[key] = {
62
+ ...example,
63
+ uid: example.uid,
64
+ requestUid: example.requestUid,
65
+ parameters: {
66
+ ...example.parameters,
67
+ headers,
68
+ },
69
+ };
70
+ return acc;
71
+ }, {});
72
+ const securitySchemes = Object.entries(data.securitySchemes || {}).reduce((acc, [key, securityScheme]) => {
73
+ acc[key] = {
74
+ ...securityScheme,
75
+ uid: securityScheme.uid,
76
+ };
77
+ return acc;
78
+ }, {});
79
+ const servers = Object.entries(data.servers || {}).reduce((acc, [key, server]) => {
80
+ acc[key] = {
81
+ ...server,
82
+ uid: server.uid,
83
+ variables: Object.entries(server.variables || {}).reduce((variablesAcc, [variableKey, variable]) => {
84
+ variablesAcc[variableKey] = {
85
+ default: variable.default ?? '',
86
+ description: variable.description ?? '',
87
+ ...(variable.enum?.length && { enum: variable.enum }),
88
+ };
89
+ return variablesAcc;
90
+ }, {}),
91
+ };
92
+ return acc;
93
+ }, {});
94
+ const tags = Object.entries(data.tags || {}).reduce((acc, [key, tag]) => {
95
+ acc[key] = {
96
+ ...tag,
97
+ uid: tag.uid,
98
+ children: tag.children,
99
+ };
100
+ return acc;
101
+ }, {});
102
+ const workspaces = Object.entries(data.workspaces || {}).reduce((acc, [key, workspace]) => {
103
+ acc[key] = {
104
+ ...workspace,
105
+ uid: workspace.uid,
106
+ collections: workspace.collections.map((uid) => uid),
107
+ cookies: workspace.cookies.map((uid) => uid),
108
+ selectedHttpClient: {
109
+ targetKey: 'shell',
110
+ clientKey: 'curl',
111
+ },
112
+ };
113
+ return acc;
114
+ }, {});
115
+ return {
116
+ ...data,
117
+ collections,
118
+ cookies,
119
+ environments,
120
+ requests,
121
+ requestExamples,
122
+ securitySchemes,
123
+ servers,
124
+ tags,
125
+ workspaces,
126
+ };
143
127
  };
144
- //# sourceMappingURL=migration.js.map
@@ -1 +1 @@
1
- //# sourceMappingURL=types.generated.js.map
1
+ export {};