@sqlrooms/sql-editor-config 0.26.1-rc.4 → 0.26.1-rc.5
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/dist/SqlEditorSliceConfig.d.ts +19 -4
- package/dist/SqlEditorSliceConfig.d.ts.map +1 -1
- package/dist/SqlEditorSliceConfig.js +32 -13
- package/dist/SqlEditorSliceConfig.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
|
|
2
|
+
declare const SqlEditorSliceConfigSchema: z.ZodObject<{
|
|
3
3
|
queries: z.ZodArray<z.ZodObject<{
|
|
4
4
|
id: z.ZodString;
|
|
5
5
|
name: z.ZodString;
|
|
6
6
|
query: z.ZodString;
|
|
7
7
|
}, z.core.$strip>>;
|
|
8
|
-
selectedQueryId: z.
|
|
8
|
+
selectedQueryId: z.ZodString;
|
|
9
9
|
lastExecutedQuery: z.ZodOptional<z.ZodString>;
|
|
10
|
-
|
|
10
|
+
openTabs: z.ZodArray<z.ZodString>;
|
|
11
11
|
}, z.core.$strip>;
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Config schema for the SQL editor slice.
|
|
14
|
+
* Automatically migrates legacy closedTabIds to openTabs format.
|
|
15
|
+
*/
|
|
16
|
+
export declare const SqlEditorSliceConfig: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
|
|
17
|
+
queries: z.ZodArray<z.ZodObject<{
|
|
18
|
+
id: z.ZodString;
|
|
19
|
+
name: z.ZodString;
|
|
20
|
+
query: z.ZodString;
|
|
21
|
+
}, z.core.$strip>>;
|
|
22
|
+
selectedQueryId: z.ZodString;
|
|
23
|
+
lastExecutedQuery: z.ZodOptional<z.ZodString>;
|
|
24
|
+
openTabs: z.ZodArray<z.ZodString>;
|
|
25
|
+
}, z.core.$strip>>;
|
|
26
|
+
export type SqlEditorSliceConfig = z.infer<typeof SqlEditorSliceConfigSchema>;
|
|
13
27
|
export declare function createDefaultSqlEditorConfig(): SqlEditorSliceConfig;
|
|
28
|
+
export {};
|
|
14
29
|
//# sourceMappingURL=SqlEditorSliceConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqlEditorSliceConfig.d.ts","sourceRoot":"","sources":["../src/SqlEditorSliceConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"SqlEditorSliceConfig.d.ts","sourceRoot":"","sources":["../src/SqlEditorSliceConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAQtB,QAAA,MAAM,0BAA0B;;;;;;;;;iBAO9B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;kBAoBH,CAAC;AAE/B,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,wBAAgB,4BAA4B,IAAI,oBAAoB,CAMnE"}
|
|
@@ -1,26 +1,45 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
const QuerySchema = z.object({
|
|
3
|
+
id: z.string().describe('Query identifier.'),
|
|
4
|
+
name: z.string().describe('Query name.'),
|
|
5
|
+
query: z.string().describe('SQL query to execute.'),
|
|
6
|
+
});
|
|
7
|
+
const SqlEditorSliceConfigSchema = z.object({
|
|
8
|
+
queries: z.array(QuerySchema),
|
|
9
9
|
selectedQueryId: z
|
|
10
10
|
.string()
|
|
11
|
-
.default('default')
|
|
12
11
|
.describe('The id of the currently selected query.'),
|
|
13
12
|
lastExecutedQuery: z.string().optional().describe('Last executed query'),
|
|
14
|
-
|
|
15
|
-
.array(z.string())
|
|
16
|
-
.default([])
|
|
17
|
-
.describe('List of closed tab ids'),
|
|
13
|
+
openTabs: z.array(z.string()).describe('IDs of open tabs'),
|
|
18
14
|
});
|
|
15
|
+
/**
|
|
16
|
+
* Config schema for the SQL editor slice.
|
|
17
|
+
* Automatically migrates legacy closedTabIds to openTabs format.
|
|
18
|
+
*/
|
|
19
|
+
export const SqlEditorSliceConfig = z.preprocess((data) => {
|
|
20
|
+
if (typeof data !== 'object' || data === null)
|
|
21
|
+
return data;
|
|
22
|
+
const obj = data;
|
|
23
|
+
// If already has openTabs, no migration needed
|
|
24
|
+
if ('openTabs' in obj)
|
|
25
|
+
return data;
|
|
26
|
+
// Migrate from closedTabIds to openTabs
|
|
27
|
+
if ('closedTabIds' in obj && 'queries' in obj) {
|
|
28
|
+
const closedTabIds = obj.closedTabIds;
|
|
29
|
+
const queries = obj.queries;
|
|
30
|
+
const openTabs = queries
|
|
31
|
+
.map((q) => q.id)
|
|
32
|
+
.filter((id) => !closedTabIds.includes(id));
|
|
33
|
+
const { closedTabIds: _, ...rest } = obj;
|
|
34
|
+
return { ...rest, openTabs };
|
|
35
|
+
}
|
|
36
|
+
return data;
|
|
37
|
+
}, SqlEditorSliceConfigSchema);
|
|
19
38
|
export function createDefaultSqlEditorConfig() {
|
|
20
39
|
return {
|
|
21
40
|
queries: [{ id: 'default', name: 'SQL', query: '' }],
|
|
22
41
|
selectedQueryId: 'default',
|
|
23
|
-
|
|
42
|
+
openTabs: ['default'],
|
|
24
43
|
};
|
|
25
44
|
}
|
|
26
45
|
//# sourceMappingURL=SqlEditorSliceConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqlEditorSliceConfig.js","sourceRoot":"","sources":["../src/SqlEditorSliceConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,
|
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AY,GAAG,GAAG,CAAC,YAAwB,CAAC;QAClD,MAAM,OAAO,GAAG,GAAG,CAAC,OAA8B,CAAC;QACnD,MAAM,QAAQ,GAAG,OAAO;aACrB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAChB,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QAE9C,MAAM,EAAC,YAAY,EAAE,CAAC,EAAE,GAAG,IAAI,EAAC,GAAG,GAAG,CAAC;QACvC,OAAO,EAAC,GAAG,IAAI,EAAE,QAAQ,EAAC,CAAC;IAC7B,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,EAAE,0BAA0B,CAAC,CAAC;AAI/B,MAAM,UAAU,4BAA4B;IAC1C,OAAO;QACL,OAAO,EAAE,CAAC,EAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAC,CAAC;QAClD,eAAe,EAAE,SAAS;QAC1B,QAAQ,EAAE,CAAC,SAAS,CAAC;KACtB,CAAC;AACJ,CAAC","sourcesContent":["import {z} from 'zod';\n\nconst QuerySchema = z.object({\n id: z.string().describe('Query identifier.'),\n name: z.string().describe('Query name.'),\n query: z.string().describe('SQL query to execute.'),\n});\n\nconst SqlEditorSliceConfigSchema = z.object({\n queries: z.array(QuerySchema),\n selectedQueryId: z\n .string()\n .describe('The id of the currently selected query.'),\n lastExecutedQuery: z.string().optional().describe('Last executed query'),\n openTabs: z.array(z.string()).describe('IDs of open tabs'),\n});\n\n/**\n * Config schema for the SQL editor slice.\n * Automatically migrates legacy closedTabIds to openTabs format.\n */\nexport const SqlEditorSliceConfig = z.preprocess((data) => {\n if (typeof data !== 'object' || data === null) return data;\n const obj = data as Record<string, unknown>;\n\n // If already has openTabs, no migration needed\n if ('openTabs' in obj) return data;\n\n // Migrate from closedTabIds to openTabs\n if ('closedTabIds' in obj && 'queries' in obj) {\n const closedTabIds = obj.closedTabIds as string[];\n const queries = obj.queries as Array<{id: string}>;\n const openTabs = queries\n .map((q) => q.id)\n .filter((id) => !closedTabIds.includes(id));\n\n const {closedTabIds: _, ...rest} = obj;\n return {...rest, openTabs};\n }\n\n return data;\n}, SqlEditorSliceConfigSchema);\n\nexport type SqlEditorSliceConfig = z.infer<typeof SqlEditorSliceConfigSchema>;\n\nexport function createDefaultSqlEditorConfig(): SqlEditorSliceConfig {\n return {\n queries: [{id: 'default', name: 'SQL', query: ''}],\n selectedQueryId: 'default',\n openTabs: ['default'],\n };\n}\n"]}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
* {@include ../README.md}
|
|
3
3
|
* @packageDocumentation
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
// Values also export their corresponding types automatically (Zod pattern)
|
|
6
|
+
export { SqlEditorSliceConfig, createDefaultSqlEditorConfig, } from './SqlEditorSliceConfig';
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,2EAA2E;AAC3E,OAAO,EACL,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC","sourcesContent":["/**\n * {@include ../README.md}\n * @packageDocumentation\n */\n\n// Values also export their corresponding types automatically (Zod pattern)\nexport {\n SqlEditorSliceConfig,\n createDefaultSqlEditorConfig,\n} from './SqlEditorSliceConfig';\n"]}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqlrooms/sql-editor-config",
|
|
3
|
-
"version": "0.26.1-rc.
|
|
3
|
+
"version": "0.26.1-rc.5",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"type": "module",
|
|
8
|
+
"sideEffects": false,
|
|
8
9
|
"author": "Ilya Boyandin <ilya@boyandin.me>",
|
|
9
10
|
"license": "MIT",
|
|
10
11
|
"repository": {
|
|
@@ -27,5 +28,5 @@
|
|
|
27
28
|
"typecheck": "tsc --noEmit",
|
|
28
29
|
"typedoc": "typedoc"
|
|
29
30
|
},
|
|
30
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "1df21f4729c5deb96f7af790cff7c189c6885074"
|
|
31
32
|
}
|