@scalar/workspace-store 0.28.3 → 0.28.4
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/mutators/environment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/mutators/environment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AAEzE,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7D,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,kBAAkB,EAGxB,MAAM,qDAAqD,CAAA;AAG5D,KAAK,KAAK,CAAC,CAAC,SAAS,MAAM,iBAAiB,IAAI,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAA;AAE5F;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAC5B,WAAW,SAAS,GAAG,IAAI,EAC3B,YAAY,iBAAiB,GAAG,SAAS,GAAG,IAAI,EAChD,kDAAkD,KAAK,CAAC,gCAAgC,CAAC,KACxF,kBAAkB,GAAG,SAoCvB,CAAA;AAED,eAAO,MAAM,iBAAiB,GAC5B,WAAW,SAAS,GAAG,IAAI,EAC3B,YAAY,iBAAiB,GAAG,SAAS,GAAG,IAAI,EAChD,qBAAqB,KAAK,CAAC,gCAAgC,CAAC,SAO7D,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,GACpC,YAAY,iBAAiB,GAAG,SAAS,GAAG,IAAI,EAChD,sCAAsC,KAAK,CAAC,yCAAyC,CAAC,KACrF,aAAa,GAAG,SA0BlB,CAAA;AAED,eAAO,MAAM,yBAAyB,GACpC,YAAY,iBAAiB,GAAG,SAAS,GAAG,IAAI,EAChD,4BAA4B,KAAK,CAAC,yCAAyC,CAAC,SAO7E,CAAA;AAED,eAAO,MAAM,0BAA0B,GAAI,4BAGxC;IACD,SAAS,EAAE,SAAS,GAAG,IAAI,CAAA;IAC3B,UAAU,EAAE,iBAAiB,GAAG,SAAS,GAAG,IAAI,CAAA;CACjD;iCAEgC,KAAK,CAAC,gCAAgC,CAAC;iCAEvC,KAAK,CAAC,gCAAgC,CAAC;yCAE/B,KAAK,CAAC,yCAAyC,CAAC;yCAEhD,KAAK,CAAC,yCAAyC,CAAC;CAGxF,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { unpackProxyObject } from "../helpers/unpack-proxy.js";
|
|
1
2
|
import {
|
|
2
3
|
xScalarEnvVarSchema,
|
|
3
4
|
xScalarEnvironmentSchema
|
|
@@ -12,7 +13,7 @@ const upsertEnvironment = (workspace, collection, { environmentName, payload, ol
|
|
|
12
13
|
}
|
|
13
14
|
const isNewEnvironment = !collection["x-scalar-environments"][oldEnvironmentName ?? environmentName];
|
|
14
15
|
const parsed = coerceValue(xScalarEnvironmentSchema, {
|
|
15
|
-
...collection["x-scalar-environments"][oldEnvironmentName ?? environmentName],
|
|
16
|
+
...unpackProxyObject(collection["x-scalar-environments"][oldEnvironmentName ?? environmentName], { depth: 1 }),
|
|
16
17
|
...payload
|
|
17
18
|
});
|
|
18
19
|
collection["x-scalar-environments"][environmentName] = parsed;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/mutators/environment.ts"],
|
|
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\ntype Event<T extends keyof EnvironmentEvents> = Omit<EnvironmentEvents[T], 'collectionType'>\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 workspace: Workspace | null,\n collection: WorkspaceDocument | Workspace | null,\n { environmentName, payload, oldEnvironmentName }: Event<'environment:upsert:environment'>,\n): XScalarEnvironment | undefined => {\n /** Discriminating between document and workspace */\n if (!collection || !workspace) {\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\nexport const deleteEnvironment = (\n workspace: Workspace | null,\n collection: WorkspaceDocument | Workspace | null,\n { environmentName }: Event<'environment:delete:environment'>,\n) => {\n if (!collection || !workspace) {\n return\n }\n\n delete collection['x-scalar-environments']?.[environmentName]\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 }: Event<'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\nexport const deleteEnvironmentVariable = (\n collection: WorkspaceDocument | Workspace | null,\n { environmentName, index }: Event<'environment:delete:environment-variable'>,\n) => {\n if (!collection?.['x-scalar-environments']?.[environmentName]) {\n console.error('Environment not found', environmentName)\n return\n }\n collection['x-scalar-environments']?.[environmentName]?.variables?.splice(index, 1)\n}\n\nexport const environmentMutatorsFactory = ({\n workspace,\n collection,\n}: {\n workspace: Workspace | null\n collection: WorkspaceDocument | Workspace | null\n}) => {\n return {\n upsertEnvironment: (payload: Event<'environment:upsert:environment'>) =>\n upsertEnvironment(workspace, collection, payload),\n deleteEnvironment: (payload: Event<'environment:delete:environment'>) =>\n deleteEnvironment(workspace, collection, payload),\n upsertEnvironmentVariable: (payload: Event<'environment:upsert:environment-variable'>) =>\n upsertEnvironmentVariable(collection, payload),\n deleteEnvironmentVariable: (payload: Event<'environment:delete:environment-variable'>) =>\n deleteEnvironmentVariable(collection, payload),\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { EnvironmentEvents } from '@/events/definitions/environment'\nimport { unpackProxyObject } from '@/helpers/unpack-proxy'\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\ntype Event<T extends keyof EnvironmentEvents> = Omit<EnvironmentEvents[T], 'collectionType'>\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 workspace: Workspace | null,\n collection: WorkspaceDocument | Workspace | null,\n { environmentName, payload, oldEnvironmentName }: Event<'environment:upsert:environment'>,\n): XScalarEnvironment | undefined => {\n /** Discriminating between document and workspace */\n if (!collection || !workspace) {\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 ...unpackProxyObject(collection['x-scalar-environments'][oldEnvironmentName ?? environmentName], { depth: 1 }),\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\nexport const deleteEnvironment = (\n workspace: Workspace | null,\n collection: WorkspaceDocument | Workspace | null,\n { environmentName }: Event<'environment:delete:environment'>,\n) => {\n if (!collection || !workspace) {\n return\n }\n\n delete collection['x-scalar-environments']?.[environmentName]\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 }: Event<'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\nexport const deleteEnvironmentVariable = (\n collection: WorkspaceDocument | Workspace | null,\n { environmentName, index }: Event<'environment:delete:environment-variable'>,\n) => {\n if (!collection?.['x-scalar-environments']?.[environmentName]) {\n console.error('Environment not found', environmentName)\n return\n }\n collection['x-scalar-environments']?.[environmentName]?.variables?.splice(index, 1)\n}\n\nexport const environmentMutatorsFactory = ({\n workspace,\n collection,\n}: {\n workspace: Workspace | null\n collection: WorkspaceDocument | Workspace | null\n}) => {\n return {\n upsertEnvironment: (payload: Event<'environment:upsert:environment'>) =>\n upsertEnvironment(workspace, collection, payload),\n deleteEnvironment: (payload: Event<'environment:delete:environment'>) =>\n deleteEnvironment(workspace, collection, payload),\n upsertEnvironmentVariable: (payload: Event<'environment:upsert:environment-variable'>) =>\n upsertEnvironmentVariable(collection, payload),\n deleteEnvironmentVariable: (payload: Event<'environment:delete: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AExD,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;AAEO,MAAM,4BAA4B,CACvC,YACA,EAAE,iBAAiB,MAAM,MACtB;AACH,MAAI,CAAC,aAAa,uBAAuB,IAAI,eAAe,GAAG;AAC7D,YAAQ,MAAM,yBAAyB,eAAe;AACtD;AAAA,EACF;AACA,aAAW,uBAAuB,IAAI,eAAe,GAAG,WAAW,OAAO,OAAO,CAAC;AACpF;AAEO,MAAM,6BAA6B,CAAC;AAAA,EACzC;AAAA,EACA;AACF,MAGM;AACJ,SAAO;AAAA,IACL,mBAAmB,CAAC,YAClB,kBAAkB,WAAW,YAAY,OAAO;AAAA,IAClD,mBAAmB,CAAC,YAClB,kBAAkB,WAAW,YAAY,OAAO;AAAA,IAClD,2BAA2B,CAAC,YAC1B,0BAA0B,YAAY,OAAO;AAAA,IAC/C,2BAA2B,CAAC,YAC1B,0BAA0B,YAAY,OAAO;AAAA,EACjD;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"openapi",
|
|
17
17
|
"scalar"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.28.
|
|
19
|
+
"version": "0.28.4",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
@@ -133,14 +133,14 @@
|
|
|
133
133
|
"type-fest": "^5.3.1",
|
|
134
134
|
"vue": "^3.5.26",
|
|
135
135
|
"yaml": "^2.8.0",
|
|
136
|
-
"@scalar/helpers": "0.2.11",
|
|
137
136
|
"@scalar/code-highlight": "0.2.2",
|
|
138
137
|
"@scalar/json-magic": "0.9.6",
|
|
139
|
-
"@scalar/snippetz": "0.6.11",
|
|
140
|
-
"@scalar/openapi-upgrader": "0.1.8",
|
|
141
138
|
"@scalar/object-utils": "1.2.25",
|
|
139
|
+
"@scalar/openapi-upgrader": "0.1.8",
|
|
140
|
+
"@scalar/helpers": "0.2.11",
|
|
142
141
|
"@scalar/themes": "0.14.0",
|
|
143
|
-
"@scalar/types": "0.6.2"
|
|
142
|
+
"@scalar/types": "0.6.2",
|
|
143
|
+
"@scalar/snippetz": "0.6.11"
|
|
144
144
|
},
|
|
145
145
|
"devDependencies": {
|
|
146
146
|
"@google-cloud/storage": "7.16.0",
|