@supacloud/compiler 0.42.0 → 0.43.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.
@@ -185,9 +185,11 @@ function parse(file, text) {
185
185
  return ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
186
186
  }
187
187
  function unique(items, description) {
188
- if (items.length !== 1)
188
+ const [item] = items;
189
+ if (items.length !== 1 || item === undefined) {
189
190
  throw new Error(`Expected exactly one ${description}; found ${items.length}`);
190
- return items[0];
191
+ }
192
+ return item;
191
193
  }
192
194
  function identifier(value) {
193
195
  if (!/^[A-Za-z_$][\w$]*$/.test(value))
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Local stand-in for @supacloud/app in fixture projects: noop implementations of decorators and tokens.
3
3
  * AST analysis matches decorators by name only and generated code does not import it;
4
- * implementation exists only so fixture sources can be dynamically imported and executed by bun.
4
+ * implementation lets fixture sources pass TypeScript checks and execute under bun.
5
5
  */
6
- export declare const RUNTIME_SOURCE = "export class InjectionToken<T = unknown> {\n readonly name: string;\n readonly scope?: string;\n\n constructor(name: string, options: { scope?: string } = {}) {\n this.name = name;\n this.scope = options.scope;\n }\n}\n\nexport function Injectable(_options: { scope?: string; deps?: unknown[] } = {}) {\n return () => {};\n}\n\nexport function Inject(_token: unknown) {\n return () => {};\n}\n\nexport function Module(_options: Record<string, unknown>) {\n return () => {};\n}\n\nexport function defineModule(_options: Record<string, unknown>) {\n return class DefinedModule {};\n}\n\nexport function Command(_options: Record<string, unknown>) {\n return () => {};\n}\n\nexport function Job(_options: Record<string, unknown>) {\n return () => {};\n}\n\nexport function Query(_options: Record<string, unknown>) {\n return () => {};\n}\n\nexport function InfraResource(_options: { name: string; kind: string }) {\n return () => {};\n}\n\nexport function Controller(_path: string) {\n return () => {};\n}\n\nfunction routeDecorator(_method: string) {\n return (_path: string, _options?: Record<string, unknown>) => () => {};\n}\n\nexport const Get = routeDecorator(\"GET\");\nexport const Post = routeDecorator(\"POST\");\nexport const Put = routeDecorator(\"PUT\");\nexport const Patch = routeDecorator(\"PATCH\");\nexport const Delete = routeDecorator(\"DELETE\");\nexport const Head = routeDecorator(\"HEAD\");\nexport const Options = routeDecorator(\"OPTIONS\");\n\nexport const REQUEST_CONTEXT = new InjectionToken(\"supacloud.request-context\", {\n scope: \"request\",\n});\nexport const JOB_CONTEXT = new InjectionToken(\"supacloud.job-context\", {\n scope: \"job\",\n});\n";
6
+ export declare const RUNTIME_SOURCE = "export class InjectionToken<T = unknown> {\n readonly name: string;\n readonly scope: string | undefined;\n\n constructor(name: string, options: { scope?: string } = {}) {\n this.name = name;\n this.scope = options.scope;\n }\n}\n\nexport function Injectable(_options: { scope?: string; deps?: unknown[] } = {}) {\n return (..._args: unknown[]) => {};\n}\n\nexport function Inject(_token: unknown) {\n return (..._args: unknown[]) => {};\n}\n\nexport function Module(_options: Record<string, unknown>) {\n return (..._args: unknown[]) => {};\n}\n\nexport function defineModule(_options: Record<string, unknown>) {\n return class DefinedModule {};\n}\n\nexport function Command(_options: Record<string, unknown>) {\n return (..._args: unknown[]) => {};\n}\n\nexport function Job(_options: Record<string, unknown>) {\n return (..._args: unknown[]) => {};\n}\n\nexport function Query(_options: Record<string, unknown>) {\n return (..._args: unknown[]) => {};\n}\n\nexport function InfraResource(_options: { name: string; kind: string }) {\n return (..._args: unknown[]) => {};\n}\n\nexport function Controller(_path: string | Record<string, unknown>) {\n return (..._args: unknown[]) => {};\n}\n\nexport function Body() {\n return (..._args: unknown[]) => {};\n}\n\nexport function Headers(_name?: string) {\n return (..._args: unknown[]) => {};\n}\n\nexport function UseGuards(..._guards: string[]) {\n return (..._args: unknown[]) => {};\n}\n\nfunction routeDecorator(_method: string) {\n return (_path: string, _options?: Record<string, unknown>) => (..._args: unknown[]) => {};\n}\n\nexport const Get = routeDecorator(\"GET\");\nexport const Post = routeDecorator(\"POST\");\nexport const Put = routeDecorator(\"PUT\");\nexport const Patch = routeDecorator(\"PATCH\");\nexport const Delete = routeDecorator(\"DELETE\");\nexport const Head = routeDecorator(\"HEAD\");\nexport const Options = routeDecorator(\"OPTIONS\");\n\nexport const REQUEST_CONTEXT = new InjectionToken(\"supacloud.request-context\", {\n scope: \"request\",\n});\nexport const JOB_CONTEXT = new InjectionToken(\"supacloud.job-context\", {\n scope: \"job\",\n});\n";
7
7
  export declare const FIXTURE_TSCONFIG = "{\n \"compilerOptions\": {\n \"target\": \"ES2022\",\n \"module\": \"ESNext\",\n \"moduleResolution\": \"bundler\",\n \"experimentalDecorators\": true,\n \"strict\": true\n }\n}\n";