@pikku/cli 0.9.6 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @pikku/cli
2
2
 
3
+ ## 0.9.8
4
+
5
+ ### Patch Changes
6
+
7
+ - ea89575: feat: adding the ability for custom schema validation / retrieving schemas to use (for example with openapi json_response)
8
+ - Updated dependencies [ea89575]
9
+ - @pikku/core@0.9.8
10
+
11
+ ## 0.9.7
12
+
13
+ ### Patch Changes
14
+
15
+ - 4fd5e19: fix: removing rpcMeta and duplicate imports
16
+ - d1babed: fix: pikkuVoidFunc should use a sessionless function -- Since its used mostly by scheduled tasks
17
+
3
18
  ## 0.9.6
4
19
 
5
20
  ### Patch Changes
package/bin/pikku-all.ts CHANGED
@@ -115,7 +115,6 @@ const runAll = async (
115
115
  await pikkuRPCInternalMap(logger, cliConfig, visitState)
116
116
  await pikkuRPCExposedMap(logger, cliConfig, visitState)
117
117
  await pikkuRPCClient(logger, cliConfig)
118
- allImports.push(cliConfig.rpcWiringMetaFile)
119
118
 
120
119
  const schemas = await pikkuSchemas(logger, cliConfig, visitState)
121
120
  if (schemas) {
@@ -127,7 +126,7 @@ const runAll = async (
127
126
  logger,
128
127
  cliConfig,
129
128
  cliConfig.bootstrapFiles.rpc,
130
- [cliConfig.rpcWiringMetaFile],
129
+ [],
131
130
  schemas
132
131
  )
133
132
 
package/cli.schema.json CHANGED
@@ -269,10 +269,13 @@
269
269
  "rootDir": {
270
270
  "type": "string"
271
271
  },
272
- "rpcMapDeclarationFile": {
272
+ "rpcInternalMapDeclarationFile": {
273
273
  "type": "string"
274
274
  },
275
- "rpcWiringMetaFile": {
275
+ "rpcInternalWiringMetaFile": {
276
+ "type": "string"
277
+ },
278
+ "rpcMapDeclarationFile": {
276
279
  "type": "string"
277
280
  },
278
281
  "rpcWiringsFile": {
@@ -287,6 +290,12 @@
287
290
  "schemaDirectory": {
288
291
  "type": "string"
289
292
  },
293
+ "schemasFromTypes": {
294
+ "items": {
295
+ "type": "string"
296
+ },
297
+ "type": "array"
298
+ },
290
299
  "servicesFile": {
291
300
  "type": "string"
292
301
  },
@@ -330,8 +339,9 @@
330
339
  "queueWorkersWiringFile",
331
340
  "queueWorkersWiringMetaFile",
332
341
  "rootDir",
342
+ "rpcInternalMapDeclarationFile",
343
+ "rpcInternalWiringMetaFile",
333
344
  "rpcMapDeclarationFile",
334
- "rpcWiringMetaFile",
335
345
  "schedulersWiringFile",
336
346
  "schedulersWiringMetaFile",
337
347
  "schemaDirectory",
@@ -67,13 +67,12 @@ const runAll = async (logger, cliConfig, options) => {
67
67
  await pikkuRPCInternalMap(logger, cliConfig, visitState);
68
68
  await pikkuRPCExposedMap(logger, cliConfig, visitState);
69
69
  await pikkuRPCClient(logger, cliConfig);
70
- allImports.push(cliConfig.rpcWiringMetaFile);
71
70
  const schemas = await pikkuSchemas(logger, cliConfig, visitState);
72
71
  if (schemas) {
73
72
  allImports.push(`${cliConfig.schemaDirectory}/register.gen.ts`);
74
73
  }
75
74
  // RPC bootstrap is always generated since RPC is always present
76
- await generateBootstrapFile(logger, cliConfig, cliConfig.bootstrapFiles.rpc, [cliConfig.rpcWiringMetaFile], schemas);
75
+ await generateBootstrapFile(logger, cliConfig, cliConfig.bootstrapFiles.rpc, [], schemas);
77
76
  const http = await pikkuHTTP(logger, cliConfig, visitState);
78
77
  if (http) {
79
78
  await pikkuHTTPMap(logger, cliConfig, visitState);
@@ -16,7 +16,6 @@ export interface PikkuCLICoreOutputFiles {
16
16
  channelsMapDeclarationFile: string;
17
17
  rpcInternalWiringMetaFile: string;
18
18
  rpcInternalMapDeclarationFile: string;
19
- rpcWiringMetaFile: string;
20
19
  rpcMapDeclarationFile: string;
21
20
  schedulersWiringFile: string;
22
21
  schedulersWiringMetaFile: string;
@@ -50,6 +49,7 @@ export type PikkuCLIConfig = {
50
49
  additionalInfo: OpenAPISpecInfo;
51
50
  };
52
51
  middlewareServices?: string[];
52
+ schemasFromTypes?: string[];
53
53
  filters: InspectorFilters;
54
54
  } & PikkuCLICoreOutputFiles;
55
55
  export declare const getPikkuCLIConfig: (configFile: string | undefined, requiredFields: Array<keyof PikkuCLIConfig>, filters?: InspectorFilters, exitProcess?: boolean) => Promise<PikkuCLIConfig>;
@@ -111,9 +111,6 @@ const _getPikkuCLIConfig = async (configFile = undefined, requiredFields, filter
111
111
  result.rpcInternalMapDeclarationFile = join(internalRPCDirectory, 'pikku-rpc-wirings-map.internal.gen.d.ts');
112
112
  }
113
113
  // External
114
- if (!result.rpcWiringMetaFile) {
115
- result.rpcWiringMetaFile = join(externalRPCDirectory, 'pikku-rpc-wirings-meta.gen.ts');
116
- }
117
114
  if (!result.rpcMapDeclarationFile) {
118
115
  result.rpcMapDeclarationFile = join(externalRPCDirectory, 'pikku-rpc-wirings-map.gen.d.ts');
119
116
  }
@@ -1,8 +1,8 @@
1
1
  import { generateSchemas, saveSchemas } from './schema-generator.js';
2
2
  import { logCommandInfoAndTime } from './utils.js';
3
- export const pikkuSchemas = async (logger, { tsconfig, schemaDirectory, supportsImportAttributes }, { functions, http }) => {
3
+ export const pikkuSchemas = async (logger, { tsconfig, schemaDirectory, supportsImportAttributes, schemasFromTypes }, { functions, http }) => {
4
4
  return await logCommandInfoAndTime(logger, 'Creating schemas', 'Created schemas', [false], async () => {
5
- const schemas = await generateSchemas(logger, tsconfig, functions.typesMap, functions.meta, http.meta);
6
- await saveSchemas(logger, schemaDirectory, schemas, functions.typesMap, functions.meta, supportsImportAttributes);
5
+ const schemas = await generateSchemas(logger, tsconfig, functions.typesMap, functions.meta, http.meta, schemasFromTypes);
6
+ await saveSchemas(logger, schemaDirectory, schemas, functions.typesMap, functions.meta, supportsImportAttributes, schemasFromTypes);
7
7
  });
8
8
  };
@@ -2,5 +2,5 @@ import { CLILogger } from './utils.js';
2
2
  import { FunctionsMeta, JSONValue } from '@pikku/core';
3
3
  import { HTTPWiringsMeta } from '@pikku/core/http';
4
4
  import { TypesMap } from '@pikku/inspector';
5
- export declare function generateSchemas(logger: CLILogger, tsconfig: string, typesMap: TypesMap, functionMeta: FunctionsMeta, httpWiringsMeta: HTTPWiringsMeta): Promise<Record<string, JSONValue>>;
6
- export declare function saveSchemas(logger: CLILogger, schemaParentDir: string, schemas: Record<string, JSONValue>, typesMap: TypesMap, functionsMeta: FunctionsMeta, supportsImportAttributes: boolean): Promise<void>;
5
+ export declare function generateSchemas(logger: CLILogger, tsconfig: string, typesMap: TypesMap, functionMeta: FunctionsMeta, httpWiringsMeta: HTTPWiringsMeta, additionalTypes?: string[]): Promise<Record<string, JSONValue>>;
6
+ export declare function saveSchemas(logger: CLILogger, schemaParentDir: string, schemas: Record<string, JSONValue>, typesMap: TypesMap, functionsMeta: FunctionsMeta, supportsImportAttributes: boolean, additionalTypes?: string[]): Promise<void>;
@@ -1,7 +1,7 @@
1
1
  import { createGenerator, RootlessError } from 'ts-json-schema-generator';
2
2
  import { writeFileInDir } from './utils.js';
3
3
  import { mkdir, writeFile } from 'fs/promises';
4
- export async function generateSchemas(logger, tsconfig, typesMap, functionMeta, httpWiringsMeta) {
4
+ export async function generateSchemas(logger, tsconfig, typesMap, functionMeta, httpWiringsMeta, additionalTypes) {
5
5
  const schemasSet = new Set(typesMap.customTypes.keys());
6
6
  for (const { inputs, outputs } of Object.values(functionMeta)) {
7
7
  const types = [...(inputs || []), ...(outputs || [])];
@@ -25,6 +25,12 @@ export async function generateSchemas(logger, tsconfig, typesMap, functionMeta,
25
25
  }
26
26
  }
27
27
  }
28
+ // Add additional types from schemasFromTypes config
29
+ if (additionalTypes) {
30
+ for (const type of additionalTypes) {
31
+ schemasSet.add(type);
32
+ }
33
+ }
28
34
  const generator = createGenerator({
29
35
  tsconfig,
30
36
  skipTypeCheck: true,
@@ -53,7 +59,7 @@ export async function generateSchemas(logger, tsconfig, typesMap, functionMeta,
53
59
  });
54
60
  return schemas;
55
61
  }
56
- export async function saveSchemas(logger, schemaParentDir, schemas, typesMap, functionsMeta, supportsImportAttributes) {
62
+ export async function saveSchemas(logger, schemaParentDir, schemas, typesMap, functionsMeta, supportsImportAttributes, additionalTypes) {
57
63
  await writeFileInDir(logger, `${schemaParentDir}/register.gen.ts`, 'export const empty = null;');
58
64
  const desiredSchemas = new Set([
59
65
  ...Object.values(functionsMeta)
@@ -65,6 +71,7 @@ export async function saveSchemas(logger, schemaParentDir, schemas, typesMap, fu
65
71
  .filter((s) => !!s &&
66
72
  !['boolean', 'string', 'number', 'null', 'undefined'].includes(s)),
67
73
  ...typesMap.customTypes.keys(),
74
+ ...(additionalTypes || []),
68
75
  ]);
69
76
  if (desiredSchemas.size === 0) {
70
77
  logger.info(`• Skipping schemas since none found.\x1b[0m`);
@@ -76,7 +83,9 @@ export async function saveSchemas(logger, schemaParentDir, schemas, typesMap, fu
76
83
  await writeFile(`${schemaParentDir}/schemas/${schemaName}.schema.json`, JSON.stringify(schema), 'utf-8');
77
84
  }
78
85
  }));
79
- const schemaImports = Array.from(desiredSchemas)
86
+ // Only include schemas that were successfully generated
87
+ const availableSchemas = Array.from(desiredSchemas).filter((schema) => schemas[schema]);
88
+ const schemaImports = availableSchemas
80
89
  .map((schema) => `
81
90
  import * as ${schema} from './schemas/${schema}.schema.json' ${supportsImportAttributes ? `with { type: 'json' }` : ''}
82
91
  addSchema('${schema}', ${schema})
@@ -1,8 +1,8 @@
1
1
  import { saveSchemas, generateSchemas } from './schema-generator.js';
2
2
  import { logCommandInfoAndTime } from './utils.js';
3
- export const pikkuSchemas = async (logger, { tsconfig, schemaDirectory, supportsImportAttributes }, { functions, http }) => {
3
+ export const pikkuSchemas = async (logger, { tsconfig, schemaDirectory, supportsImportAttributes, schemasFromTypes }, { functions, http }) => {
4
4
  return await logCommandInfoAndTime(logger, 'Creating schemas', 'Created schemas', [false], async () => {
5
- const schemas = await generateSchemas(logger, tsconfig, functions.typesMap, functions.meta, http.meta);
6
- await saveSchemas(logger, schemaDirectory, schemas, functions.typesMap, functions.meta, supportsImportAttributes);
5
+ const schemas = await generateSchemas(logger, tsconfig, functions.typesMap, functions.meta, http.meta, schemasFromTypes);
6
+ await saveSchemas(logger, schemaDirectory, schemas, functions.typesMap, functions.meta, supportsImportAttributes, schemasFromTypes);
7
7
  });
8
8
  };
@@ -72,11 +72,11 @@ export const serializeImportMap = (relativeToPath, packageMappings, typesMap, re
72
72
  if (uniqueName === '__object') {
73
73
  return;
74
74
  }
75
- if (originalName === uniqueName) {
76
- variables.push(originalName);
77
- }
78
- else {
79
- variables.push(`${originalName} as ${uniqueName}`);
75
+ const importName = originalName === uniqueName
76
+ ? originalName
77
+ : `${originalName} as ${uniqueName}`;
78
+ if (!variables.includes(importName)) {
79
+ variables.push(importName);
80
80
  }
81
81
  paths.set(path, variables);
82
82
  });
@@ -340,7 +340,7 @@ export const pikkuChannelFunc = <In = unknown, Out = unknown, ChannelData = unkn
340
340
  export const pikkuVoidFunc = (
341
341
  func:
342
342
  | PikkuFunctionSessionless<void, void>
343
- | CorePikkuFunctionConfig<PikkuFunction<void, void>, PikkuPermission<void>>
343
+ | CorePikkuFunctionConfig<PikkuFunctionSessionless<void, void>, PikkuPermission<void>>
344
344
  ) => {
345
345
  return typeof func === 'function' ? func : func.func
346
346
  }
@@ -2,12 +2,12 @@ import { logCommandInfoAndTime, writeFileInDir } from '../../utils.js';
2
2
  import { generateSchemas } from '../../schema-generator.js';
3
3
  import { generateOpenAPISpec } from './openapi-spec-generator.js';
4
4
  import { stringify } from 'yaml';
5
- export const pikkuOpenAPI = async (logger, { tsconfig, openAPI }, { http, functions }) => {
5
+ export const pikkuOpenAPI = async (logger, { tsconfig, openAPI, schemasFromTypes }, { http, functions }) => {
6
6
  return await logCommandInfoAndTime(logger, 'Creating OpenAPI spec', 'Created OpenAPI spec', [openAPI?.outputFile === undefined, 'openAPI outfile is not defined'], async () => {
7
7
  if (!openAPI?.outputFile) {
8
8
  throw new Error('openAPI is required');
9
9
  }
10
- const schemas = await generateSchemas(logger, tsconfig, functions.typesMap, functions.meta, http.meta);
10
+ const schemas = await generateSchemas(logger, tsconfig, functions.typesMap, functions.meta, http.meta, schemasFromTypes);
11
11
  const openAPISpec = await generateOpenAPISpec(functions.meta, http.meta, schemas, openAPI.additionalInfo);
12
12
  if (openAPI.outputFile.endsWith('.json')) {
13
13
  await writeFileInDir(logger, openAPI.outputFile, JSON.stringify(openAPISpec, null, 2), { ignoreModifyComment: true });
@@ -1,6 +1,6 @@
1
1
  import { serializeRPCWrapper } from './serialize-rpc-wrapper.js';
2
2
  import { getFileImportRelativePath, logCommandInfoAndTime, writeFileInDir, } from '../../utils.js';
3
- export const pikkuRPCClient = async (logger, { rpcWiringsFile, rpcMapDeclarationFile, rpcInternalMapDeclarationFile, packageMappings, }) => {
3
+ export const pikkuRPCClient = async (logger, { rpcWiringsFile, rpcMapDeclarationFile, packageMappings }) => {
4
4
  return await logCommandInfoAndTime(logger, 'Generating RPC wrappers', 'Generated RPC wrappers', [
5
5
  rpcWiringsFile === undefined || rpcWiringsFile === null,
6
6
  "rpcWiringsFile isn't set in the pikku config",
@@ -1,11 +1,8 @@
1
1
  import { logCommandInfoAndTime, writeFileInDir } from '../../utils.js';
2
- export const pikkuRPC = async (logger, { rpcInternalWiringMetaFile, rpcWiringMetaFile }, { rpc }) => {
2
+ export const pikkuRPC = async (logger, { rpcInternalWiringMetaFile }, { rpc }) => {
3
3
  return await logCommandInfoAndTime(logger, 'Finding RPCs tasks', 'Found RPCs', [false], async () => {
4
4
  if (rpc.internalFiles.size > 0) {
5
5
  await writeFileInDir(logger, rpcInternalWiringMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('rpc', 'meta', ${JSON.stringify(rpc.internalMeta, null, 2)})`);
6
6
  }
7
- if (rpc.exposedFiles.size > 0) {
8
- await writeFileInDir(logger, rpcWiringMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('rpc', 'meta', ${JSON.stringify(rpc.exposedFiles, null, 2)})`);
9
- }
10
7
  });
11
8
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikku/cli",
3
- "version": "0.9.6",
3
+ "version": "0.9.8",
4
4
  "author": "yasser.fadl@gmail.com",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@openapi-contrib/json-schema-to-openapi-schema": "^4.0.2",
25
- "@pikku/core": "^0.9.6",
25
+ "@pikku/core": "^0.9.8",
26
26
  "@pikku/inspector": "^0.9.4",
27
27
  "@types/cookie": "^1.0.0",
28
28
  "@types/uuid": "^10.0.0",
package/run-tests.sh CHANGED
@@ -46,7 +46,7 @@ if [ "$watch_mode" = true ]; then
46
46
  fi
47
47
 
48
48
  if [ "$coverage_mode" = true ]; then
49
- node_cmd="$node_cmd --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=lcov.info"
49
+ node_cmd="$node_cmd --test-coverage-include=\"src/**/*.{ts,js}\" --test-coverage-exclude=\"**/dist/**\" --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=lcov.info"
50
50
  fi
51
51
 
52
52
  # Execute the node command with the expanded list of files
@@ -32,7 +32,6 @@ export interface PikkuCLICoreOutputFiles {
32
32
  rpcInternalMapDeclarationFile: string
33
33
 
34
34
  // RPC Exposed
35
- rpcWiringMetaFile: string
36
35
  rpcMapDeclarationFile: string
37
36
 
38
37
  // Schedulers
@@ -84,6 +83,8 @@ export type PikkuCLIConfig = {
84
83
 
85
84
  middlewareServices?: string[]
86
85
 
86
+ schemasFromTypes?: string[]
87
+
87
88
  filters: InspectorFilters
88
89
  } & PikkuCLICoreOutputFiles
89
90
 
@@ -253,12 +254,6 @@ const _getPikkuCLIConfig = async (
253
254
  }
254
255
 
255
256
  // External
256
- if (!result.rpcWiringMetaFile) {
257
- result.rpcWiringMetaFile = join(
258
- externalRPCDirectory,
259
- 'pikku-rpc-wirings-meta.gen.ts'
260
- )
261
- }
262
257
  if (!result.rpcMapDeclarationFile) {
263
258
  result.rpcMapDeclarationFile = join(
264
259
  externalRPCDirectory,
@@ -4,7 +4,7 @@ import { PikkuCommand } from './types.js'
4
4
 
5
5
  export const pikkuSchemas: PikkuCommand = async (
6
6
  logger,
7
- { tsconfig, schemaDirectory, supportsImportAttributes },
7
+ { tsconfig, schemaDirectory, supportsImportAttributes, schemasFromTypes },
8
8
  { functions, http }
9
9
  ) => {
10
10
  return await logCommandInfoAndTime(
@@ -18,7 +18,8 @@ export const pikkuSchemas: PikkuCommand = async (
18
18
  tsconfig,
19
19
  functions.typesMap,
20
20
  functions.meta,
21
- http.meta
21
+ http.meta,
22
+ schemasFromTypes
22
23
  )
23
24
  await saveSchemas(
24
25
  logger,
@@ -26,7 +27,8 @@ export const pikkuSchemas: PikkuCommand = async (
26
27
  schemas,
27
28
  functions.typesMap,
28
29
  functions.meta,
29
- supportsImportAttributes
30
+ supportsImportAttributes,
31
+ schemasFromTypes
30
32
  )
31
33
  }
32
34
  )
@@ -10,7 +10,8 @@ export async function generateSchemas(
10
10
  tsconfig: string,
11
11
  typesMap: TypesMap,
12
12
  functionMeta: FunctionsMeta,
13
- httpWiringsMeta: HTTPWiringsMeta
13
+ httpWiringsMeta: HTTPWiringsMeta,
14
+ additionalTypes?: string[]
14
15
  ): Promise<Record<string, JSONValue>> {
15
16
  const schemasSet = new Set(typesMap.customTypes.keys())
16
17
  for (const { inputs, outputs } of Object.values(functionMeta)) {
@@ -37,6 +38,13 @@ export async function generateSchemas(
37
38
  }
38
39
  }
39
40
 
41
+ // Add additional types from schemasFromTypes config
42
+ if (additionalTypes) {
43
+ for (const type of additionalTypes) {
44
+ schemasSet.add(type)
45
+ }
46
+ }
47
+
40
48
  const generator = createGenerator({
41
49
  tsconfig,
42
50
  skipTypeCheck: true,
@@ -72,7 +80,8 @@ export async function saveSchemas(
72
80
  schemas: Record<string, JSONValue>,
73
81
  typesMap: TypesMap,
74
82
  functionsMeta: FunctionsMeta,
75
- supportsImportAttributes: boolean
83
+ supportsImportAttributes: boolean,
84
+ additionalTypes?: string[]
76
85
  ) {
77
86
  await writeFileInDir(
78
87
  logger,
@@ -80,7 +89,7 @@ export async function saveSchemas(
80
89
  'export const empty = null;'
81
90
  )
82
91
 
83
- const desiredSchemas = new Set([
92
+ const desiredSchemas = new Set<string>([
84
93
  ...Object.values(functionsMeta)
85
94
  .map(({ inputs, outputs }) => [
86
95
  inputs?.[0] ? typesMap.getUniqueName(inputs[0]) : undefined,
@@ -88,11 +97,12 @@ export async function saveSchemas(
88
97
  ])
89
98
  .flat()
90
99
  .filter(
91
- (s) =>
100
+ (s): s is string =>
92
101
  !!s &&
93
102
  !['boolean', 'string', 'number', 'null', 'undefined'].includes(s)
94
103
  ),
95
104
  ...typesMap.customTypes.keys(),
105
+ ...(additionalTypes || []),
96
106
  ])
97
107
 
98
108
  if (desiredSchemas.size === 0) {
@@ -113,7 +123,12 @@ export async function saveSchemas(
113
123
  })
114
124
  )
115
125
 
116
- const schemaImports = Array.from(desiredSchemas)
126
+ // Only include schemas that were successfully generated
127
+ const availableSchemas = Array.from(desiredSchemas).filter(
128
+ (schema) => schemas[schema]
129
+ )
130
+
131
+ const schemaImports = availableSchemas
117
132
  .map(
118
133
  (schema) => `
119
134
  import * as ${schema} from './schemas/${schema}.schema.json' ${supportsImportAttributes ? `with { type: 'json' }` : ''}
package/src/schemas.ts CHANGED
@@ -4,7 +4,7 @@ import { PikkuCommand } from './types.js'
4
4
 
5
5
  export const pikkuSchemas: PikkuCommand = async (
6
6
  logger,
7
- { tsconfig, schemaDirectory, supportsImportAttributes },
7
+ { tsconfig, schemaDirectory, supportsImportAttributes, schemasFromTypes },
8
8
  { functions, http }
9
9
  ) => {
10
10
  return await logCommandInfoAndTime(
@@ -18,7 +18,8 @@ export const pikkuSchemas: PikkuCommand = async (
18
18
  tsconfig,
19
19
  functions.typesMap,
20
20
  functions.meta,
21
- http.meta
21
+ http.meta,
22
+ schemasFromTypes
22
23
  )
23
24
  await saveSchemas(
24
25
  logger,
@@ -26,7 +27,8 @@ export const pikkuSchemas: PikkuCommand = async (
26
27
  schemas,
27
28
  functions.typesMap,
28
29
  functions.meta,
29
- supportsImportAttributes
30
+ supportsImportAttributes,
31
+ schemasFromTypes
30
32
  )
31
33
  }
32
34
  )
@@ -86,10 +86,12 @@ export const serializeImportMap = (
86
86
  return
87
87
  }
88
88
 
89
- if (originalName === uniqueName) {
90
- variables.push(originalName)
91
- } else {
92
- variables.push(`${originalName} as ${uniqueName}`)
89
+ const importName =
90
+ originalName === uniqueName
91
+ ? originalName
92
+ : `${originalName} as ${uniqueName}`
93
+ if (!variables.includes(importName)) {
94
+ variables.push(importName)
93
95
  }
94
96
  paths.set(path, variables)
95
97
  })
@@ -348,7 +348,7 @@ export const pikkuChannelFunc = <In = unknown, Out = unknown, ChannelData = unkn
348
348
  export const pikkuVoidFunc = (
349
349
  func:
350
350
  | PikkuFunctionSessionless<void, void>
351
- | CorePikkuFunctionConfig<PikkuFunction<void, void>, PikkuPermission<void>>
351
+ | CorePikkuFunctionConfig<PikkuFunctionSessionless<void, void>, PikkuPermission<void>>
352
352
  ) => {
353
353
  return typeof func === 'function' ? func : func.func
354
354
  }
@@ -6,7 +6,7 @@ import { PikkuCommand } from '../../types.js'
6
6
 
7
7
  export const pikkuOpenAPI: PikkuCommand = async (
8
8
  logger,
9
- { tsconfig, openAPI },
9
+ { tsconfig, openAPI, schemasFromTypes },
10
10
  { http, functions }
11
11
  ) => {
12
12
  return await logCommandInfoAndTime(
@@ -23,7 +23,8 @@ export const pikkuOpenAPI: PikkuCommand = async (
23
23
  tsconfig,
24
24
  functions.typesMap,
25
25
  functions.meta,
26
- http.meta
26
+ http.meta,
27
+ schemasFromTypes
27
28
  )
28
29
  const openAPISpec = await generateOpenAPISpec(
29
30
  functions.meta,
@@ -8,12 +8,7 @@ import { PikkuCommandWithoutState } from '../../types.js'
8
8
 
9
9
  export const pikkuRPCClient: PikkuCommandWithoutState = async (
10
10
  logger,
11
- {
12
- rpcWiringsFile,
13
- rpcMapDeclarationFile,
14
- rpcInternalMapDeclarationFile,
15
- packageMappings,
16
- }
11
+ { rpcWiringsFile, rpcMapDeclarationFile, packageMappings }
17
12
  ) => {
18
13
  return await logCommandInfoAndTime(
19
14
  logger,
@@ -3,7 +3,7 @@ import { PikkuCommand } from '../../types.js'
3
3
 
4
4
  export const pikkuRPC: PikkuCommand = async (
5
5
  logger,
6
- { rpcInternalWiringMetaFile, rpcWiringMetaFile },
6
+ { rpcInternalWiringMetaFile },
7
7
  { rpc }
8
8
  ) => {
9
9
  return await logCommandInfoAndTime(
@@ -19,14 +19,6 @@ export const pikkuRPC: PikkuCommand = async (
19
19
  `import { pikkuState } from '@pikku/core'\npikkuState('rpc', 'meta', ${JSON.stringify(rpc.internalMeta, null, 2)})`
20
20
  )
21
21
  }
22
-
23
- if (rpc.exposedFiles.size > 0) {
24
- await writeFileInDir(
25
- logger,
26
- rpcWiringMetaFile,
27
- `import { pikkuState } from '@pikku/core'\npikkuState('rpc', 'meta', ${JSON.stringify(rpc.exposedFiles, null, 2)})`
28
- )
29
- }
30
22
  }
31
23
  )
32
24
  }