import { init_dirname, init_buffer, init_process } from './chunk-WKNVAFKE.js';
import { z } from 'zod';

// src/well-known/collections.ts
init_dirname();
init_buffer();
init_process();
var BaseCollectionEntitySchema = z.object({
  id: z.string().describe("Unique identifier for the entity"),
  title: z.string().describe("Human-readable title for the entity"),
  created_at: z.string().datetime(),
  updated_at: z.string().datetime(),
  created_by: z.string().optional(),
  updated_by: z.string().optional()
});
var ComparisonExpressionSchema = z.object({
  field: z.array(z.string()),
  operator: z.enum(["eq", "gt", "gte", "lt", "lte", "in", "like", "contains"]),
  value: z.unknown()
});
var WhereExpressionSchema = z.union([
  ComparisonExpressionSchema,
  z.object({
    operator: z.enum(["and", "or", "not"]),
    conditions: z.array(ComparisonExpressionSchema)
  })
]);
var OrderByExpressionSchema = z.object({
  field: z.array(z.string()),
  direction: z.enum(["asc", "desc"]),
  nulls: z.enum(["first", "last"]).optional()
});
var CollectionListInputSchema = z.object({
  where: WhereExpressionSchema.optional().describe("Filter expression"),
  orderBy: z.array(OrderByExpressionSchema).optional().describe("Sort expressions"),
  limit: z.number().int().min(1).max(1e3).optional().describe("Maximum number of items to return"),
  offset: z.number().int().min(0).optional().describe("Number of items to skip")
});
function createCollectionListOutputSchema(entitySchema) {
  return z.object({
    items: z.array(entitySchema).describe("Array of collection items"),
    totalCount: z.number().int().min(0).optional().describe("Total number of matching items (if available)"),
    hasMore: z.boolean().optional().describe("Whether there are more items available")
  });
}
var CollectionGetInputSchema = z.object({
  id: z.string().describe("ID of the entity to retrieve")
});
function createCollectionGetOutputSchema(entitySchema) {
  return z.object({
    item: entitySchema.nullable().describe("The retrieved item, or null if not found")
  });
}
function createCollectionInsertInputSchema(entitySchema) {
  return z.object({
    data: entitySchema.describe(
      "Data for the new entity (id may be auto-generated)"
    )
  });
}
function createCollectionInsertOutputSchema(entitySchema) {
  return z.object({
    item: entitySchema.describe("The created entity with generated id")
  });
}
function createCollectionUpdateInputSchema(entitySchema) {
  return z.object({
    id: z.string().describe("ID of the entity to update"),
    data: entitySchema.partial().describe("Partial entity data to update")
  });
}
function createCollectionUpdateOutputSchema(entitySchema) {
  return z.object({
    item: entitySchema.describe("The updated entity")
  });
}
var CollectionDeleteInputSchema = z.object({
  id: z.string().describe("ID of the entity to delete")
});
function createCollectionDeleteOutputSchema(entitySchema) {
  return z.object({
    item: entitySchema.describe("The deleted entity")
  });
}
function createCollectionBindings(collectionName, entitySchema, options) {
  const upperName = collectionName.toUpperCase();
  const readOnly = options?.readOnly ?? false;
  const bindings = [
    {
      name: `COLLECTION_${upperName}_LIST`,
      inputSchema: CollectionListInputSchema,
      outputSchema: createCollectionListOutputSchema(entitySchema)
    },
    {
      name: `COLLECTION_${upperName}_GET`,
      inputSchema: CollectionGetInputSchema,
      outputSchema: createCollectionGetOutputSchema(entitySchema)
    }
  ];
  if (!readOnly) {
    bindings.push(
      {
        name: `COLLECTION_${upperName}_CREATE`,
        inputSchema: createCollectionInsertInputSchema(entitySchema),
        outputSchema: createCollectionInsertOutputSchema(entitySchema),
        opt: true
      },
      {
        name: `COLLECTION_${upperName}_UPDATE`,
        inputSchema: createCollectionUpdateInputSchema(entitySchema),
        outputSchema: createCollectionUpdateOutputSchema(entitySchema),
        opt: true
      },
      {
        name: `COLLECTION_${upperName}_DELETE`,
        inputSchema: CollectionDeleteInputSchema,
        outputSchema: createCollectionDeleteOutputSchema(entitySchema),
        opt: true
      }
    );
  }
  return bindings;
}

export { BaseCollectionEntitySchema, CollectionDeleteInputSchema, CollectionGetInputSchema, CollectionListInputSchema, OrderByExpressionSchema, WhereExpressionSchema, createCollectionBindings, createCollectionDeleteOutputSchema, createCollectionGetOutputSchema, createCollectionInsertInputSchema, createCollectionInsertOutputSchema, createCollectionListOutputSchema, createCollectionUpdateInputSchema, createCollectionUpdateOutputSchema };
//# sourceMappingURL=chunk-XWLBKKHZ.js.map
//# sourceMappingURL=chunk-XWLBKKHZ.js.map