@open-mercato/shared 0.6.1-develop.3227.1.2b7b8ab258 → 0.6.1-develop.3256.1.fe3dec2464

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.
@@ -125,7 +125,8 @@ function createCrudOpenApiFactory(config) {
125
125
  description: `${resourceName} deleted`,
126
126
  schema: del.responseSchema ?? fallbackOkResponseSchema
127
127
  }
128
- ]
128
+ ],
129
+ ...del.errors && del.errors.length > 0 ? { errors: del.errors } : {}
129
130
  };
130
131
  }
131
132
  return {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/openapi/crud.ts"],
4
- "sourcesContent": ["import { z, type ZodTypeAny } from 'zod'\nimport type { OpenApiRouteDoc } from './types'\n\nexport const defaultCreateResponseSchema = z.object({ id: z.string().uuid().nullable() })\nexport const defaultOkResponseSchema = z.object({ ok: z.literal(true) })\n\nexport type PagedListResponseOptions = {\n paginationMetaOptional?: boolean\n}\n\nexport function createPagedListResponseSchema(itemSchema: ZodTypeAny, options: PagedListResponseOptions = {}) {\n const paginationMetaOptional = options.paginationMetaOptional ?? false\n\n return z.object({\n items: z.array(itemSchema),\n total: z.number(),\n page: paginationMetaOptional ? z.number().optional() : z.number(),\n pageSize: paginationMetaOptional ? z.number().optional() : z.number(),\n totalPages: z.number(),\n })\n}\n\ntype CrudMethodConfig = {\n schema: ZodTypeAny\n description?: string\n responseSchema?: ZodTypeAny\n}\n\ntype CrudCreateConfig = CrudMethodConfig & {\n status?: number\n}\n\ntype CrudDeleteConfig = {\n schema?: ZodTypeAny\n description?: string\n responseSchema?: ZodTypeAny\n}\n\nexport type CrudOpenApiOptions = {\n tag?: string\n resourceName: string\n pluralName?: string\n description?: string\n querySchema?: ZodTypeAny\n listResponseSchema: ZodTypeAny\n create?: CrudCreateConfig\n update?: CrudMethodConfig\n del?: CrudDeleteConfig\n}\n\nexport type CrudTextContext = {\n resourceName: string\n resourceLower: string\n pluralName: string\n pluralLower: string\n}\n\nexport type CrudOpenApiFactoryConfig = {\n defaultTag: string\n defaultCreateResponseSchema?: ZodTypeAny\n defaultOkResponseSchema?: ZodTypeAny\n makeListDescription?: (ctx: CrudTextContext) => string\n makeCreateDescription?: (ctx: CrudTextContext) => string\n makeCreateRequestBodyDescription?: (ctx: CrudTextContext) => string\n makeUpdateDescription?: (ctx: CrudTextContext) => string\n makeUpdateRequestBodyDescription?: (ctx: CrudTextContext) => string\n makeDeleteDescription?: (ctx: CrudTextContext) => string\n makeDeleteRequestBodyDescription?: (ctx: CrudTextContext) => string\n}\n\nfunction withIdsQueryParam(schema: ZodTypeAny | undefined): ZodTypeAny | undefined {\n if (!schema) return schema\n if (!(schema instanceof z.ZodObject)) return schema\n return schema.extend({\n ids: z\n .string()\n .optional()\n .describe('Comma-separated list of record UUIDs to filter by (max 200).'),\n })\n}\n\nfunction resolveDefault(\n factory: ((ctx: CrudTextContext) => string) | undefined,\n ctx: CrudTextContext,\n fallback: string,\n) {\n if (typeof factory === 'function') return factory(ctx)\n return fallback\n}\n\nexport function createCrudOpenApiFactory(config: CrudOpenApiFactoryConfig) {\n return function createCrudOpenApi(options: CrudOpenApiOptions): OpenApiRouteDoc {\n const {\n resourceName,\n pluralName,\n tag,\n description,\n querySchema,\n listResponseSchema,\n create,\n update,\n del,\n } = options\n\n const plural = pluralName ?? `${resourceName}s`\n const resourceLower = resourceName.toLowerCase()\n const pluralLower = plural.toLowerCase()\n const context: CrudTextContext = {\n resourceName,\n resourceLower,\n pluralName: plural,\n pluralLower,\n }\n\n const fallbackCreateResponseSchema = config.defaultCreateResponseSchema ?? defaultCreateResponseSchema\n const fallbackOkResponseSchema = config.defaultOkResponseSchema ?? defaultOkResponseSchema\n\n const methods: NonNullable<OpenApiRouteDoc['methods']> = {}\n\n methods.GET = {\n summary: `List ${pluralLower}`,\n description:\n description ?? resolveDefault(config.makeListDescription, context, `Returns a paginated collection of ${pluralLower}.`),\n query: withIdsQueryParam(querySchema),\n responses: [\n {\n status: 200,\n description: `Paginated ${pluralLower}`,\n schema: listResponseSchema,\n },\n ],\n }\n\n if (create) {\n const createDescription =\n create.description ??\n resolveDefault(config.makeCreateDescription, context, `Creates a new ${resourceLower}.`)\n\n const createBodyDescription =\n resolveDefault(\n config.makeCreateRequestBodyDescription,\n context,\n create.description ?? `Payload describing the ${resourceLower} to create.`,\n )\n\n methods.POST = {\n summary: `Create ${resourceLower}`,\n description: createDescription,\n requestBody: {\n schema: create.schema,\n description: createBodyDescription,\n },\n responses: [\n {\n status: create.status ?? 201,\n description: `${resourceName} created`,\n schema: create.responseSchema ?? fallbackCreateResponseSchema,\n },\n ],\n }\n }\n\n if (update) {\n const updateDescription =\n update.description ??\n resolveDefault(config.makeUpdateDescription, context, `Updates an existing ${resourceLower} by id.`)\n\n const updateBodyDescription =\n resolveDefault(\n config.makeUpdateRequestBodyDescription,\n context,\n update.description ?? `Fields to update on the ${resourceLower}.`,\n )\n\n methods.PUT = {\n summary: `Update ${resourceLower}`,\n description: updateDescription,\n requestBody: {\n schema: update.schema,\n description: updateBodyDescription,\n },\n responses: [\n {\n status: 200,\n description: `${resourceName} updated`,\n schema: update.responseSchema ?? fallbackOkResponseSchema,\n },\n ],\n }\n }\n\n if (del) {\n const deleteDescription =\n del.description ??\n resolveDefault(config.makeDeleteDescription, context, `Deletes a ${resourceLower} identified by id.`)\n\n const deleteBodyDescription =\n resolveDefault(\n config.makeDeleteRequestBodyDescription,\n context,\n del.description ?? 'Identifier payload.',\n )\n\n methods.DELETE = {\n summary: `Delete ${resourceLower}`,\n description: deleteDescription,\n requestBody: del.schema\n ? {\n schema: del.schema,\n description: deleteBodyDescription,\n }\n : undefined,\n responses: [\n {\n status: 200,\n description: `${resourceName} deleted`,\n schema: del.responseSchema ?? fallbackOkResponseSchema,\n },\n ],\n }\n }\n\n return {\n tag: tag ?? config.defaultTag,\n summary: `${resourceName} management`,\n methods,\n }\n }\n}\n"],
5
- "mappings": "AAAA,SAAS,SA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E,QAAQ;AAAA,YACR,aAAa,GAAG,YAAY;AAAA,YAC5B,QAAQ,OAAO,kBAAkB;AAAA,UACnC;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAEA,QAAI,KAAK;AACP,YAAM,oBACJ,IAAI,eACJ,eAAe,OAAO,uBAAuB,SAAS,aAAa,aAAa,oBAAoB;AAEtG,YAAM,wBACJ;AAAA,QACE,OAAO;AAAA,QACP;AAAA,QACA,IAAI,eAAe;AAAA,MACrB;AAEF,cAAQ,SAAS;AAAA,QACf,SAAS,UAAU,aAAa;AAAA,QAChC,aAAa;AAAA,QACb,aAAa,IAAI,SACb;AAAA,UACE,QAAQ,IAAI;AAAA,UACZ,aAAa;AAAA,QACf,IACA;AAAA,QACJ,WAAW;AAAA,UACT;AAAA,YACE,QAAQ;AAAA,YACR,aAAa,GAAG,YAAY;AAAA,YAC5B,QAAQ,IAAI,kBAAkB;AAAA,UAChC;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAEA,WAAO;AAAA,MACL,KAAK,OAAO,OAAO;AAAA,MACnB,SAAS,GAAG,YAAY;AAAA,MACxB;AAAA,IACF;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import { z, type ZodTypeAny } from 'zod'\nimport type { OpenApiResponseDoc, OpenApiRouteDoc } from './types'\n\nexport const defaultCreateResponseSchema = z.object({ id: z.string().uuid().nullable() })\nexport const defaultOkResponseSchema = z.object({ ok: z.literal(true) })\n\nexport type PagedListResponseOptions = {\n paginationMetaOptional?: boolean\n}\n\nexport function createPagedListResponseSchema(itemSchema: ZodTypeAny, options: PagedListResponseOptions = {}) {\n const paginationMetaOptional = options.paginationMetaOptional ?? false\n\n return z.object({\n items: z.array(itemSchema),\n total: z.number(),\n page: paginationMetaOptional ? z.number().optional() : z.number(),\n pageSize: paginationMetaOptional ? z.number().optional() : z.number(),\n totalPages: z.number(),\n })\n}\n\ntype CrudMethodConfig = {\n schema: ZodTypeAny\n description?: string\n responseSchema?: ZodTypeAny\n}\n\ntype CrudCreateConfig = CrudMethodConfig & {\n status?: number\n}\n\ntype CrudDeleteConfig = {\n schema?: ZodTypeAny\n description?: string\n responseSchema?: ZodTypeAny\n errors?: OpenApiResponseDoc[]\n}\n\nexport type CrudOpenApiOptions = {\n tag?: string\n resourceName: string\n pluralName?: string\n description?: string\n querySchema?: ZodTypeAny\n listResponseSchema: ZodTypeAny\n create?: CrudCreateConfig\n update?: CrudMethodConfig\n del?: CrudDeleteConfig\n}\n\nexport type CrudTextContext = {\n resourceName: string\n resourceLower: string\n pluralName: string\n pluralLower: string\n}\n\nexport type CrudOpenApiFactoryConfig = {\n defaultTag: string\n defaultCreateResponseSchema?: ZodTypeAny\n defaultOkResponseSchema?: ZodTypeAny\n makeListDescription?: (ctx: CrudTextContext) => string\n makeCreateDescription?: (ctx: CrudTextContext) => string\n makeCreateRequestBodyDescription?: (ctx: CrudTextContext) => string\n makeUpdateDescription?: (ctx: CrudTextContext) => string\n makeUpdateRequestBodyDescription?: (ctx: CrudTextContext) => string\n makeDeleteDescription?: (ctx: CrudTextContext) => string\n makeDeleteRequestBodyDescription?: (ctx: CrudTextContext) => string\n}\n\nfunction withIdsQueryParam(schema: ZodTypeAny | undefined): ZodTypeAny | undefined {\n if (!schema) return schema\n if (!(schema instanceof z.ZodObject)) return schema\n return schema.extend({\n ids: z\n .string()\n .optional()\n .describe('Comma-separated list of record UUIDs to filter by (max 200).'),\n })\n}\n\nfunction resolveDefault(\n factory: ((ctx: CrudTextContext) => string) | undefined,\n ctx: CrudTextContext,\n fallback: string,\n) {\n if (typeof factory === 'function') return factory(ctx)\n return fallback\n}\n\nexport function createCrudOpenApiFactory(config: CrudOpenApiFactoryConfig) {\n return function createCrudOpenApi(options: CrudOpenApiOptions): OpenApiRouteDoc {\n const {\n resourceName,\n pluralName,\n tag,\n description,\n querySchema,\n listResponseSchema,\n create,\n update,\n del,\n } = options\n\n const plural = pluralName ?? `${resourceName}s`\n const resourceLower = resourceName.toLowerCase()\n const pluralLower = plural.toLowerCase()\n const context: CrudTextContext = {\n resourceName,\n resourceLower,\n pluralName: plural,\n pluralLower,\n }\n\n const fallbackCreateResponseSchema = config.defaultCreateResponseSchema ?? defaultCreateResponseSchema\n const fallbackOkResponseSchema = config.defaultOkResponseSchema ?? defaultOkResponseSchema\n\n const methods: NonNullable<OpenApiRouteDoc['methods']> = {}\n\n methods.GET = {\n summary: `List ${pluralLower}`,\n description:\n description ?? resolveDefault(config.makeListDescription, context, `Returns a paginated collection of ${pluralLower}.`),\n query: withIdsQueryParam(querySchema),\n responses: [\n {\n status: 200,\n description: `Paginated ${pluralLower}`,\n schema: listResponseSchema,\n },\n ],\n }\n\n if (create) {\n const createDescription =\n create.description ??\n resolveDefault(config.makeCreateDescription, context, `Creates a new ${resourceLower}.`)\n\n const createBodyDescription =\n resolveDefault(\n config.makeCreateRequestBodyDescription,\n context,\n create.description ?? `Payload describing the ${resourceLower} to create.`,\n )\n\n methods.POST = {\n summary: `Create ${resourceLower}`,\n description: createDescription,\n requestBody: {\n schema: create.schema,\n description: createBodyDescription,\n },\n responses: [\n {\n status: create.status ?? 201,\n description: `${resourceName} created`,\n schema: create.responseSchema ?? fallbackCreateResponseSchema,\n },\n ],\n }\n }\n\n if (update) {\n const updateDescription =\n update.description ??\n resolveDefault(config.makeUpdateDescription, context, `Updates an existing ${resourceLower} by id.`)\n\n const updateBodyDescription =\n resolveDefault(\n config.makeUpdateRequestBodyDescription,\n context,\n update.description ?? `Fields to update on the ${resourceLower}.`,\n )\n\n methods.PUT = {\n summary: `Update ${resourceLower}`,\n description: updateDescription,\n requestBody: {\n schema: update.schema,\n description: updateBodyDescription,\n },\n responses: [\n {\n status: 200,\n description: `${resourceName} updated`,\n schema: update.responseSchema ?? fallbackOkResponseSchema,\n },\n ],\n }\n }\n\n if (del) {\n const deleteDescription =\n del.description ??\n resolveDefault(config.makeDeleteDescription, context, `Deletes a ${resourceLower} identified by id.`)\n\n const deleteBodyDescription =\n resolveDefault(\n config.makeDeleteRequestBodyDescription,\n context,\n del.description ?? 'Identifier payload.',\n )\n\n methods.DELETE = {\n summary: `Delete ${resourceLower}`,\n description: deleteDescription,\n requestBody: del.schema\n ? {\n schema: del.schema,\n description: deleteBodyDescription,\n }\n : undefined,\n responses: [\n {\n status: 200,\n description: `${resourceName} deleted`,\n schema: del.responseSchema ?? fallbackOkResponseSchema,\n },\n ],\n ...(del.errors && del.errors.length > 0 ? { errors: del.errors } : {}),\n }\n }\n\n return {\n tag: tag ?? config.defaultTag,\n summary: `${resourceName} management`,\n methods,\n }\n }\n}\n"],
5
+ "mappings": "AAAA,SAAS,SAA0B;AAG5B,MAAM,8BAA8B,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AACjF,MAAM,0BAA0B,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,IAAI,EAAE,CAAC;AAMhE,SAAS,8BAA8B,YAAwB,UAAoC,CAAC,GAAG;AAC5G,QAAM,yBAAyB,QAAQ,0BAA0B;AAEjE,SAAO,EAAE,OAAO;AAAA,IACd,OAAO,EAAE,MAAM,UAAU;AAAA,IACzB,OAAO,EAAE,OAAO;AAAA,IAChB,MAAM,yBAAyB,EAAE,OAAO,EAAE,SAAS,IAAI,EAAE,OAAO;AAAA,IAChE,UAAU,yBAAyB,EAAE,OAAO,EAAE,SAAS,IAAI,EAAE,OAAO;AAAA,IACpE,YAAY,EAAE,OAAO;AAAA,EACvB,CAAC;AACH;AAmDA,SAAS,kBAAkB,QAAwD;AACjF,MAAI,CAAC,OAAQ,QAAO;AACpB,MAAI,EAAE,kBAAkB,EAAE,WAAY,QAAO;AAC7C,SAAO,OAAO,OAAO;AAAA,IACnB,KAAK,EACF,OAAO,EACP,SAAS,EACT,SAAS,8DAA8D;AAAA,EAC5E,CAAC;AACH;AAEA,SAAS,eACP,SACA,KACA,UACA;AACA,MAAI,OAAO,YAAY,WAAY,QAAO,QAAQ,GAAG;AACrD,SAAO;AACT;AAEO,SAAS,y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.6.1-develop.3227.1.2b7b8ab258";
1
+ const APP_VERSION = "0.6.1-develop.3256.1.fe3dec2464";
2
2
  const appVersion = APP_VERSION;
