@ic-reactor/codegen 0.12.1 → 0.13.0

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/index.d.cts CHANGED
@@ -190,6 +190,18 @@ declare function assertSafeCanisterName(name: unknown): asserts name is string;
190
190
  * remote host at import time, inside the user's own bundle.
191
191
  */
192
192
  declare function assertSafeModuleSpecifier(label: string, specifier: unknown): asserts specifier is string;
193
+ /**
194
+ * Derive the declarations file stem from a `.did` path and assert it is usable
195
+ * both as a file name and as the tail of the import specifier we emit.
196
+ *
197
+ * `path.basename` is happy to hand back `"."` or `".."`: a `didFile` of
198
+ * `"canisters/.."` makes the generated reactor `import … from
199
+ * "./declarations/.."`, a *directory* reference — reported as a successful
200
+ * generation, rejected by the consumer's bundler. Validating the derived
201
+ * specifier here is the same treatment `clientManagerPath` gets, for the same
202
+ * reason: it is config-supplied text that ends up inside an `import`.
203
+ */
204
+ declare function resolveDeclarationsBaseName(didFile: unknown): string;
193
205
  /** Reactor classes the generator knows how to emit an import for. */
194
206
  declare const REACTOR_CLASS_NAMES: readonly ReactorClassName[];
195
207
  /** Runtime targets the generator knows how to emit. */
