@karmaniverous/smoz 0.2.3 → 0.2.5

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.
@@ -73,111 +73,111 @@ const getParamName = (s) => {
73
73
  const toDirSeg = (s) => isParamSeg(s) ? `[${getParamName(s)}]` : s;
74
74
  /** Normalize a segment for API paths (Serverless/OpenAPI‑native). */
75
75
  const toPathSeg = (s) => isParamSeg(s) ? `{${getParamName(s)}}` : s;
76
- const lambdaHttpTemplate = ({ token, basePath, method, }) => `/**
77
- * Registration: ${method.toUpperCase()} /${basePath} (public)
78
- */
79
- import { join } from 'node:path';
80
-
81
- import { z } from 'zod';
82
-
83
- import { app, APP_ROOT_ABS } from '@/app/config/app.config';
84
-
85
- export const eventSchema = z.any();
86
- export const responseSchema = z.any();
87
-
88
- export const fn = app.defineFunction({
89
- eventType: '${token}',
90
- httpContexts: ['public'],
91
- method: '${method}',
92
- basePath: '${basePath}',
93
- contentType: 'application/json',
94
- eventSchema,
95
- responseSchema,
96
- callerModuleUrl: import.meta.url,
97
- endpointsRootAbs: join(APP_ROOT_ABS, 'functions', '${token}').replace(/\\\\\\\\/g, '/'),
98
- });
76
+ const lambdaHttpTemplate = ({ token, basePath, method, }) => `/**
77
+ * Registration: ${method.toUpperCase()} /${basePath} (public)
78
+ */
79
+ import { join } from 'node:path';
80
+
81
+ import { z } from 'zod';
82
+
83
+ import { app, APP_ROOT_ABS } from '@/app/config/app.config';
84
+
85
+ export const eventSchema = z.any();
86
+ export const responseSchema = z.any();
87
+
88
+ export const fn = app.defineFunction({
89
+ eventType: '${token}',
90
+ httpContexts: ['public'],
91
+ method: '${method}',
92
+ basePath: '${basePath}',
93
+ contentType: 'application/json',
94
+ eventSchema,
95
+ responseSchema,
96
+ callerModuleUrl: import.meta.url,
97
+ endpointsRootAbs: join(APP_ROOT_ABS, 'functions', '${token}').replace(/\\\\\\\\/g, '/'),
98
+ });
99
99
  `;
100
- const handlerHttpTemplate = () => `/**
101
- * Handler: replace with your business logic.
102
- */
103
- import { z } from 'zod';
104
-
105
- import type { responseSchema } from './lambda';
106
- import { fn } from './lambda';
107
-
108
- type Response = z.infer<typeof responseSchema>;
109
-
110
- export const handler = fn.handler(async (): Promise<Response> => {
111
- return {} as Response;
112
- });
100
+ const handlerHttpTemplate = () => `/**
101
+ * Handler: replace with your business logic.
102
+ */
103
+ import { z } from 'zod';
104
+
105
+ import type { responseSchema } from './lambda';
106
+ import { fn } from './lambda';
107
+
108
+ type Response = z.infer<typeof responseSchema>;
109
+
110
+ export const handler = fn.handler(async (): Promise<Response> => {
111
+ return {} as Response;
112
+ });
113
113
  `;
114
114
  const openapiTemplate = ({ params, pathTemplate, }) => {
115
115
  const paramsBlock = params.length > 0
116
- ? ` parameters: [
116
+ ? ` parameters: [
117
117
  ${params
118
118
  .map((p) => ` { name: '${p}', in: 'path', required: true, schema: { type: 'string' }, description: 'Path parameter: ${p}' },`)
119
- .join('\n')}
120
- ],
119
+ .join('\n')}
120
+ ],
121
121
  `
122
122
  : '';
123
- return `/* REQUIREMENTS
124
- - Define OpenAPI Path Item for the new endpoint.
125
- */
126
- import { eventSchema, fn, responseSchema } from './lambda';
127
-
128
- fn.openapi({
129
- summary: 'Describe your endpoint',
130
- description: 'Describe your endpoint. Path template: ${pathTemplate}.',
131
- ${paramsBlock} requestBody: {
132
- description: 'Request payload.',
133
- content: { 'application/json': { schema: eventSchema } },
134
- },
135
- responses: {
136
- 200: {
137
- description: 'Ok',
138
- content: { 'application/json': { schema: responseSchema } },
139
- },
140
- },
141
- tags: [],
142
- });
143
-
144
- export {};
123
+ return `/* REQUIREMENTS
124
+ - Define OpenAPI Path Item for the new endpoint.
125
+ */
126
+ import { eventSchema, fn, responseSchema } from './lambda';
127
+
128
+ fn.openapi({
129
+ summary: 'Describe your endpoint',
130
+ description: 'Describe your endpoint. Path template: ${pathTemplate}.',
131
+ ${paramsBlock} requestBody: {
132
+ description: 'Request payload.',
133
+ content: { 'application/json': { schema: eventSchema } },
134
+ },
135
+ responses: {
136
+ 200: {
137
+ description: 'Ok',
138
+ content: { 'application/json': { schema: responseSchema } },
139
+ },
140
+ },
141
+ tags: [],
142
+ });
143
+
144
+ export {};
145
145
  `;
