@karmaniverous/smoz 0.1.2

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.
@@ -0,0 +1,85 @@
1
+ # SMOZ App Template
2
+
3
+ This template provides a minimal, convention‑friendly baseline for new SMOZ apps:
4
+
5
+ - TypeScript configuration (strict, moduleResolution bundler)
6
+ - ESLint (flat config) + typescript‑eslint + Prettier
7
+ - Vitest baseline config
8
+ - TypeDoc baseline config
9
+
10
+ ## Conventions
11
+
12
+ - Author code lives under:
13
+ - `app/config/app.config.ts` — app schemas/config (params, env, http tokens)
14
+ - `app/functions/<eventType>/...` (e.g., `app/functions/rest/hello/get`)
15
+ - Generated artifacts live under:
16
+ - `app/generated/`
17
+ - `register.functions.ts` — side‑effect imports of all `lambda.ts`
18
+ - `register.openapi.ts` — side‑effect imports of all `openapi.ts`
19
+ - `register.serverless.ts` — side‑effect imports of per‑function `serverless.ts` (if any)
20
+ - `openapi.json` — OpenAPI document
21
+
22
+ ## Getting started
23
+
24
+ 1. Install dependencies
25
+ - Run: `npm install`
26
+
27
+ 2. Type checking
28
+ - Run: `npm run typecheck`
29
+
30
+ 3. Linting
31
+ - Run: `npm run lint` (or `npm run lint:fix` to auto‑fix)
32
+
33
+ 4. Tests (baseline suite OK)
34
+ - Run: `npm run test`
35
+
36
+ 5. Docs (TypeDoc baseline loads)
37
+ - Run: `npm run docs`
38
+
39
+ 6. Generate OpenAPI (if your app config and endpoints are present)
40
+ - Run: `npm run openapi`
41
+
42
+ ## SMOZ CLI — register
43
+
44
+ The CLI scans `app/functions/**` for `lambda.ts`, `openapi.ts`, and optional `serverless.ts`
45
+ and generates side‑effect registration files under `app/generated/`.
46
+
47
+ - Build CLI (if packaged locally): `npm run cli:build`
48
+ - Register: `npx smoz register`
49
+ - Idempotent: rewrites files only when content changes
50
+ - Formats output with Prettier when available
51
+
52
+ Tip: Commit `app/generated/register.*.ts` so typecheck is stable without running the CLI.
53
+ Teams often keep `app/generated/openapi.json` untracked in VCS (optional).
54
+
55
+ ## Notes
56
+
57
+ - HTTP tokens (`rest`, `http`) are configured in your `app.config.ts`. You may widen these tokens per app.
58
+ - Keep function modules small and focused:
59
+ - `lambda.ts`: define and register function (`app.defineFunction`)
60
+ - `handler.ts`: business handler exported via `fn.handler`
61
+ - `openapi.ts`: attach OpenAPI operation via `fn.openapi`
62
+ - `serverless.ts`: (non‑HTTP only) attach extra events via `fn.serverless`
63
+
64
+ ## Next steps
65
+
66
+ - Add your first endpoint (e.g., `app/functions/rest/hello/get`)
67
+ - Run the CLI register step
68
+ - Generate OpenAPI
69
+ - Package or deploy with your preferred toolchain
70
+
71
+ ## Path hygiene (cross‑platform)
72
+
73
+ Windows uses backslashes in paths, which can leak into string comparisons and
74
+ generated artifacts. Normalize separators consistently using the helper exported
75
+ by the toolkit:
76
+
77
+ ```ts
78
+ import { toPosixPath } from '@karmaniverous/smoz';
79
+
80
+ // Derive the app root as the parent directory of app/config/
81
+ import { fileURLToPath } from 'node:url';
82
+ export const APP_ROOT_ABS = toPosixPath(
83
+ fileURLToPath(new URL('..', import.meta.url)),
84
+ );
85
+ ```
@@ -0,0 +1,47 @@
1
+ import eslint from '@eslint/js';
2
+ import prettierConfig from 'eslint-config-prettier';
3
+ import prettierPlugin from 'eslint-plugin-prettier';
4
+ import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
5
+ import { dirname } from 'path';
6
+ import tseslint from 'typescript-eslint';
7
+ import { fileURLToPath } from 'url';
8
+
9
+ const tsconfigRootDir = dirname(fileURLToPath(import.meta.url));
10
+
11
+ export default [
12
+ {
13
+ ignores: [
14
+ '.serverless/**',
15
+ '.tsbuild/**',
16
+ 'coverage/**',
17
+ 'dist/**',
18
+ 'docs/**',
19
+ 'node_modules/**',
20
+ ],
21
+ },
22
+ eslint.configs.recommended,
23
+ ...tseslint.configs.strictTypeChecked,
24
+ prettierConfig,
25
+ {
26
+ languageOptions: {
27
+ parser: tseslint.parser,
28
+ parserOptions: {
29
+ project: ['./tsconfig.json'],
30
+ tsconfigRootDir,
31
+ },
32
+ },
33
+ plugins: {
34
+ prettier: prettierPlugin,
35
+ 'simple-import-sort': simpleImportSortPlugin,
36
+ },
37
+ rules: {
38
+ 'prettier/prettier': 'error',
39
+ '@typescript-eslint/consistent-type-imports': 'error',
40
+ '@typescript-eslint/no-unused-expressions': 'off',
41
+ '@typescript-eslint/no-unused-vars': 'error',
42
+ 'no-unused-vars': 'off',
43
+ 'simple-import-sort/imports': 'error',
44
+ 'simple-import-sort/exports': 'error',
45
+ },
46
+ },
47
+ ];
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "allowSyntheticDefaultImports": true,
4
+ "emitDeclarationOnly": false,
5
+ "exactOptionalPropertyTypes": true,
6
+ "module": "esnext",
7
+ "moduleDetection": "force",
8
+ "moduleResolution": "bundler",
9
+ "noEmit": true,
10
+ "noUncheckedIndexedAccess": true,
11
+ "noUncheckedSideEffectImports": true,
12
+ "resolveJsonModule": true,
13
+ "rootDir": ".",
14
+ "skipLibCheck": true,
15
+ "strict": true,
16
+ "stripInternal": true,
17
+ "target": "esnext",
18
+ "types": ["node"],
19
+ "verbatimModuleSyntax": true
20
+ }
21
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": ".",
4
+ "outDir": ".tsbuild",
5
+ "paths": {
6
+ "@/*": ["*"]
7
+ },
8
+ "tsBuildInfoFile": ".tsbuild/tsconfig.tsbuildinfo"
9
+ },
10
+ "exclude": [".serverless/**", "node_modules/**", "app/generated/**", "dist/**"],
11
+ "extends": "./tsconfig.base.json",
12
+ "include": [
13
+ "**/*",
14
+ "**/*.json"
15
+ ]
16
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "entryPoints": ["./src"],
3
+ "entryPointStrategy": "expand",
4
+ "exclude": ["**/*.test.ts", "**/*.d.ts", "**/generated/**"],
5
+ "excludeInternal": false,
6
+ "out": "./docs/",
7
+ "searchInComments": true,
8
+ "searchInDocuments": true,
9
+ "highlightLanguages": ["bash", "console", "json", "typescript"],
10
+ "navigation": {
11
+ "excludeReferences": true
12
+ },
13
+ "projectDocuments": []
14
+ }
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ environment: 'node',
6
+ exclude: ['**/node_modules/**', '**/dist/**', '**/.tsbuild/**'],
7
+ },
8
+ });