@@ -250,34 +262,6 @@ interface ValidateCanisterConfigOptions {
250
262
  */
251
263
  declare function assertSafeCanisterConfig(options: ValidateCanisterConfigOptions): ValidatedCanisterPaths;
252
264
 
253
- /**
254
- * Candid Parser Utilities
255
- *
256
- * Parses Candid .did files to extract service method signatures.
257
- * Used by the CLI for listing methods and by advanced generators.
258
- */
259
- type MethodType = "query" | "mutation";
260
- interface MethodInfo {
261
- /** Method name as it appears in the Candid service */
262
- name: string;
263
- /** "query" for read-only calls, "mutation" for update calls */
264
- type: MethodType;
265
- /** True if the method takes at least one argument */
266
- hasArgs: boolean;
267
- }
268
- /**
269
- * Extract method information from raw Candid source text.
270
- *
271
- * Compiles the Candid to JS and inspects the IDL.Service definition.
272
- */
273
- declare function extractMethods(didContent: string): MethodInfo[];
274
- /**
275
- * Parse a .did file from disk and return its methods.
276
- *
277
- * @throws if the file does not exist or fails to parse
278
- */
279
- declare function parseDIDFile(didFilePath: string): MethodInfo[];
280
-
281
265
  /**
282
266
  * Declarations Generator
283
267
  *
@@ -304,17 +288,17 @@ interface DeclarationsGeneratorResult {
304
288
  files: GeneratorResult[];
305
289
  error?: string;
306
290
  }
307
- /**
308
- * Generate TypeScript declarations from a Candid file.
309
- *
310
- * Always cleans and regenerates the declarations directory to ensure
311
- * it's in sync with the source .did file.
312
- */
313
291
  declare function generateDeclarations(options: DeclarationsGeneratorOptions): Promise<DeclarationsGeneratorResult>;
314
292
  /**
315
293
  * Check if declarations already exist for a canister.
294
+ *
295
+ * Declarations are written under the *.did basename*, which need not equal the
296
+ * canister name — `{ name: "backend", didFile: "service.did" }` writes
297
+ * `declarations/service.d.ts`. Pass `didFile` for an exact answer; without it
298
+ * this falls back to any `.d.ts` in the directory, because a bare
299
+ * `<canisterName>.d.ts` check reports "missing" for perfectly good output.
316
300
  */
317
- declare function declarationsExist(outDir: string, canisterName: string): boolean;
301
+ declare function declarationsExist(outDir: string, canisterName: string, didFile?: string): boolean;
318
302
 
319
303
  /**
320
304
  * Reactor File Generator
@@ -393,4 +377,4 @@ interface ClientGeneratorOptions {
393
377
  */
394
378
  declare function generateClientFile(options?: ClientGeneratorOptions): string;
395
379
 
396
- export { CANISTER_NAME_PATTERN, CODEGEN_TARGETS, type CanisterConfig, type ClientGeneratorOptions, type CodegenConfig, CodegenConfigError, type CodegenTarget, type DeclarationsGeneratorOptions, type DeclarationsGeneratorResult, type GeneratorResult, type MethodInfo, type MethodType, type PipelineOptions, type PipelineResult, REACTOR_CLASS_NAMES, type ReactorClassName, type ReactorGeneratorOptions, type ValidateCanisterConfigOptions, type ValidatedCanisterPaths, assertContainedPath, assertOneOf, assertSafeCanisterConfig, assertSafeCanisterName, assertSafeModuleSpecifier, declarationsExist, extractMethods, generateClientFile, generateDeclarations, generateReactorEntryFile, generateReactorFile, getReactorName, getServiceTypeName, parseDIDFile, resolveContainedOutDir, runCanisterPipeline, toPascalCase };
380
+ export { CANISTER_NAME_PATTERN, CODEGEN_TARGETS, type CanisterConfig, type ClientGeneratorOptions, type CodegenConfig, CodegenConfigError, type CodegenTarget, type DeclarationsGeneratorOptions, type DeclarationsGeneratorResult, type GeneratorResult, type PipelineOptions, type PipelineResult, REACTOR_CLASS_NAMES, type ReactorClassName, type ReactorGeneratorOptions, type ValidateCanisterConfigOptions, type ValidatedCanisterPaths, assertContainedPath, assertOneOf, assertSafeCanisterConfig, assertSafeCanisterName, assertSafeModuleSpecifier, declarationsExist, generateClientFile, generateDeclarations, generateReactorEntryFile, generateReactorFile, getReactorName, getServiceTypeName, resolveContainedOutDir, resolveDeclarationsBaseName, runCanisterPipeline, toPascalCase };
package/dist/index.d.ts CHANGED
@@ -190,6 +190,18 @@ declare function assertSafeCanisterName(name: unknown): asserts name is string;
190
190
  * remote host at import time, inside the user's own bundle.
191
191
  */
192
192
  declare function assertSafeModuleSpecifier(label: string, specifier: unknown): asserts specifier is string;
193
+ /**
194
+ * Derive the declarations file stem from a `.did` path and assert it is usable
195
+ * both as a file name and as the tail of the import specifier we emit.
196
+ *
197
+ * `path.basename` is happy to hand back `"."` or `".."`: a `didFile` of
198
+ * `"canisters/.."` makes the generated reactor `import … from
199
+ * "./declarations/.."`, a *directory* reference — reported as a successful
200
+ * generation, rejected by the consumer's bundler. Validating the derived
201
+ * specifier here is the same treatment `clientManagerPath` gets, for the same
202
+ * reason: it is config-supplied text that ends up inside an `import`.
203
+ */
204
+ declare function resolveDeclarationsBaseName(didFile: unknown): string;
193
205
  /** Reactor classes the generator knows how to emit an import for. */
194
206
  declare const REACTOR_CLASS_NAMES: readonly ReactorClassName[];
195
207
  /** Runtime targets the generator knows how to emit. */
@@ -250,34 +262,6 @@ interface ValidateCanisterConfigOptions {
250
262
  */
251
263
  declare function assertSafeCanisterConfig(options: ValidateCanisterConfigOptions): ValidatedCanisterPaths;
252
264
 
253
- /**
254
- * Candid Parser Utilities
255
- *
256
- * Parses Candid .did files to extract service method signatures.
257
- * Used by the CLI for listing methods and by advanced generators.
258
- */
259
- type MethodType = "query" | "mutation";
260
- interface MethodInfo {
261
- /** Method name as it appears in the Candid service */
262
- name: string;
263
- /** "query" for read-only calls, "mutation" for update calls */
264
- type: MethodType;
265
- /** True if the method takes at least one argument */
266
- hasArgs: boolean;
267
- }
268
- /**
269
- * Extract method information from raw Candid source text.
270
- *
271
- * Compiles the Candid to JS and inspects the IDL.Service definition.
272
- */
273
- declare function extractMethods(didContent: string): MethodInfo[];
274
- /**
275
- * Parse a .did file from disk and return its methods.
276
- *
277
- * @throws if the file does not exist or fails to parse
278
- */
279
- declare function parseDIDFile(didFilePath: string): MethodInfo[];
280
-
281
265
  /**
282
266
  * Declarations Generator
283
267
  *
@@ -304,17 +288,17 @@ interface DeclarationsGeneratorResult {
304
288
  files: GeneratorResult[];
305
289
  error?: string;
306
290
  }
307
- /**
308
- * Generate TypeScript declarations from a Candid file.
309
- *
310
- * Always cleans and regenerates the declarations directory to ensure
311
- * it's in sync with the source .did file.
312
- */
313
291
  declare function generateDeclarations(options: DeclarationsGeneratorOptions): Promise<DeclarationsGeneratorResult>;
314
292
  /**
315
293
  * Check if declarations already exist for a canister.
294
+ *
295
+ * Declarations are written under the *.did basename*, which need not equal the
296
+ * canister name — `{ name: "backend", didFile: "service.did" }` writes
297
+ * `declarations/service.d.ts`. Pass `didFile` for an exact answer; without it
298
+ * this falls back to any `.d.ts` in the directory, because a bare
299
+ * `<canisterName>.d.ts` check reports "missing" for perfectly good output.
316
300
  */
317
- declare function declarationsExist(outDir: string, canisterName: string): boolean;
301
+ declare function declarationsExist(outDir: string, canisterName: string, didFile?: string): boolean;
318
302
 
319
303
  /**
320
304
  * Reactor File Generator
@@ -393,4 +377,4 @@ interface ClientGeneratorOptions {
393
377
  */
394
378
  declare function generateClientFile(options?: ClientGeneratorOptions): string;
395
379
 
396
- export { CANISTER_NAME_PATTERN, CODEGEN_TARGETS, type CanisterConfig, type ClientGeneratorOptions, type CodegenConfig, CodegenConfigError, type CodegenTarget, type DeclarationsGeneratorOptions, type DeclarationsGeneratorResult, type GeneratorResult, type MethodInfo, type MethodType, type PipelineOptions, type PipelineResult, REACTOR_CLASS_NAMES, type ReactorClassName, type ReactorGeneratorOptions, type ValidateCanisterConfigOptions, type ValidatedCanisterPaths, assertContainedPath, assertOneOf, assertSafeCanisterConfig, assertSafeCanisterName, assertSafeModuleSpecifier, declarationsExist, extractMethods, generateClientFile, generateDeclarations, generateReactorEntryFile, generateReactorFile, getReactorName, getServiceTypeName, parseDIDFile, resolveContainedOutDir, runCanisterPipeline, toPascalCase };
380
+ export { CANISTER_NAME_PATTERN, CODEGEN_TARGETS, type CanisterConfig, type ClientGeneratorOptions, type CodegenConfig, CodegenConfigError, type CodegenTarget, type DeclarationsGeneratorOptions, type DeclarationsGeneratorResult, type GeneratorResult, type PipelineOptions, type PipelineResult, REACTOR_CLASS_NAMES, type ReactorClassName, type ReactorGeneratorOptions, type ValidateCanisterConfigOptions, type ValidatedCanisterPaths, assertContainedPath, assertOneOf, assertSafeCanisterConfig, assertSafeCanisterName, assertSafeModuleSpecifier, declarationsExist, generateClientFile, generateDeclarations, generateReactorEntryFile, generateReactorFile, getReactorName, getServiceTypeName, resolveContainedOutDir, resolveDeclarationsBaseName, runCanisterPipeline, toPascalCase };