146
146
  };
147
- const lambdaInternalTemplate = (token) => `/**
148
- * Registration: internal ${token} function.
149
- */
150
- import { join } from 'node:path';
151
-
152
- import { z } from 'zod';
153
-
154
- import { app, APP_ROOT_ABS } from '@/app/config/app.config';
155
-
156
- export const eventSchema = z.any();
157
- export const responseSchema = z.any();
158
-
159
- export const fn = app.defineFunction({
160
- eventType: '${token}',
161
- eventSchema,
162
- responseSchema,
163
- callerModuleUrl: import.meta.url,
164
- endpointsRootAbs: join(APP_ROOT_ABS, 'functions', '${token}').replace(/\\\\\\\\/g, '/'),
165
- });
147
+ const lambdaInternalTemplate = (token) => `/**
148
+ * Registration: internal ${token} function.
149
+ */
150
+ import { join } from 'node:path';
151
+
152
+ import { z } from 'zod';
153
+
154
+ import { app, APP_ROOT_ABS } from '@/app/config/app.config';
155
+
156
+ export const eventSchema = z.any();
157
+ export const responseSchema = z.any();
158
+
159
+ export const fn = app.defineFunction({
160
+ eventType: '${token}',
161
+ eventSchema,
162
+ responseSchema,
163
+ callerModuleUrl: import.meta.url,
164
+ endpointsRootAbs: join(APP_ROOT_ABS, 'functions', '${token}').replace(/\\\\\\\\/g, '/'),
165
+ });
166
166
  `;
167
- const handlerInternalTemplate = () => `/**
168
- * Handler: replace with your business logic.
169
- */
170
- import { z } from 'zod';
171
-
172
- import type { responseSchema } from './lambda';
173
- import { fn } from './lambda';
174
-
175
- type Response = z.infer<typeof responseSchema>;
176
-
177
- export const handler = fn.handler(async (_event): Promise<Response> => {
178
- void _event;
179
- return {} as Response;
180
- });
167
+ const handlerInternalTemplate = () => `/**
168
+ * Handler: replace with your business logic.
169
+ */
170
+ import { z } from 'zod';
171
+
172
+ import type { responseSchema } from './lambda';
173
+ import { fn } from './lambda';
174
+
175
+ type Response = z.infer<typeof responseSchema>;
176
+
177
+ export const handler = fn.handler(async (_event): Promise<Response> => {
178
+ void _event;
179
+ return {} as Response;
180
+ });
181
181
  `;
182
182
  const runAdd = async (root, spec) => {
183
183
  const parts = spec.split('/').filter(Boolean);
@@ -435,7 +435,7 @@ const runOpenapi = async (root, opts) => {
435
435
  */
436
436
  const toPosix$1 = (p) => p.split(path.sep).join('/');
437
437
  const withoutTsExt = (p) => p.endsWith('.ts') ? p.slice(0, -3) : p;
438
- const HEADER = `/* AUTO-GENERATED by smoz register — DO NOT EDIT */
438
+ const HEADER = `/* AUTO-GENERATED by smoz register — DO NOT EDIT */
439
439
  `;
440
440
  const formatMaybe = async (root, filePath, source) => {
441
441
  try {