@pikku/cli 0.12.2 → 0.12.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/cli.schema.json +1 -1
- package/console-app/assets/index-AX4YS8AA.js +657 -0
- package/console-app/assets/{index-0Ui5UudO.css → index-DvrDbftC.css} +1 -1
- package/console-app/index.html +2 -2
- package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +1 -1
- package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.js +1 -1
- package/dist/.pikku/agent/pikku-agent-wirings.gen.d.ts +1 -1
- package/dist/.pikku/agent/pikku-agent-wirings.gen.js +1 -1
- package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +1 -1
- package/dist/.pikku/channel/pikku-channel-types.gen.js +1 -1
- package/dist/.pikku/channel/pikku-channels-meta.gen.js +1 -1
- package/dist/.pikku/channel/pikku-channels.gen.d.ts +1 -1
- package/dist/.pikku/channel/pikku-channels.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-channel.d.ts +13 -1
- package/dist/.pikku/cli/pikku-cli-channel.js +17 -2
- package/dist/.pikku/cli/pikku-cli-client.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-client.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-types.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.json +12 -1
- package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli.gen.js +1 -1
- package/dist/.pikku/console/pikku-node-types.gen.d.ts +1 -1
- package/dist/.pikku/function/pikku-function-types.gen.d.ts +30 -1
- package/dist/.pikku/function/pikku-function-types.gen.js +17 -1
- package/dist/.pikku/function/pikku-functions-meta.gen.js +1 -1
- package/dist/.pikku/function/pikku-functions-meta.gen.json +88 -88
- package/dist/.pikku/function/pikku-functions.gen.js +1 -1
- package/dist/.pikku/http/pikku-http-types.gen.d.ts +1 -1
- package/dist/.pikku/http/pikku-http-types.gen.js +1 -1
- package/dist/.pikku/http/pikku-http-wirings-meta.gen.js +1 -1
- package/dist/.pikku/http/pikku-http-wirings.gen.d.ts +1 -1
- package/dist/.pikku/http/pikku-http-wirings.gen.js +1 -1
- package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +1 -1
- package/dist/.pikku/mcp/pikku-mcp-types.gen.js +1 -1
- package/dist/.pikku/mcp/pikku-mcp-wirings-meta.gen.js +1 -1
- package/dist/.pikku/mcp/pikku-mcp-wirings.gen.d.ts +1 -1
- package/dist/.pikku/mcp/pikku-mcp-wirings.gen.js +1 -1
- package/dist/.pikku/pikku-bootstrap.gen.js +1 -1
- package/dist/.pikku/pikku-services.gen.d.ts +3 -1
- package/dist/.pikku/pikku-services.gen.js +2 -0
- package/dist/.pikku/pikku-types.gen.d.ts +1 -1
- package/dist/.pikku/pikku-types.gen.js +1 -1
- package/dist/.pikku/pikku-websocket.gen.d.ts +1 -1
- package/dist/.pikku/pikku-websocket.gen.js +1 -1
- package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +1 -1
- package/dist/.pikku/queue/pikku-queue-types.gen.js +1 -1
- package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +1 -1
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +1 -1
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +1 -1
- package/dist/.pikku/rpc/pikku-remote-rpc-workers.gen.js +1 -1
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +1 -1
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +1 -1
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +1 -1
- package/dist/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.js +1 -1
- package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.d.ts +1 -1
- package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.js +1 -1
- package/dist/.pikku/schemas/register.gen.js +3 -3
- package/dist/.pikku/schemas/schemas/ConsoleCommandInput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuNewAddonInput.schema.json +1 -1
- package/dist/.pikku/secrets/pikku-secret-types.gen.d.ts +1 -1
- package/dist/.pikku/secrets/pikku-secret-types.gen.js +1 -1
- package/dist/.pikku/secrets/pikku-secrets.gen.d.ts +1 -1
- package/dist/.pikku/secrets/pikku-secrets.gen.js +1 -1
- package/dist/.pikku/trigger/pikku-trigger-types.gen.d.ts +1 -1
- package/dist/.pikku/trigger/pikku-trigger-types.gen.js +1 -1
- package/dist/.pikku/variables/pikku-variable-types.gen.d.ts +1 -1
- package/dist/.pikku/variables/pikku-variable-types.gen.js +1 -1
- package/dist/.pikku/variables/pikku-variables.gen.d.ts +1 -1
- package/dist/.pikku/variables/pikku-variables.gen.js +1 -1
- package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +1 -1
- package/dist/.pikku/workflow/pikku-workflow-types.gen.js +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings.gen.d.ts +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +1 -1
- package/dist/src/cli.wiring.js +9 -0
- package/dist/src/functions/commands/all.js +33 -11
- package/dist/src/functions/commands/console.d.ts +3 -0
- package/dist/src/functions/commands/console.js +8 -2
- package/dist/src/functions/commands/new-addon.d.ts +3 -0
- package/dist/src/functions/commands/new-addon.js +8 -6
- package/dist/src/functions/wirings/ai-agent/serialize-public-agent.js +19 -0
- package/dist/src/functions/wirings/channels/pikku-command-channels-map.js +1 -1
- package/dist/src/functions/wirings/channels/serialize-typed-channel-map.d.ts +1 -1
- package/dist/src/functions/wirings/channels/serialize-typed-channel-map.js +7 -6
- package/dist/src/functions/wirings/cli/pikku-command-cli-entry.js +9 -1
- package/dist/src/functions/wirings/cli/serialize-channel-cli.js +35 -12
- package/dist/src/functions/wirings/console/pikku-command-node-types.js +2 -2
- package/dist/src/functions/wirings/console/pikku-command-nodes-meta.js +20 -11
- package/dist/src/functions/wirings/console/serialize-console-functions.js +1 -1
- package/dist/src/functions/wirings/functions/pikku-command-function-types-split.js +1 -1
- package/dist/src/functions/wirings/functions/serialize-addon-types.js +23 -1
- package/dist/src/functions/wirings/functions/serialize-function-types.js +38 -0
- package/dist/src/services.js +1 -1
- package/dist/src/utils/file-import-path.js +5 -2
- package/dist/src/utils/openapi/codegen.d.ts +1 -0
- package/dist/src/utils/openapi/codegen.js +214 -46
- package/dist/src/utils/openapi/parse-openapi.d.ts +25 -0
- package/dist/src/utils/openapi/parse-openapi.js +119 -9
- package/dist/src/utils/openapi/zod-codegen.d.ts +1 -53
- package/dist/src/utils/openapi/zod-codegen.js +1 -251
- package/dist/src/utils/pikku-cli-config.js +2 -2
- package/dist/src/utils/strip-verbose-meta.d.ts +2 -0
- package/dist/src/utils/strip-verbose-meta.js +34 -0
- package/package.json +4 -3
- package/console-app/assets/index-DRJQtv3c.js +0 -676
|
@@ -5,10 +5,10 @@ import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-
|
|
|
5
5
|
import { serializeNodeTypes } from './serialize-node-types.js';
|
|
6
6
|
export const pikkuNodeTypes = pikkuSessionlessFunc({
|
|
7
7
|
func: async ({ logger, config }) => {
|
|
8
|
-
const { nodeTypesFile, rpcInternalMapDeclarationFile, packageMappings,
|
|
8
|
+
const { nodeTypesFile, rpcInternalMapDeclarationFile, packageMappings, addon, } = config;
|
|
9
9
|
let rpcMapImportPath = getFileImportRelativePath(nodeTypesFile, rpcInternalMapDeclarationFile, packageMappings);
|
|
10
10
|
rpcMapImportPath = rpcMapImportPath.replace('.d.js', '.js');
|
|
11
|
-
const categories =
|
|
11
|
+
const categories = typeof addon === 'object' ? addon?.categories : undefined;
|
|
12
12
|
const content = serializeNodeTypes(rpcMapImportPath, categories);
|
|
13
13
|
await writeFileInDir(logger, nodeTypesFile, content);
|
|
14
14
|
},
|
|
@@ -28,14 +28,16 @@ export const pikkuNodesMeta = pikkuSessionlessFunc({
|
|
|
28
28
|
func: async ({ logger, config, getInspectorState }) => {
|
|
29
29
|
const state = await getInspectorState();
|
|
30
30
|
const { nodes, secrets } = state;
|
|
31
|
-
const {
|
|
31
|
+
const { addonMetaJsonFile, addon, rootDir } = config;
|
|
32
|
+
const addonMeta = typeof addon === 'object' ? addon : undefined;
|
|
32
33
|
const secretsMeta = validateAndBuildSecretDefinitionsMeta(secrets.definitions, state.schemaLookup);
|
|
33
34
|
const hasNodes = Object.keys(nodes.meta).length > 0;
|
|
34
35
|
const hasSecrets = secrets.definitions.length > 0;
|
|
35
|
-
|
|
36
|
+
const hasPackageMeta = !!addonMeta?.icon || !!addonMeta?.displayName;
|
|
37
|
+
if (!hasNodes && !hasSecrets && !hasPackageMeta) {
|
|
36
38
|
return undefined;
|
|
37
39
|
}
|
|
38
|
-
const allowedCategories =
|
|
40
|
+
const allowedCategories = addonMeta?.categories;
|
|
39
41
|
if (allowedCategories && allowedCategories.length > 0) {
|
|
40
42
|
for (const [name, meta] of Object.entries(nodes.meta)) {
|
|
41
43
|
if (!allowedCategories.includes(meta.category)) {
|
|
@@ -49,23 +51,30 @@ export const pikkuNodesMeta = pikkuSessionlessFunc({
|
|
|
49
51
|
const { icon: _icon, ...nodeMetaWithoutIcon } = meta;
|
|
50
52
|
outputMeta[name] = nodeMetaWithoutIcon;
|
|
51
53
|
}
|
|
52
|
-
const packageIcon = await loadIcon(
|
|
54
|
+
const packageIcon = await loadIcon(addonMeta?.icon, rootDir, logger);
|
|
53
55
|
const metaData = {
|
|
54
56
|
nodes: outputMeta,
|
|
55
57
|
secrets: secretsMeta,
|
|
56
58
|
package: {
|
|
57
|
-
displayName:
|
|
58
|
-
description:
|
|
59
|
+
displayName: addonMeta?.displayName,
|
|
60
|
+
description: addonMeta?.description,
|
|
59
61
|
icon: packageIcon,
|
|
60
|
-
categories:
|
|
62
|
+
categories: addonMeta?.categories,
|
|
61
63
|
},
|
|
62
64
|
};
|
|
63
|
-
if (
|
|
65
|
+
if (addonMetaJsonFile && (config.scaffold?.console || config.addon)) {
|
|
64
66
|
const minimalMeta = stripVerboseFields(metaData);
|
|
65
|
-
await writeFileInDir(logger,
|
|
67
|
+
await writeFileInDir(logger, addonMetaJsonFile, JSON.stringify(minimalMeta, null, 2), { ignoreModifyComment: true });
|
|
66
68
|
if (hasVerboseFields(metaData)) {
|
|
67
|
-
const verbosePath =
|
|
68
|
-
|
|
69
|
+
const verbosePath = addonMetaJsonFile.endsWith('.gen.json')
|
|
70
|
+
? addonMetaJsonFile.replace(/\.gen\.json$/, '-verbose.gen.json')
|
|
71
|
+
: addonMetaJsonFile.replace(/(\.\w+)$/, '-verbose$1');
|
|
72
|
+
if (verbosePath === addonMetaJsonFile) {
|
|
73
|
+
logger.warn(`Cannot derive verbose path from ${addonMetaJsonFile}, skipping verbose metadata`);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
await writeFileInDir(logger, verbosePath, JSON.stringify(metaData, null, 2), { ignoreModifyComment: true });
|
|
77
|
+
}
|
|
69
78
|
}
|
|
70
79
|
}
|
|
71
80
|
return true;
|
|
@@ -85,6 +85,6 @@ export const consoleRoutes = defineHTTPRoutes({
|
|
|
85
85
|
})
|
|
86
86
|
|
|
87
87
|
wireAddon({ name: 'console', package: '@pikku/addon-console' })
|
|
88
|
-
wireHTTPRoutes({
|
|
88
|
+
wireHTTPRoutes({ basePath: '/api', routes: { console: consoleRoutes } })
|
|
89
89
|
`;
|
|
90
90
|
};
|
|
@@ -21,7 +21,7 @@ export const pikkuFunctionTypesSplit = pikkuSessionlessFunc({
|
|
|
21
21
|
const configTypeImport = pikkuConfigType
|
|
22
22
|
? `import type { ${pikkuConfigType.type} } from '${getFileImportRelativePath(functionTypesFile, pikkuConfigType.typePath, packageMappings)}'`
|
|
23
23
|
: '// Config type not found, will use fallback';
|
|
24
|
-
const content = serializeFunctionTypes(`import type { ${userSessionType.type} } from '${getFileImportRelativePath(functionTypesFile, userSessionType.typePath, packageMappings)}'`, userSessionType.type, `import type { ${singletonServicesType.type} } from '${getFileImportRelativePath(functionTypesFile, singletonServicesType.typePath, packageMappings)}'`, singletonServicesType.type, `import type { ${wireServicesType.type} } from '${getFileImportRelativePath(functionTypesFile, wireServicesType.typePath, packageMappings)}'`, wireServicesType.type, `import type { TypedPikkuRPC, FlattenedRPCMap } from '${getFileImportRelativePath(functionTypesFile, rpcInternalMapDeclarationFile, packageMappings)}'`, `import type { RequiredSingletonServices, RequiredWireServices } from '${getFileImportRelativePath(functionTypesFile, servicesFile, packageMappings)}'`, configTypeImport, config.addonName, undefined, config.
|
|
24
|
+
const content = serializeFunctionTypes(`import type { ${userSessionType.type} } from '${getFileImportRelativePath(functionTypesFile, userSessionType.typePath, packageMappings)}'`, userSessionType.type, `import type { ${singletonServicesType.type} } from '${getFileImportRelativePath(functionTypesFile, singletonServicesType.typePath, packageMappings)}'`, singletonServicesType.type, `import type { ${wireServicesType.type} } from '${getFileImportRelativePath(functionTypesFile, wireServicesType.typePath, packageMappings)}'`, wireServicesType.type, `import type { TypedPikkuRPC, FlattenedRPCMap } from '${getFileImportRelativePath(functionTypesFile, rpcInternalMapDeclarationFile, packageMappings)}'`, `import type { RequiredSingletonServices, RequiredWireServices } from '${getFileImportRelativePath(functionTypesFile, servicesFile, packageMappings)}'`, configTypeImport, config.addonName, undefined, typeof config.addon === 'object' ? config.addon?.categories : undefined);
|
|
25
25
|
await writeFileInDir(logger, functionTypesFile, content);
|
|
26
26
|
},
|
|
27
27
|
middleware: [
|
|
@@ -61,18 +61,40 @@ export const pikkuAddonServices = <T extends Record<string, any>, ExistingServic
|
|
|
61
61
|
func: (config: Config, services: ExistingServices) => Promise<T>
|
|
62
62
|
) => {
|
|
63
63
|
return async (config: Config, existingServices?: Partial<SingletonServices>): Promise<RequiredSingletonServices> => {
|
|
64
|
-
const { logger, variables, secrets } = (existingServices ?? {}) as unknown as SingletonServices
|
|
64
|
+
const { logger, variables, secrets, schema } = (existingServices ?? {}) as unknown as SingletonServices
|
|
65
65
|
const typedVariables = new TypedVariablesService(variables)
|
|
66
66
|
const typedSecrets = new TypedSecretService(secrets)
|
|
67
67
|
const result = await func(config, { ...existingServices, logger, variables: typedVariables, secrets: typedSecrets } as ExistingServices)
|
|
68
68
|
return {
|
|
69
69
|
config,
|
|
70
70
|
logger,
|
|
71
|
+
schema,
|
|
71
72
|
variables: typedVariables,
|
|
72
73
|
secrets: typedSecrets,
|
|
73
74
|
...result,
|
|
74
75
|
} as unknown as RequiredSingletonServices
|
|
75
76
|
}
|
|
76
77
|
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Creates a Pikku wire services factory for addon packages.
|
|
81
|
+
* Wire services are created per-request and have access to the HTTP request context.
|
|
82
|
+
*
|
|
83
|
+
* @param func - Wire services factory function that receives singleton services and the wire context
|
|
84
|
+
* @returns The wire services factory function
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* \`\`\`typescript
|
|
88
|
+
* export const createWireServices = pikkuAddonWireServices(async (services, wire) => {
|
|
89
|
+
* const authHeader = wire.http?.request?.header('authorization')
|
|
90
|
+
* return { myService: new MyService(authHeader) }
|
|
91
|
+
* })
|
|
92
|
+
* \`\`\`
|
|
93
|
+
*/
|
|
94
|
+
export const pikkuAddonWireServices = (
|
|
95
|
+
func: (services: SingletonServices, wire: any) => Promise<Record<string, any>>
|
|
96
|
+
) => {
|
|
97
|
+
return func as any
|
|
98
|
+
}
|
|
77
99
|
`;
|
|
78
100
|
};
|
|
@@ -15,6 +15,7 @@ export const serializeFunctionTypes = (userSessionTypeImport, userSessionTypeNam
|
|
|
15
15
|
import { CorePikkuFunctionConfig, CorePikkuAuth, CorePikkuAuthConfig, CorePikkuPermission, CorePikkuMiddleware, CorePermissionGroup, addMiddleware as addMiddlewareCore, addPermission as addPermissionCore, PikkuWire, PickRequired } from '@pikku/core'
|
|
16
16
|
import { pikkuState as __pikkuState, CreateWireServices } from '@pikku/core/internal'
|
|
17
17
|
import { pikkuAuth as pikkuAuthCore } from '@pikku/core'
|
|
18
|
+
import { PikkuError } from '@pikku/core/errors'
|
|
18
19
|
import type { NodeType } from '@pikku/core/node'
|
|
19
20
|
import type { StandardSchemaV1 } from '@standard-schema/spec'
|
|
20
21
|
import { CorePikkuFunction, CorePikkuFunctionSessionless } from '@pikku/core/function'
|
|
@@ -229,6 +230,37 @@ export const pikkuPermissionFactory = <In = any>(
|
|
|
229
230
|
return factory
|
|
230
231
|
}
|
|
231
232
|
|
|
233
|
+
/**
|
|
234
|
+
* A function that generates a human-readable description of a pending approval action.
|
|
235
|
+
* Used by AI agents to show meaningful approval prompts instead of raw tool arguments.
|
|
236
|
+
*
|
|
237
|
+
* @template In - The input type (same as the function it describes)
|
|
238
|
+
* @template RequiredServices - The services required for this description function
|
|
239
|
+
*/
|
|
240
|
+
export type PikkuApprovalDescription<In = unknown, RequiredServices extends Services = Services> = (
|
|
241
|
+
services: RequiredServices,
|
|
242
|
+
data: In
|
|
243
|
+
) => Promise<string>
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Factory function for creating approval description functions with tree-shaking support.
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* \`\`\`typescript
|
|
250
|
+
* export const deleteTodoApproval = pikkuApprovalDescription(
|
|
251
|
+
* async ({ todoStore }, { id }) => {
|
|
252
|
+
* const todo = await todoStore.get(id)
|
|
253
|
+
* return \\\`Delete todo: "\${todo.title}"\\\`
|
|
254
|
+
* }
|
|
255
|
+
* )
|
|
256
|
+
* \`\`\`
|
|
257
|
+
*/
|
|
258
|
+
export const pikkuApprovalDescription = <In = unknown, RequiredServices extends Services = Services>(
|
|
259
|
+
fn: PikkuApprovalDescription<In, RequiredServices>
|
|
260
|
+
): PikkuApprovalDescription<In, RequiredServices> => {
|
|
261
|
+
return fn
|
|
262
|
+
}
|
|
263
|
+
|
|
232
264
|
/**
|
|
233
265
|
* A sessionless API function that doesn't require user authentication.
|
|
234
266
|
* Use this for public endpoints, health checks, or operations that don't need user context.
|
|
@@ -308,6 +340,8 @@ export type PikkuFunctionConfigWithSchema<
|
|
|
308
340
|
expose?: boolean
|
|
309
341
|
mcp?: boolean
|
|
310
342
|
internal?: boolean
|
|
343
|
+
approvalRequired?: boolean
|
|
344
|
+
approvalDescription?: PikkuApprovalDescription<InferSchemaOutput<InputSchema>>
|
|
311
345
|
func: PikkuFunction<
|
|
312
346
|
InferSchemaOutput<InputSchema>,
|
|
313
347
|
OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown,
|
|
@@ -323,6 +357,7 @@ export type PikkuFunctionConfigWithSchema<
|
|
|
323
357
|
input: InputSchema
|
|
324
358
|
output?: OutputSchema
|
|
325
359
|
node?: NodeConfig
|
|
360
|
+
errors?: Array<typeof PikkuError>
|
|
326
361
|
}
|
|
327
362
|
|
|
328
363
|
/**
|
|
@@ -393,6 +428,8 @@ export type PikkuFunctionSessionlessConfigWithSchema<
|
|
|
393
428
|
mcp?: boolean
|
|
394
429
|
internal?: boolean
|
|
395
430
|
remote?: boolean
|
|
431
|
+
approvalRequired?: boolean
|
|
432
|
+
approvalDescription?: PikkuApprovalDescription<InferSchemaOutput<InputSchema>>
|
|
396
433
|
func: PikkuFunctionSessionless<
|
|
397
434
|
InferSchemaOutput<InputSchema>,
|
|
398
435
|
OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown,
|
|
@@ -404,6 +441,7 @@ export type PikkuFunctionSessionlessConfigWithSchema<
|
|
|
404
441
|
input: InputSchema
|
|
405
442
|
output?: OutputSchema
|
|
406
443
|
node?: NodeConfig
|
|
444
|
+
errors?: Array<typeof PikkuError>
|
|
407
445
|
}
|
|
408
446
|
|
|
409
447
|
/**
|
package/dist/src/services.js
CHANGED
|
@@ -221,7 +221,7 @@ export const createSingletonServices = async (config) => {
|
|
|
221
221
|
unfilteredState = await inspect(logger, wiringFiles, {
|
|
222
222
|
setupOnly,
|
|
223
223
|
rootDir,
|
|
224
|
-
isAddon: config.addon,
|
|
224
|
+
isAddon: !!config.addon,
|
|
225
225
|
types: {
|
|
226
226
|
configFileType: config.configFile,
|
|
227
227
|
userSessionType: config.userSessionType,
|
|
@@ -30,8 +30,11 @@ export const getFileImportRelativePath = (from, to, packageMappings) => {
|
|
|
30
30
|
const fromAbsolutePath = resolve(dirname(from));
|
|
31
31
|
// Check if both files are in the same package directory
|
|
32
32
|
// If so, skip packageMappings to use relative paths
|
|
33
|
+
// Skip '.' key — it matches any dot character in paths and is too generic for substring matching
|
|
33
34
|
let inSamePackage = false;
|
|
34
35
|
for (const [path] of Object.entries(packageMappings)) {
|
|
36
|
+
if (path === '.')
|
|
37
|
+
continue;
|
|
35
38
|
if (absolutePath.includes(path) && fromAbsolutePath.includes(path)) {
|
|
36
39
|
inSamePackage = true;
|
|
37
40
|
break;
|
|
@@ -39,10 +42,10 @@ export const getFileImportRelativePath = (from, to, packageMappings) => {
|
|
|
39
42
|
}
|
|
40
43
|
// Only apply packageMappings if files are not in the same package
|
|
41
44
|
if (!inSamePackage) {
|
|
42
|
-
// let usesPackageName = false
|
|
43
45
|
for (const [path, packageName] of Object.entries(packageMappings)) {
|
|
46
|
+
if (path === '.')
|
|
47
|
+
continue;
|
|
44
48
|
if (absolutePath.includes(path)) {
|
|
45
|
-
// usesPackageName = true
|
|
46
49
|
// Use string slicing instead of regex to avoid ReDoS and ensure correct behavior
|
|
47
50
|
const pathIndex = absolutePath.indexOf(path);
|
|
48
51
|
filePath = packageName + absolutePath.slice(pathIndex + path.length);
|