@scalar/workspace-store 0.18.0 → 0.18.1
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 +6 -0
- package/dist/events/bus.d.ts +14 -4
- package/dist/events/bus.d.ts.map +1 -1
- package/dist/events/bus.js +12 -10
- package/dist/events/bus.js.map +2 -2
- package/dist/events/definitions/analytics.d.ts +3 -3
- package/dist/events/definitions/analytics.d.ts.map +1 -1
- package/dist/events/definitions/common.d.ts +5 -0
- package/dist/events/definitions/common.d.ts.map +1 -0
- package/dist/events/definitions/common.js +1 -0
- package/dist/events/definitions/common.js.map +7 -0
- package/dist/events/definitions/document.d.ts +2 -2
- package/dist/events/definitions/environment.d.ts +37 -0
- package/dist/events/definitions/environment.d.ts.map +1 -0
- package/dist/events/definitions/environment.js +1 -0
- package/dist/events/definitions/environment.js.map +7 -0
- package/dist/events/definitions/index.d.ts +3 -1
- package/dist/events/definitions/index.d.ts.map +1 -1
- package/dist/events/definitions/meta.d.ts +9 -3
- package/dist/events/definitions/meta.d.ts.map +1 -1
- package/dist/events/index.d.ts +1 -0
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js.map +2 -2
- package/dist/mutators/environment.d.ts +21 -13
- package/dist/mutators/environment.d.ts.map +1 -1
- package/dist/mutators/environment.js +46 -25
- package/dist/mutators/environment.js.map +2 -2
- package/dist/mutators/index.d.ts +4 -12
- package/dist/mutators/index.d.ts.map +1 -1
- package/dist/mutators/index.js +7 -4
- package/dist/mutators/index.js.map +2 -2
- package/dist/schemas/extensions/document/x-scalar-environments.d.ts +52 -0
- package/dist/schemas/extensions/document/x-scalar-environments.d.ts.map +1 -0
- package/dist/schemas/extensions/document/x-scalar-environments.js +25 -0
- package/dist/schemas/extensions/document/x-scalar-environments.js.map +7 -0
- package/dist/schemas/extensions/workspace/x-scalar-active-environment.d.ts +8 -0
- package/dist/schemas/extensions/workspace/x-scalar-active-environment.d.ts.map +1 -0
- package/dist/schemas/extensions/workspace/x-scalar-active-environment.js +8 -0
- package/dist/schemas/extensions/workspace/x-scalar-active-environment.js.map +7 -0
- package/dist/schemas/inmemory-workspace.d.ts +24 -16
- package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
- package/dist/schemas/reference-config/index.d.ts +12 -8
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.d.ts +12 -8
- package/dist/schemas/reference-config/settings.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +411 -276
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.js +5 -5
- package/dist/schemas/v3.1/strict/openapi-document.js.map +2 -2
- package/dist/schemas/workspace-specification/config.d.ts +12 -8
- package/dist/schemas/workspace-specification/config.d.ts.map +1 -1
- package/dist/schemas/workspace-specification/index.d.ts +12 -8
- package/dist/schemas/workspace-specification/index.d.ts.map +1 -1
- package/dist/schemas/workspace.d.ts +115 -75
- package/dist/schemas/workspace.d.ts.map +1 -1
- package/dist/schemas/workspace.js +16 -10
- package/dist/schemas/workspace.js.map +2 -2
- package/package.json +10 -5
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments.d.ts +0 -33
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments.d.ts.map +0 -1
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments.js +0 -23
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments.js.map +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @scalar/workspace-store
|
|
2
2
|
|
|
3
|
+
## 0.18.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#7226](https://github.com/scalar/scalar/pull/7226) [`bffef40`](https://github.com/scalar/scalar/commit/bffef4092e40d12052f8538267af71bc99b7172f) Thanks [@amritk](https://github.com/amritk)! - feat: added overview page for client v2
|
|
8
|
+
|
|
3
9
|
## 0.18.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/events/bus.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import type { ApiReferenceEvents } from './definitions/index.js';
|
|
2
2
|
type Unsubscribe = () => void;
|
|
3
|
+
/**
|
|
4
|
+
* Helper type for event listeners that makes the payload optional
|
|
5
|
+
* if the event allows undefined, otherwise requires it.
|
|
6
|
+
*/
|
|
7
|
+
type EventListener<E extends keyof ApiReferenceEvents> = undefined extends ApiReferenceEvents[E] ? (payload?: ApiReferenceEvents[E]) => void : (payload: ApiReferenceEvents[E]) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Helper type for emit parameters that uses rest parameters
|
|
10
|
+
* for a cleaner API surface.
|
|
11
|
+
*/
|
|
12
|
+
type EmitParameters<E extends keyof ApiReferenceEvents> = undefined extends ApiReferenceEvents[E] ? [event: E, payload?: ApiReferenceEvents[E]] : [event: E, payload: ApiReferenceEvents[E]];
|
|
3
13
|
/**
|
|
4
14
|
* Type-safe event bus for workspace events
|
|
5
15
|
*
|
|
@@ -22,7 +32,7 @@ export type WorkspaceEventBus = {
|
|
|
22
32
|
* // Later, clean up
|
|
23
33
|
* unsubscribe()
|
|
24
34
|
*/
|
|
25
|
-
on<E extends keyof ApiReferenceEvents>(event: E, listener:
|
|
35
|
+
on<E extends keyof ApiReferenceEvents>(event: E, listener: EventListener<E>): Unsubscribe;
|
|
26
36
|
/**
|
|
27
37
|
* Remove a specific event listener
|
|
28
38
|
*
|
|
@@ -34,17 +44,17 @@ export type WorkspaceEventBus = {
|
|
|
34
44
|
* bus.on('scalar-update-sidebar', handler)
|
|
35
45
|
* bus.off('scalar-update-sidebar', handler)
|
|
36
46
|
*/
|
|
37
|
-
off<E extends keyof ApiReferenceEvents>(event: E, listener:
|
|
47
|
+
off<E extends keyof ApiReferenceEvents>(event: E, listener: EventListener<E>): void;
|
|
38
48
|
/**
|
|
39
49
|
* Emit an event with its payload
|
|
40
50
|
*
|
|
41
51
|
* @param event - The event name to emit
|
|
42
|
-
* @param
|
|
52
|
+
* @param payload - The event detail payload (optional if event allows undefined)
|
|
43
53
|
*
|
|
44
54
|
* @example
|
|
45
55
|
* bus.emit('scalar-update-sidebar', { value: true })
|
|
46
56
|
*/
|
|
47
|
-
emit<E extends keyof ApiReferenceEvents>(
|
|
57
|
+
emit<E extends keyof ApiReferenceEvents>(...args: EmitParameters<E>): void;
|
|
48
58
|
};
|
|
49
59
|
/**
|
|
50
60
|
* Options for creating an event bus
|
package/dist/events/bus.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bus.d.ts","sourceRoot":"","sources":["../../src/events/bus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAEvD,KAAK,WAAW,GAAG,MAAM,IAAI,CAAA;AAE7B
|
|
1
|
+
{"version":3,"file":"bus.d.ts","sourceRoot":"","sources":["../../src/events/bus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAEvD,KAAK,WAAW,GAAG,MAAM,IAAI,CAAA;AAE7B;;;GAGG;AACH,KAAK,aAAa,CAAC,CAAC,SAAS,MAAM,kBAAkB,IAAI,SAAS,SAAS,kBAAkB,CAAC,CAAC,CAAC,GAC5F,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAAK,IAAI,GACzC,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAA;AAE5C;;;GAGG;AACH,KAAK,cAAc,CAAC,CAAC,SAAS,MAAM,kBAAkB,IAAI,SAAS,SAAS,kBAAkB,CAAC,CAAC,CAAC,GAC7F,CAAC,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,GAC3C,CAAC,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAA;AAE9C;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;;;;;;;;;;;;OAcG;IACH,EAAE,CAAC,CAAC,SAAS,MAAM,kBAAkB,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,WAAW,CAAA;IAEzF;;;;;;;;;;OAUG;IACH,GAAG,CAAC,CAAC,SAAS,MAAM,kBAAkB,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;IAEnF;;;;;;;;OAQG;IACH,IAAI,CAAC,CAAC,SAAS,MAAM,kBAAkB,EAAE,GAAG,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;CAC3E,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,uBAAuB,GAAI,UAAS,eAAoB,KAAG,iBAoFvE,CAAA"}
|
package/dist/events/bus.js
CHANGED
|
@@ -2,8 +2,11 @@ const createWorkspaceEventBus = (options = {}) => {
|
|
|
2
2
|
const { debug = false } = options;
|
|
3
3
|
const events = /* @__PURE__ */ new Map();
|
|
4
4
|
const getListeners = (event) => {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
let listeners = events.get(event);
|
|
6
|
+
if (!listeners) {
|
|
7
|
+
listeners = /* @__PURE__ */ new Set();
|
|
8
|
+
events.set(event, listeners);
|
|
9
|
+
}
|
|
7
10
|
return listeners;
|
|
8
11
|
};
|
|
9
12
|
const log = (message, ...args) => {
|
|
@@ -14,7 +17,7 @@ const createWorkspaceEventBus = (options = {}) => {
|
|
|
14
17
|
const on = (event, listener) => {
|
|
15
18
|
const listeners = getListeners(event);
|
|
16
19
|
listeners.add(listener);
|
|
17
|
-
log(`Added listener for "${event}" (${listeners.size} total)`);
|
|
20
|
+
log(`Added listener for "${String(event)}" (${listeners.size} total)`);
|
|
18
21
|
return () => off(event, listener);
|
|
19
22
|
};
|
|
20
23
|
const off = (event, listener) => {
|
|
@@ -23,28 +26,27 @@ const createWorkspaceEventBus = (options = {}) => {
|
|
|
23
26
|
return;
|
|
24
27
|
}
|
|
25
28
|
listeners.delete(listener);
|
|
29
|
+
log(`Removed listener for "${String(event)}" (${listeners.size} remaining)`);
|
|
26
30
|
if (listeners.size === 0) {
|
|
27
31
|
events.delete(event);
|
|
28
32
|
}
|
|
29
33
|
};
|
|
30
|
-
const emit = (
|
|
34
|
+
const emit = (...args) => {
|
|
35
|
+
const [event, payload] = args;
|
|
31
36
|
const listeners = events.get(event);
|
|
32
37
|
if (!listeners || listeners.size === 0) {
|
|
33
|
-
log(`No listeners for "${event}"`);
|
|
38
|
+
log(`No listeners for "${String(event)}"`);
|
|
34
39
|
return;
|
|
35
40
|
}
|
|
36
|
-
log(`Emitting "${event}" to ${listeners.size} listener(s)`, payload);
|
|
41
|
+
log(`Emitting "${String(event)}" to ${listeners.size} listener(s)`, payload);
|
|
37
42
|
const listenersArray = Array.from(listeners);
|
|
38
43
|
for (const listener of listenersArray) {
|
|
39
44
|
try {
|
|
40
45
|
listener(payload);
|
|
41
46
|
} catch (error) {
|
|
42
|
-
console.error(`[EventBus] Error in listener for "${event}":`, error);
|
|
47
|
+
console.error(`[EventBus] Error in listener for "${String(event)}":`, error);
|
|
43
48
|
}
|
|
44
49
|
}
|
|
45
|
-
if (listeners.size === 0) {
|
|
46
|
-
events.delete(event);
|
|
47
|
-
}
|
|
48
50
|
};
|
|
49
51
|
return {
|
|
50
52
|
on,
|
package/dist/events/bus.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/events/bus.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ApiReferenceEvents } from './definitions'\n\ntype Unsubscribe = () => void\n\n/**\n * Type-safe event bus for workspace events\n *\n * - Full type safety for event names and payloads\n * - Debug mode for development\n */\nexport type WorkspaceEventBus = {\n /**\n * Subscribe to an event\n *\n * @param event - The event name to listen for\n * @param listener - Callback function that receives the event detail\n * @returns Unsubscribe function to remove the listener\n *\n * @example\n * const unsubscribe = bus.on('scalar-update-sidebar', (detail) => {\n * console.log('Sidebar state:', detail.value)\n * })\n *\n * // Later, clean up\n * unsubscribe()\n */\n on<E extends keyof ApiReferenceEvents>(event: E, listener:
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { ApiReferenceEvents } from './definitions'\n\ntype Unsubscribe = () => void\n\n/**\n * Helper type for event listeners that makes the payload optional\n * if the event allows undefined, otherwise requires it.\n */\ntype EventListener<E extends keyof ApiReferenceEvents> = undefined extends ApiReferenceEvents[E]\n ? (payload?: ApiReferenceEvents[E]) => void\n : (payload: ApiReferenceEvents[E]) => void\n\n/**\n * Helper type for emit parameters that uses rest parameters\n * for a cleaner API surface.\n */\ntype EmitParameters<E extends keyof ApiReferenceEvents> = undefined extends ApiReferenceEvents[E]\n ? [event: E, payload?: ApiReferenceEvents[E]]\n : [event: E, payload: ApiReferenceEvents[E]]\n\n/**\n * Type-safe event bus for workspace events\n *\n * - Full type safety for event names and payloads\n * - Debug mode for development\n */\nexport type WorkspaceEventBus = {\n /**\n * Subscribe to an event\n *\n * @param event - The event name to listen for\n * @param listener - Callback function that receives the event detail\n * @returns Unsubscribe function to remove the listener\n *\n * @example\n * const unsubscribe = bus.on('scalar-update-sidebar', (detail) => {\n * console.log('Sidebar state:', detail.value)\n * })\n *\n * // Later, clean up\n * unsubscribe()\n */\n on<E extends keyof ApiReferenceEvents>(event: E, listener: EventListener<E>): Unsubscribe\n\n /**\n * Remove a specific event listener\n *\n * @param event - The event name\n * @param listener - The listener function to remove\n *\n * @example\n * const handler = (detail) => console.log(detail)\n * bus.on('scalar-update-sidebar', handler)\n * bus.off('scalar-update-sidebar', handler)\n */\n off<E extends keyof ApiReferenceEvents>(event: E, listener: EventListener<E>): void\n\n /**\n * Emit an event with its payload\n *\n * @param event - The event name to emit\n * @param payload - The event detail payload (optional if event allows undefined)\n *\n * @example\n * bus.emit('scalar-update-sidebar', { value: true })\n */\n emit<E extends keyof ApiReferenceEvents>(...args: EmitParameters<E>): void\n}\n\n/**\n * Options for creating an event bus\n */\nexport type EventBusOptions = {\n /**\n * Enable debug mode to log all events and listener operations\n * Useful for development and troubleshooting\n */\n debug?: boolean\n}\n\n/**\n * Creates a type-safe event bus for workspace events\n *\n * This implementation uses a Map for O(1) lookups and maintains\n * a separate Set for each event type to efficiently manage listeners.\n *\n * Create this once per application instance.\n *\n * @param options - Configuration options\n * @returns A fully type-safe event bus instance\n *\n * @example\n * const bus = createWorkspaceEventBus()\n *\n * // Subscribe to events\n * const unsubscribe = bus.on('scalar-update-sidebar', (detail) => {\n * console.log('Sidebar:', detail.value)\n * })\n *\n * // Emit events\n * bus.emit('scalar-update-sidebar', { value: true })\n *\n * // Clean up\n * unsubscribe()\n */\nexport const createWorkspaceEventBus = (options: EventBusOptions = {}): WorkspaceEventBus => {\n const { debug = false } = options\n\n /**\n * Map of event names to their listener sets\n * Using Map for O(1) lookups and Set for O(1) add/remove operations\n */\n type ListenerSet = Set<EventListener<keyof ApiReferenceEvents>>\n const events = new Map<keyof ApiReferenceEvents, ListenerSet>()\n\n /**\n * Get or create a listener set for an event\n */\n const getListeners = <E extends keyof ApiReferenceEvents>(event: E): ListenerSet => {\n let listeners = events.get(event)\n if (!listeners) {\n listeners = new Set()\n events.set(event, listeners)\n }\n return listeners\n }\n\n /**\n * Log debug information if debug mode is enabled\n */\n const log = (message: string, ...args: unknown[]): void => {\n if (debug) {\n console.log(`[EventBus] ${message}`, ...args)\n }\n }\n\n const on = <E extends keyof ApiReferenceEvents>(event: E, listener: EventListener<E>): Unsubscribe => {\n const listeners = getListeners(event)\n listeners.add(listener as EventListener<keyof ApiReferenceEvents>)\n log(`Added listener for \"${String(event)}\" (${listeners.size} total)`)\n\n return () => off(event, listener)\n }\n\n const off = <E extends keyof ApiReferenceEvents>(event: E, listener: EventListener<E>): void => {\n const listeners = events.get(event)\n if (!listeners) {\n return\n }\n\n listeners.delete(listener as EventListener<keyof ApiReferenceEvents>)\n log(`Removed listener for \"${String(event)}\" (${listeners.size} remaining)`)\n\n // Clean up empty listener sets to avoid memory leaks\n if (listeners.size === 0) {\n events.delete(event)\n }\n }\n\n const emit = <E extends keyof ApiReferenceEvents>(...args: EmitParameters<E>): void => {\n const [event, payload] = args\n const listeners = events.get(event)\n\n if (!listeners || listeners.size === 0) {\n log(`No listeners for \"${String(event)}\"`)\n return\n }\n\n log(`Emitting \"${String(event)}\" to ${listeners.size} listener(s)`, payload)\n\n // Convert to array to avoid issues if listeners modify the set during iteration\n const listenersArray = Array.from(listeners)\n\n // Execute all listeners\n for (const listener of listenersArray) {\n try {\n listener(payload)\n } catch (error) {\n // Do not let one listener error break other listeners\n console.error(`[EventBus] Error in listener for \"${String(event)}\":`, error)\n }\n }\n }\n\n return {\n on,\n off,\n emit,\n }\n}\n"],
|
|
5
|
+
"mappings": "AAyGO,MAAM,0BAA0B,CAAC,UAA2B,CAAC,MAAyB;AAC3F,QAAM,EAAE,QAAQ,MAAM,IAAI;AAO1B,QAAM,SAAS,oBAAI,IAA2C;AAK9D,QAAM,eAAe,CAAqC,UAA0B;AAClF,QAAI,YAAY,OAAO,IAAI,KAAK;AAChC,QAAI,CAAC,WAAW;AACd,kBAAY,oBAAI,IAAI;AACpB,aAAO,IAAI,OAAO,SAAS;AAAA,IAC7B;AACA,WAAO;AAAA,EACT;AAKA,QAAM,MAAM,CAAC,YAAoB,SAA0B;AACzD,QAAI,OAAO;AACT,cAAQ,IAAI,cAAc,OAAO,IAAI,GAAG,IAAI;AAAA,IAC9C;AAAA,EACF;AAEA,QAAM,KAAK,CAAqC,OAAU,aAA4C;AACpG,UAAM,YAAY,aAAa,KAAK;AACpC,cAAU,IAAI,QAAmD;AACjE,QAAI,uBAAuB,OAAO,KAAK,CAAC,MAAM,UAAU,IAAI,SAAS;AAErE,WAAO,MAAM,IAAI,OAAO,QAAQ;AAAA,EAClC;AAEA,QAAM,MAAM,CAAqC,OAAU,aAAqC;AAC9F,UAAM,YAAY,OAAO,IAAI,KAAK;AAClC,QAAI,CAAC,WAAW;AACd;AAAA,IACF;AAEA,cAAU,OAAO,QAAmD;AACpE,QAAI,yBAAyB,OAAO,KAAK,CAAC,MAAM,UAAU,IAAI,aAAa;AAG3E,QAAI,UAAU,SAAS,GAAG;AACxB,aAAO,OAAO,KAAK;AAAA,IACrB;AAAA,EACF;AAEA,QAAM,OAAO,IAAwC,SAAkC;AACrF,UAAM,CAAC,OAAO,OAAO,IAAI;AACzB,UAAM,YAAY,OAAO,IAAI,KAAK;AAElC,QAAI,CAAC,aAAa,UAAU,SAAS,GAAG;AACtC,UAAI,qBAAqB,OAAO,KAAK,CAAC,GAAG;AACzC;AAAA,IACF;AAEA,QAAI,aAAa,OAAO,KAAK,CAAC,QAAQ,UAAU,IAAI,gBAAgB,OAAO;AAG3E,UAAM,iBAAiB,MAAM,KAAK,SAAS;AAG3C,eAAW,YAAY,gBAAgB;AACrC,UAAI;AACF,iBAAS,OAAO;AAAA,MAClB,SAAS,OAAO;AAEd,gBAAQ,MAAM,qCAAqC,OAAO,KAAK,CAAC,MAAM,KAAK;AAAA,MAC7E;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -4,7 +4,7 @@ export type AnalyticsEvents = {
|
|
|
4
4
|
/**
|
|
5
5
|
* Fired when a request is sent through the API client
|
|
6
6
|
*/
|
|
7
|
-
'on:send-request': {
|
|
7
|
+
'analytics:on:send-request': {
|
|
8
8
|
/** The HTTP method of the request */
|
|
9
9
|
method: HttpMethod;
|
|
10
10
|
/** The path of the request */
|
|
@@ -15,13 +15,13 @@ export type AnalyticsEvents = {
|
|
|
15
15
|
/**
|
|
16
16
|
* Fired when the user clicks the "Show more" button on the references
|
|
17
17
|
*/
|
|
18
|
-
'on:show-more': {
|
|
18
|
+
'analytics:on:show-more': {
|
|
19
19
|
/** The id of the tag that was opened */
|
|
20
20
|
id: string;
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
23
23
|
* Fired when the references are loaded
|
|
24
24
|
*/
|
|
25
|
-
'on:loaded': undefined;
|
|
25
|
+
'analytics:on:loaded': undefined;
|
|
26
26
|
};
|
|
27
27
|
//# sourceMappingURL=analytics.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,sDAAsD;AACtD,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,
|
|
1
|
+
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,sDAAsD;AACtD,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,2BAA2B,EAAE;QAC3B,qCAAqC;QACrC,MAAM,EAAE,UAAU,CAAA;QAClB,8BAA8B;QAC9B,IAAI,EAAE,MAAM,CAAA;QACZ,8BAA8B;QAC9B,IAAI,EAAE,GAAG,CAAA;KACV,CAAA;IACD;;OAEG;IACH,wBAAwB,EAAE;QACxB,wCAAwC;QACxC,EAAE,EAAE,MAAM,CAAA;KACX,CAAA;IACD;;OAEG;IACH,qBAAqB,EAAE,SAAS,CAAA;CACjC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/common.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,MAAM,MAAM,cAAc,GAAG;IAAE,cAAc,EAAE,UAAU,GAAG,WAAW,CAAA;CAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -5,10 +5,10 @@ export type DocumentEvents = {
|
|
|
5
5
|
/**
|
|
6
6
|
* Update any property in the document info object
|
|
7
7
|
*/
|
|
8
|
-
'update:
|
|
8
|
+
'document:update:info': PartialDeep<InfoObject>;
|
|
9
9
|
/**
|
|
10
10
|
* Update the icon of the active document/workspace
|
|
11
11
|
*/
|
|
12
|
-
'update:
|
|
12
|
+
'document:update:icon': string;
|
|
13
13
|
};
|
|
14
14
|
//# sourceMappingURL=document.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { CollectionType } from '../../events/definitions/common.js';
|
|
2
|
+
import type { XScalarEnvVar, XScalarEnvironment } from '../../schemas/extensions/document/x-scalar-environments.js';
|
|
3
|
+
/** Event definitions for all things environment related */
|
|
4
|
+
export type EnvironmentEvents = {
|
|
5
|
+
/**
|
|
6
|
+
* Add OR update an environment
|
|
7
|
+
*/
|
|
8
|
+
'environment:upsert:environment': {
|
|
9
|
+
environmentName: string;
|
|
10
|
+
payload: Partial<XScalarEnvironment>;
|
|
11
|
+
/** Only needed when renaming the environment */
|
|
12
|
+
oldEnvironmentName?: string;
|
|
13
|
+
} & CollectionType;
|
|
14
|
+
/**
|
|
15
|
+
* Add or update an environment variable
|
|
16
|
+
*/
|
|
17
|
+
'environment:upsert:environment-variable': {
|
|
18
|
+
environmentName: string;
|
|
19
|
+
variable: XScalarEnvVar;
|
|
20
|
+
/** Only needed for update, omit it for add */
|
|
21
|
+
index?: number;
|
|
22
|
+
} & CollectionType;
|
|
23
|
+
/**
|
|
24
|
+
* Delete an environment
|
|
25
|
+
*/
|
|
26
|
+
'environment:delete:environment': {
|
|
27
|
+
environmentName: string;
|
|
28
|
+
} & CollectionType;
|
|
29
|
+
/**
|
|
30
|
+
* Delete an environment variable by index
|
|
31
|
+
*/
|
|
32
|
+
'environment:delete:environment-variable': {
|
|
33
|
+
environmentName: string;
|
|
34
|
+
index: number;
|
|
35
|
+
} & CollectionType;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/environment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAA;AAE5G,2DAA2D;AAC3D,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;OAEG;IACH,gCAAgC,EAAE;QAChC,eAAe,EAAE,MAAM,CAAA;QACvB,OAAO,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAA;QACpC,gDAAgD;QAChD,kBAAkB,CAAC,EAAE,MAAM,CAAA;KAC5B,GAAG,cAAc,CAAA;IAClB;;OAEG;IACH,yCAAyC,EAAE;QACzC,eAAe,EAAE,MAAM,CAAA;QACvB,QAAQ,EAAE,aAAa,CAAA;QACvB,8CAA8C;QAC9C,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,GAAG,cAAc,CAAA;IAClB;;OAEG;IACH,gCAAgC,EAAE;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,GAAG,cAAc,CAAA;IAC9E;;OAEG;IACH,yCAAyC,EAAE;QAAE,eAAe,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,cAAc,CAAA;CACvG,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=environment.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { EnvironmentEvents } from '../../events/definitions/environment.js';
|
|
1
2
|
import type { ServerObject } from '../../schemas/v3.1/strict/openapi-document.js';
|
|
2
3
|
import type { AnalyticsEvents } from './analytics.js';
|
|
3
4
|
import type { AuthEvents } from './auth.js';
|
|
@@ -6,5 +7,6 @@ import type { MetaEvents } from './meta.js';
|
|
|
6
7
|
import type { OperationEvents } from './operation.js';
|
|
7
8
|
import type { ServerEvents } from './server.js';
|
|
8
9
|
import type { UIEvents } from './ui.js';
|
|
9
|
-
export type ApiReferenceEvents<T extends keyof ServerObject = keyof ServerObject> = AuthEvents & AnalyticsEvents & DocumentEvents & MetaEvents & OperationEvents & ServerEvents<T> & UIEvents;
|
|
10
|
+
export type ApiReferenceEvents<T extends keyof ServerObject = keyof ServerObject> = AuthEvents & AnalyticsEvents & DocumentEvents & EnvironmentEvents & MetaEvents & OperationEvents & ServerEvents<T> & UIEvents;
|
|
11
|
+
export type { CollectionType } from './common.js';
|
|
10
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAE1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AAEpC,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,YAAY,GAAG,MAAM,YAAY,IAAI,UAAU,GAC5F,eAAe,GACf,cAAc,GACd,UAAU,GACV,eAAe,GACf,YAAY,CAAC,CAAC,CAAC,GACf,QAAQ,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAE1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AAEpC,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,YAAY,GAAG,MAAM,YAAY,IAAI,UAAU,GAC5F,eAAe,GACf,cAAc,GACd,iBAAiB,GACjB,UAAU,GACV,eAAe,GACf,YAAY,CAAC,CAAC,CAAC,GACf,QAAQ,CAAA;AAEV,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA"}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import type { AvailableClients } from '@scalar/types/snippetz';
|
|
2
2
|
/** Event definitions for the workspace/document meta */
|
|
3
3
|
export type MetaEvents = {
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Update the dark mode theme setting
|
|
6
|
+
*/
|
|
5
7
|
'update:dark-mode': boolean;
|
|
6
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Update the active document on the workspace
|
|
10
|
+
*/
|
|
7
11
|
'update:active-document': string;
|
|
8
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Update the selected client on the workspace
|
|
14
|
+
*/
|
|
9
15
|
'update:selected-client': AvailableClients[number];
|
|
10
16
|
};
|
|
11
17
|
//# sourceMappingURL=meta.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAE9D,wDAAwD;AACxD,MAAM,MAAM,UAAU,GAAG;IACvB
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAE9D,wDAAwD;AACxD,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,kBAAkB,EAAE,OAAO,CAAA;IAC3B;;OAEG;IACH,wBAAwB,EAAE,MAAM,CAAA;IAChC;;OAEG;IACH,wBAAwB,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;CACnD,CAAA"}
|
package/dist/events/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { type WorkspaceEventBus, createWorkspaceEventBus } from './bus.js';
|
|
2
|
+
export type { CollectionType } from './definitions/index.js';
|
|
2
3
|
export { onCustomEvent } from './listeners.js';
|
|
3
4
|
export { type ApiReferenceEvent, type ApiReferenceEvents, emitCustomEvent } from './old-definitions.js';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,OAAO,CAAA;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,OAAO,CAAA;AACvE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA"}
|
package/dist/events/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/events/index.ts"],
|
|
4
|
-
"sourcesContent": ["// biome-ignore lint/performance/noBarrelFile: Entry point for /events\nexport { type WorkspaceEventBus, createWorkspaceEventBus } from './bus'\nexport { onCustomEvent } from './listeners'\nexport { type ApiReferenceEvent, type ApiReferenceEvents, emitCustomEvent } from './old-definitions'\n"],
|
|
5
|
-
"mappings": "AACA,SAAiC,+BAA+B;
|
|
4
|
+
"sourcesContent": ["// biome-ignore lint/performance/noBarrelFile: Entry point for /events\nexport { type WorkspaceEventBus, createWorkspaceEventBus } from './bus'\nexport type { CollectionType } from './definitions'\nexport { onCustomEvent } from './listeners'\nexport { type ApiReferenceEvent, type ApiReferenceEvents, emitCustomEvent } from './old-definitions'\n"],
|
|
5
|
+
"mappings": "AACA,SAAiC,+BAA+B;AAEhE,SAAS,qBAAqB;AAC9B,SAA0D,uBAAuB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { EnvironmentEvents } from '../events/definitions/environment.js';
|
|
2
|
+
import type { Workspace, WorkspaceDocument } from '../schemas.js';
|
|
3
|
+
import { type XScalarEnvVar, type XScalarEnvironment } from '../schemas/extensions/document/x-scalar-environments.js';
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
* Provides functions to add and delete environments from the document's x-scalar-client-config-environments extension.
|
|
5
|
+
* Adds OR updates an environment to the document or workspace.
|
|
6
6
|
*
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
9
|
-
* @
|
|
7
|
+
* @param document - current document if available
|
|
8
|
+
* @param workspace - current workspace if available
|
|
9
|
+
* @param environmentName - Name of the environment to add
|
|
10
|
+
* @param payload - The environment configuration to add
|
|
11
|
+
* @param oldEnvironmentName - Only needed when renaming the environment
|
|
12
|
+
* @returns the parsed environment that was added or updated or undefined if the collection is not found
|
|
10
13
|
*/
|
|
11
|
-
export declare const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
export declare const upsertEnvironment: (document: WorkspaceDocument | null, workspace: Workspace, { environmentName, payload, collectionType, oldEnvironmentName }: EnvironmentEvents["environment:upsert:environment"]) => XScalarEnvironment | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Adds OR updates an environment variable to the document or workspace.
|
|
17
|
+
*
|
|
18
|
+
* @param collection - Workspace OR document
|
|
19
|
+
* @param environmentName - Name of the environment to add the variable to
|
|
20
|
+
* @param variableName - Name of the variable to add
|
|
21
|
+
* @param value - Value of the variable to add
|
|
22
|
+
* @returns the parsed variable that was added or updated or undefined if the collection is not found
|
|
23
|
+
*/
|
|
24
|
+
export declare const upsertEnvironmentVariable: (collection: WorkspaceDocument | Workspace | null, { environmentName, variable, index }: EnvironmentEvents["environment:upsert:environment-variable"]) => XScalarEnvVar | undefined;
|
|
17
25
|
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/mutators/environment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/mutators/environment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7D,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,kBAAkB,EAGxB,MAAM,qDAAqD,CAAA;AAG5D;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAU,iBAAiB,GAAG,IAAI,EAClC,WAAW,SAAS,EACpB,kEAAkE,iBAAiB,CAAC,gCAAgC,CAAC,KACpH,kBAAkB,GAAG,SAqCvB,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,GACpC,YAAY,iBAAiB,GAAG,SAAS,GAAG,IAAI,EAChD,sCAAsC,iBAAiB,CAAC,yCAAyC,CAAC,KACjG,aAAa,GAAG,SA0BlB,CAAA"}
|
|
@@ -1,31 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
xScalarEnvVarSchema,
|
|
3
|
+
xScalarEnvironmentSchema
|
|
4
|
+
} from "../schemas/extensions/document/x-scalar-environments.js";
|
|
5
|
+
import { coerceValue } from "../schemas/typebox-coerce.js";
|
|
6
|
+
const upsertEnvironment = (document, workspace, { environmentName, payload, collectionType, oldEnvironmentName }) => {
|
|
7
|
+
const collection = collectionType === "document" ? document : workspace;
|
|
8
|
+
if (!collection) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (!collection["x-scalar-environments"]) {
|
|
12
|
+
collection["x-scalar-environments"] = {};
|
|
13
|
+
}
|
|
14
|
+
const isNewEnvironment = !collection["x-scalar-environments"][oldEnvironmentName ?? environmentName];
|
|
15
|
+
const parsed = coerceValue(xScalarEnvironmentSchema, {
|
|
16
|
+
...collection["x-scalar-environments"][oldEnvironmentName ?? environmentName],
|
|
17
|
+
...payload
|
|
18
|
+
});
|
|
19
|
+
collection["x-scalar-environments"][environmentName] = parsed;
|
|
20
|
+
if (oldEnvironmentName && oldEnvironmentName !== environmentName) {
|
|
21
|
+
delete collection["x-scalar-environments"][oldEnvironmentName];
|
|
22
|
+
if (workspace["x-scalar-active-environment"] === oldEnvironmentName) {
|
|
23
|
+
workspace["x-scalar-active-environment"] = environmentName;
|
|
5
24
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
}
|
|
26
|
+
if (isNewEnvironment) {
|
|
27
|
+
workspace["x-scalar-active-environment"] = environmentName;
|
|
28
|
+
}
|
|
29
|
+
return parsed;
|
|
30
|
+
};
|
|
31
|
+
const upsertEnvironmentVariable = (collection, { environmentName, variable, index }) => {
|
|
32
|
+
if (!collection?.["x-scalar-environments"]?.[environmentName]) {
|
|
33
|
+
console.error("Environment not found", environmentName);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const parsed = coerceValue(xScalarEnvVarSchema, variable);
|
|
37
|
+
if (index !== void 0) {
|
|
38
|
+
if (parsed.name === "") {
|
|
39
|
+
collection["x-scalar-environments"][environmentName].variables.splice(index, 1);
|
|
40
|
+
return;
|
|
19
41
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
deleteEnvironment
|
|
26
|
-
};
|
|
42
|
+
collection["x-scalar-environments"][environmentName].variables[index] = parsed;
|
|
43
|
+
} else {
|
|
44
|
+
collection["x-scalar-environments"][environmentName].variables.push(parsed);
|
|
45
|
+
}
|
|
46
|
+
return parsed;
|
|
27
47
|
};
|
|
28
48
|
export {
|
|
29
|
-
|
|
49
|
+
upsertEnvironment,
|
|
50
|
+
upsertEnvironmentVariable
|
|
30
51
|
};
|
|
31
52
|
//# sourceMappingURL=environment.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/mutators/environment.ts"],
|
|
4
|
-
"sourcesContent": ["import type {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { EnvironmentEvents } from '@/events/definitions/environment'\nimport type { Workspace, WorkspaceDocument } from '@/schemas'\nimport {\n type XScalarEnvVar,\n type XScalarEnvironment,\n xScalarEnvVarSchema,\n xScalarEnvironmentSchema,\n} from '@/schemas/extensions/document/x-scalar-environments'\nimport { coerceValue } from '@/schemas/typebox-coerce'\n\n/**\n * Adds OR updates an environment to the document or workspace.\n *\n * @param document - current document if available\n * @param workspace - current workspace if available\n * @param environmentName - Name of the environment to add\n * @param payload - The environment configuration to add\n * @param oldEnvironmentName - Only needed when renaming the environment\n * @returns the parsed environment that was added or updated or undefined if the collection is not found\n */\nexport const upsertEnvironment = (\n document: WorkspaceDocument | null,\n workspace: Workspace,\n { environmentName, payload, collectionType, oldEnvironmentName }: EnvironmentEvents['environment:upsert:environment'],\n): XScalarEnvironment | undefined => {\n /** Discriminating between document and workspace */\n const collection = collectionType === 'document' ? document : workspace\n if (!collection) {\n return\n }\n\n if (!collection['x-scalar-environments']) {\n collection['x-scalar-environments'] = {}\n }\n\n // Check if this is a new environment before we create it\n const isNewEnvironment = !collection['x-scalar-environments'][oldEnvironmentName ?? environmentName]\n\n // Ensure we parse the payload but keep the old variables\n const parsed = coerceValue(xScalarEnvironmentSchema, {\n ...collection['x-scalar-environments'][oldEnvironmentName ?? environmentName],\n ...payload,\n })\n collection['x-scalar-environments'][environmentName] = parsed\n\n // If we are renaming the environment, we need to delete the old one\n if (oldEnvironmentName && oldEnvironmentName !== environmentName) {\n delete collection['x-scalar-environments'][oldEnvironmentName]\n\n // If the old environment was active, we need to set the new environment as active\n if (workspace['x-scalar-active-environment'] === oldEnvironmentName) {\n workspace['x-scalar-active-environment'] = environmentName\n }\n }\n\n // Set the newly created workspace environment as active\n if (isNewEnvironment) {\n workspace['x-scalar-active-environment'] = environmentName\n }\n\n return parsed\n}\n\n/**\n * Adds OR updates an environment variable to the document or workspace.\n *\n * @param collection - Workspace OR document\n * @param environmentName - Name of the environment to add the variable to\n * @param variableName - Name of the variable to add\n * @param value - Value of the variable to add\n * @returns the parsed variable that was added or updated or undefined if the collection is not found\n */\nexport const upsertEnvironmentVariable = (\n collection: WorkspaceDocument | Workspace | null,\n { environmentName, variable, index }: EnvironmentEvents['environment:upsert:environment-variable'],\n): XScalarEnvVar | undefined => {\n // The environment should exist by now if we are upserting a variable\n if (!collection?.['x-scalar-environments']?.[environmentName]) {\n console.error('Environment not found', environmentName)\n return\n }\n\n // Ensure we parse the variable for type safety\n const parsed = coerceValue(xScalarEnvVarSchema, variable)\n\n if (index !== undefined) {\n // Delete the row if the name is empty\n if (parsed.name === '') {\n collection['x-scalar-environments'][environmentName].variables.splice(index, 1)\n return\n }\n\n // Update\n collection['x-scalar-environments'][environmentName].variables[index] = parsed\n }\n // Add\n else {\n collection['x-scalar-environments'][environmentName].variables.push(parsed)\n }\n\n return parsed\n}\n"],
|
|
5
|
+
"mappings": "AAEA;AAAA,EAGE;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAYrB,MAAM,oBAAoB,CAC/B,UACA,WACA,EAAE,iBAAiB,SAAS,gBAAgB,mBAAmB,MAC5B;AAEnC,QAAM,aAAa,mBAAmB,aAAa,WAAW;AAC9D,MAAI,CAAC,YAAY;AACf;AAAA,EACF;AAEA,MAAI,CAAC,WAAW,uBAAuB,GAAG;AACxC,eAAW,uBAAuB,IAAI,CAAC;AAAA,EACzC;AAGA,QAAM,mBAAmB,CAAC,WAAW,uBAAuB,EAAE,sBAAsB,eAAe;AAGnG,QAAM,SAAS,YAAY,0BAA0B;AAAA,IACnD,GAAG,WAAW,uBAAuB,EAAE,sBAAsB,eAAe;AAAA,IAC5E,GAAG;AAAA,EACL,CAAC;AACD,aAAW,uBAAuB,EAAE,eAAe,IAAI;AAGvD,MAAI,sBAAsB,uBAAuB,iBAAiB;AAChE,WAAO,WAAW,uBAAuB,EAAE,kBAAkB;AAG7D,QAAI,UAAU,6BAA6B,MAAM,oBAAoB;AACnE,gBAAU,6BAA6B,IAAI;AAAA,IAC7C;AAAA,EACF;AAGA,MAAI,kBAAkB;AACpB,cAAU,6BAA6B,IAAI;AAAA,EAC7C;AAEA,SAAO;AACT;AAWO,MAAM,4BAA4B,CACvC,YACA,EAAE,iBAAiB,UAAU,MAAM,MACL;AAE9B,MAAI,CAAC,aAAa,uBAAuB,IAAI,eAAe,GAAG;AAC7D,YAAQ,MAAM,yBAAyB,eAAe;AACtD;AAAA,EACF;AAGA,QAAM,SAAS,YAAY,qBAAqB,QAAQ;AAExD,MAAI,UAAU,QAAW;AAEvB,QAAI,OAAO,SAAS,IAAI;AACtB,iBAAW,uBAAuB,EAAE,eAAe,EAAE,UAAU,OAAO,OAAO,CAAC;AAC9E;AAAA,IACF;AAGA,eAAW,uBAAuB,EAAE,eAAe,EAAE,UAAU,KAAK,IAAI;AAAA,EAC1E,OAEK;AACH,eAAW,uBAAuB,EAAE,eAAe,EAAE,UAAU,KAAK,MAAM;AAAA,EAC5E;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/mutators/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
/** biome-ignore-all lint/performance/noBarrelFile: this will probably get deleted later */
|
|
1
2
|
import type { WorkspaceStore } from '../client.js';
|
|
2
3
|
/**
|
|
3
4
|
* Generates a set of mutators for managing OpenAPI document and workspace state.
|
|
4
5
|
*
|
|
6
|
+
* @deprecated use the individual mutators instead, this will be removed after we move fully to the new store
|
|
7
|
+
*
|
|
5
8
|
* @param store - The workspace store containing all documents and workspace-level data
|
|
6
9
|
* @returns An object with mutators for the workspace, the active document, and any named document
|
|
7
10
|
*/
|
|
@@ -10,10 +13,6 @@ export declare function generateClientMutators(store: WorkspaceStore): {
|
|
|
10
13
|
* Returns mutators for the workspace-level configuration.
|
|
11
14
|
*/
|
|
12
15
|
workspace: () => {
|
|
13
|
-
environmentMutators: {
|
|
14
|
-
addEnvironment: (name: string, environment: import("../schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments.js").xScalarClientConfigEnvironment) => boolean;
|
|
15
|
-
deleteEnvironment: (environmentName: string) => boolean;
|
|
16
|
-
};
|
|
17
16
|
cookieMutators: {
|
|
18
17
|
addCookie: (cookie: import("../schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.js").XScalarClientConfigCookie) => boolean;
|
|
19
18
|
deleteCookie: (cookieName: string) => boolean;
|
|
@@ -43,10 +42,6 @@ export declare function generateClientMutators(store: WorkspaceStore): {
|
|
|
43
42
|
addSecurityScheme: (name: string, securityScheme: import("../schemas/v3.1/strict/security-scheme.js").SecuritySchemeObject) => boolean;
|
|
44
43
|
deleteSecurityScheme: (name: string) => boolean;
|
|
45
44
|
};
|
|
46
|
-
environmentMutators: {
|
|
47
|
-
addEnvironment: (name: string, environment: import("../schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments.js").xScalarClientConfigEnvironment) => boolean;
|
|
48
|
-
deleteEnvironment: (environmentName: string) => boolean;
|
|
49
|
-
};
|
|
50
45
|
cookieMutators: {
|
|
51
46
|
addCookie: (cookie: import("../schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.js").XScalarClientConfigCookie) => boolean;
|
|
52
47
|
deleteCookie: (cookieName: string) => boolean;
|
|
@@ -73,10 +68,6 @@ export declare function generateClientMutators(store: WorkspaceStore): {
|
|
|
73
68
|
addSecurityScheme: (name: string, securityScheme: import("../schemas/v3.1/strict/security-scheme.js").SecuritySchemeObject) => boolean;
|
|
74
69
|
deleteSecurityScheme: (name: string) => boolean;
|
|
75
70
|
};
|
|
76
|
-
environmentMutators: {
|
|
77
|
-
addEnvironment: (name: string, environment: import("../schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments.js").xScalarClientConfigEnvironment) => boolean;
|
|
78
|
-
deleteEnvironment: (environmentName: string) => boolean;
|
|
79
|
-
};
|
|
80
71
|
cookieMutators: {
|
|
81
72
|
addCookie: (cookie: import("../schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.js").XScalarClientConfigCookie) => boolean;
|
|
82
73
|
deleteCookie: (cookieName: string) => boolean;
|
|
@@ -87,4 +78,5 @@ export declare function generateClientMutators(store: WorkspaceStore): {
|
|
|
87
78
|
};
|
|
88
79
|
};
|
|
89
80
|
};
|
|
81
|
+
export { upsertEnvironment, upsertEnvironmentVariable, } from './environment.js';
|
|
90
82
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mutators/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mutators/index.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAO9C;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc;IA4DxD;;OAEG;;;;;;;;;;;;;;;IAEH;;;OAGG;;;;;;;;;;;;;;;;;;;;;;IAGH;;;;OAIG;gBACS,MAAM;;;;;;;;;;;;;;;;;;;;;EAErB;AAED,OAAO,EACL,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,eAAe,CAAA"}
|