3
3
  export {
4
4
  APP_VERSION,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/lib/version.ts"],
4
- "sourcesContent": ["// Build-time generated version\nexport const APP_VERSION = '0.6.1-develop.3227.1.2b7b8ab258'\nexport const appVersion = APP_VERSION\n"],
4
+ "sourcesContent": ["// Build-time generated version\nexport const APP_VERSION = '0.6.1-develop.3256.1.fe3dec2464'\nexport const appVersion = APP_VERSION\n"],
5
5
  "mappings": "AACO,MAAM,cAAc;AACpB,MAAM,aAAa;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/shared",
3
- "version": "0.6.1-develop.3227.1.2b7b8ab258",
3
+ "version": "0.6.1-develop.3256.1.fe3dec2464",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -92,7 +92,7 @@
92
92
  "@mikro-orm/core": "^7.0.15",
93
93
  "@mikro-orm/decorators": "^7.0.15",
94
94
  "@mikro-orm/postgresql": "^7.0.15",
95
- "@open-mercato/cache": "0.6.1-develop.3227.1.2b7b8ab258",
95
+ "@open-mercato/cache": "0.6.1-develop.3256.1.fe3dec2464",
96
96
  "dotenv": "^17.4.2",
97
97
  "rate-limiter-flexible": "^11.1.0",
98
98
  "reflect-metadata": "^0.2.2",
@@ -21,7 +21,7 @@ export type EnvLookup = Record<string, string | undefined>
21
21
  * Metadata describing a single model available in an LLM provider.
22
22
  *
23
23
  * Used by the AI Assistant UI to populate model dropdowns and by the
24
- * routing layer to pick defaults when `OPENCODE_MODEL` is not set.
24
+ * routing layer to pick defaults when `OM_AI_MODEL` is not set.
25
25
  */
26
26
  export interface LlmModelInfo {
27
27
  /**
@@ -56,9 +56,10 @@ export interface LlmCreateModelOptions {
56
56
  /** Resolved API key for the provider. */
57
57
  apiKey: string
58
58
  /**
59
- * Optional override for adapters that support a custom base URL
60
- * (e.g. OpenAI protocol adapter pointed at DeepInfra, Groq, or LiteLLM).
61
- * Adapters that don't use base URLs (Anthropic, Google) ignore this.
59
+ * Optional override for the upstream base URL. Every OpenAI-compatible
60
+ * adapter MUST honor baseURL; Anthropic now also honors it (Messages-
61
+ * protocol relays only — Cloudflare AI Gateway in Anthropic mode, Helicone
62
+ * proxy); Google honors it when the SDK supports it (@ai-sdk/google ≥3.0).
62
63
  */
63
64
  baseURL?: string
64
65
  }
@@ -76,8 +77,8 @@ export interface LlmProvider {
76
77
  /**
77
78
  * Stable identifier used in configuration, env vars, and the registry.
78
79
  * MUST be lowercase snake_case or kebab-case (e.g. `anthropic`, `deepinfra`,
79
- * `openai`, `internal-litellm`). The `OPENCODE_PROVIDER` env var resolves
80
- * to this value.
80
+ * `openai`, `internal-litellm`). The `OM_AI_PROVIDER` env var resolves to
81
+ * this value; the legacy `OPENCODE_PROVIDER` env var is a BC fallback.
81
82
  */
82
83
  readonly id: string
83
84
  /** Human-readable display name for UI dropdowns. */
@@ -90,7 +91,7 @@ export interface LlmProvider {
90
91
  /**
91
92
  * Default model id returned by {@link LlmProvider.defaultModels}[0]
92
93
  * when the caller does not specify one. Used by the routing layer when
93
- * `OPENCODE_MODEL` is not set.
94
+ * `OM_AI_MODEL` is not set.
94
95
  */
95
96
  readonly defaultModel: string
96
97
  /** Curated list of models shown in the UI dropdown for this provider. */
@@ -1,5 +1,5 @@
1
1
  import { z, type ZodTypeAny } from 'zod'
2
- import type { OpenApiRouteDoc } from './types'
2
+ import type { OpenApiResponseDoc, OpenApiRouteDoc } from './types'
3
3
 
4
4
  export const defaultCreateResponseSchema = z.object({ id: z.string().uuid().nullable() })
5
5
  export const defaultOkResponseSchema = z.object({ ok: z.literal(true) })
@@ -34,6 +34,7 @@ type CrudDeleteConfig = {
34
34
  schema?: ZodTypeAny
35
35
  description?: string
36
36
  responseSchema?: ZodTypeAny
37
+ errors?: OpenApiResponseDoc[]
37
38
  }
38
39
 
39
40
  export type CrudOpenApiOptions = {
@@ -217,6 +218,7 @@ export function createCrudOpenApiFactory(config: CrudOpenApiFactoryConfig) {
217
218
  schema: del.responseSchema ?? fallbackOkResponseSchema,
218
219
  },
219
220
  ],
221
+ ...(del.errors && del.errors.length > 0 ? { errors: del.errors } : {}),
220
222
  }
221
223
  }
222
224