@jaypie/dynamodb 0.4.4 → 0.5.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../../../src/client.ts","../../../../../src/constants.ts","../../../../../src/keyBuilders.ts","../../../../../src/entities.ts","../../../../../src/queries.ts","../../../../../src/mcp/admin/createTable.ts","../../../../../src/mcp/admin/dockerCompose.ts","../../../../../src/mcp/autoInit.ts","../../../../../src/mcp/admin/status.ts","../../../../../src/mcp/index.ts"],"sourcesContent":["import { DynamoDBClient } from \"@aws-sdk/client-dynamodb\";\nimport { DynamoDBDocumentClient } from \"@aws-sdk/lib-dynamodb\";\nimport { ConfigurationError } from \"@jaypie/errors\";\n\nimport type { DynamoClientConfig } from \"./types.js\";\n\n// Environment variable names\nconst ENV_AWS_REGION = \"AWS_REGION\";\nconst ENV_DYNAMODB_TABLE_NAME = \"DYNAMODB_TABLE_NAME\";\n\n// Defaults\nconst DEFAULT_REGION = \"us-east-1\";\nconst LOCAL_CREDENTIALS = {\n accessKeyId: \"local\",\n secretAccessKey: \"local\",\n};\n\n// Module-level state\nlet docClient: DynamoDBDocumentClient | null = null;\nlet tableName: string | null = null;\n\n/**\n * Check if endpoint indicates local development mode\n */\nfunction isLocalEndpoint(endpoint?: string): boolean {\n if (!endpoint) return false;\n return endpoint.includes(\"127.0.0.1\") || endpoint.includes(\"localhost\");\n}\n\n/**\n * Initialize the DynamoDB client\n * Must be called once at application startup before using query functions\n *\n * @param config - Client configuration\n */\nexport function initClient(config: DynamoClientConfig = {}): void {\n const { endpoint } = config;\n const region = config.region ?? process.env[ENV_AWS_REGION] ?? DEFAULT_REGION;\n\n // Auto-detect local mode and use dummy credentials\n const credentials =\n config.credentials ??\n (isLocalEndpoint(endpoint) ? LOCAL_CREDENTIALS : undefined);\n\n const dynamoClient = new DynamoDBClient({\n ...(credentials && { credentials }),\n ...(endpoint && { endpoint }),\n region,\n });\n\n docClient = DynamoDBDocumentClient.from(dynamoClient, {\n marshallOptions: {\n removeUndefinedValues: true,\n },\n });\n\n tableName = config.tableName ?? process.env[ENV_DYNAMODB_TABLE_NAME] ?? null;\n}\n\n/**\n * Get the initialized DynamoDB Document Client\n * @throws ConfigurationError if client has not been initialized\n */\nexport function getDocClient(): DynamoDBDocumentClient {\n if (!docClient) {\n throw new ConfigurationError(\n \"DynamoDB client not initialized. Call initClient() first.\",\n );\n }\n return docClient;\n}\n\n/**\n * Get the configured table name\n * @throws ConfigurationError if client has not been initialized\n */\nexport function getTableName(): string {\n if (!tableName) {\n throw new ConfigurationError(\n \"DynamoDB client not initialized. Call initClient() first.\",\n );\n }\n return tableName;\n}\n\n/**\n * Check if the client has been initialized\n */\nexport function isInitialized(): boolean {\n return docClient !== null && tableName !== null;\n}\n\n/**\n * Reset the client state (primarily for testing)\n */\nexport function resetClient(): void {\n docClient = null;\n tableName = null;\n}\n","// Re-export shared constants from fabric\nexport {\n APEX,\n ARCHIVED_SUFFIX,\n DELETED_SUFFIX,\n SEPARATOR,\n} from \"@jaypie/fabric\";\n\n// GSI names\nexport const INDEX_ALIAS = \"indexAlias\";\nexport const INDEX_CATEGORY = \"indexCategory\";\nexport const INDEX_SCOPE = \"indexScope\";\nexport const INDEX_TYPE = \"indexType\";\nexport const INDEX_XID = \"indexXid\";\n","import {\n buildCompositeKey as fabricBuildCompositeKey,\n calculateScope as fabricCalculateScope,\n getModelIndexes,\n type IndexableModel,\n populateIndexKeys as fabricPopulateIndexKeys,\n} from \"@jaypie/fabric\";\n\nimport { APEX, SEPARATOR } from \"./constants.js\";\nimport type { ParentReference, StorableEntity } from \"./types.js\";\n\n// =============================================================================\n// Key Builders\n// =============================================================================\n\n/**\n * Build the indexScope key for hierarchical queries\n * @param scope - The scope (APEX or \"{parent.model}#{parent.id}\")\n * @param model - The entity model name\n * @returns Composite key: \"{scope}#{model}\"\n */\nexport function buildIndexScope(scope: string, model: string): string {\n return `${scope}${SEPARATOR}${model}`;\n}\n\n/**\n * Build the indexAlias key for human-friendly lookups\n * @param scope - The scope\n * @param model - The entity model name\n * @param alias - The human-friendly alias\n * @returns Composite key: \"{scope}#{model}#{alias}\"\n */\nexport function buildIndexAlias(\n scope: string,\n model: string,\n alias: string,\n): string {\n return `${scope}${SEPARATOR}${model}${SEPARATOR}${alias}`;\n}\n\n/**\n * Build the indexCategory key for category filtering\n * @param scope - The scope\n * @param model - The entity model name\n * @param category - The category classification\n * @returns Composite key: \"{scope}#{model}#{category}\"\n */\nexport function buildIndexCategory(\n scope: string,\n model: string,\n category: string,\n): string {\n return `${scope}${SEPARATOR}${model}${SEPARATOR}${category}`;\n}\n\n/**\n * Build the indexType key for type filtering\n * @param scope - The scope\n * @param model - The entity model name\n * @param type - The type classification\n * @returns Composite key: \"{scope}#{model}#{type}\"\n */\nexport function buildIndexType(\n scope: string,\n model: string,\n type: string,\n): string {\n return `${scope}${SEPARATOR}${model}${SEPARATOR}${type}`;\n}\n\n/**\n * Build the indexXid key for external ID lookups\n * @param scope - The scope\n * @param model - The entity model name\n * @param xid - The external ID\n * @returns Composite key: \"{scope}#{model}#{xid}\"\n */\nexport function buildIndexXid(\n scope: string,\n model: string,\n xid: string,\n): string {\n return `${scope}${SEPARATOR}${model}${SEPARATOR}${xid}`;\n}\n\n// =============================================================================\n// New Vocabulary-Based Functions\n// =============================================================================\n\n/**\n * Build a composite key from entity fields\n *\n * @param entity - Entity with fields to extract\n * @param fields - Field names to combine with SEPARATOR\n * @param suffix - Optional suffix to append (e.g., \"#deleted\")\n * @returns Composite key string\n */\nexport function buildCompositeKey(\n entity: IndexableModel,\n fields: string[],\n suffix?: string,\n): string {\n return fabricBuildCompositeKey(entity, fields, suffix);\n}\n\n/**\n * Calculate the scope from a parent reference\n * @param parent - Optional parent entity reference\n * @returns APEX (\"@\") if no parent, otherwise \"{parent.model}#{parent.id}\"\n */\nexport function calculateScope(parent?: ParentReference): string {\n if (!parent) {\n return APEX;\n }\n return fabricCalculateScope(parent);\n}\n\n/**\n * Auto-populate GSI index keys on an entity\n *\n * Uses the model's registered indexes (from the fabric registry).\n *\n * - indexScope is always populated from scope + model\n * - indexAlias is populated only when alias is present\n * - indexCategory is populated only when category is present\n * - indexType is populated only when type is present\n * - indexXid is populated only when xid is present\n *\n * @param entity - The entity to populate index keys for\n * @param suffix - Optional suffix to append to all index keys (e.g., \"#deleted\", \"#archived\")\n * @returns The entity with populated index keys\n */\nexport function indexEntity<T extends StorableEntity>(\n entity: T,\n suffix: string = \"\",\n): T {\n const indexes = getModelIndexes(entity.model);\n // Cast through unknown to bridge the type gap between StorableEntity and IndexableModel\n return fabricPopulateIndexKeys(\n entity as unknown as IndexableModel,\n indexes,\n suffix,\n ) as unknown as T;\n}\n","import {\n DeleteCommand,\n GetCommand,\n PutCommand,\n TransactWriteCommand,\n} from \"@aws-sdk/lib-dynamodb\";\nimport { fabricService } from \"@jaypie/fabric\";\n\nimport { getDocClient, getTableName } from \"./client.js\";\nimport { ARCHIVED_SUFFIX, DELETED_SUFFIX } from \"./constants.js\";\nimport { indexEntity } from \"./keyBuilders.js\";\nimport type { StorableEntity } from \"./types.js\";\n\n/**\n * Calculate suffix based on entity's archived/deleted state\n */\nfunction calculateEntitySuffix(entity: {\n archivedAt?: string;\n deletedAt?: string;\n}): string {\n const hasArchived = Boolean(entity.archivedAt);\n const hasDeleted = Boolean(entity.deletedAt);\n\n if (hasArchived && hasDeleted) {\n return ARCHIVED_SUFFIX + DELETED_SUFFIX;\n }\n if (hasArchived) {\n return ARCHIVED_SUFFIX;\n }\n if (hasDeleted) {\n return DELETED_SUFFIX;\n }\n return \"\";\n}\n\n/**\n * Get a single entity by primary key\n */\nexport const getEntity = fabricService({\n alias: \"getEntity\",\n description: \"Get a single entity by primary key\",\n input: {\n id: { type: String, description: \"Entity ID (sort key)\" },\n model: { type: String, description: \"Entity model (partition key)\" },\n },\n service: async ({ id, model }): Promise<StorableEntity | null> => {\n const docClient = getDocClient();\n const tableName = getTableName();\n\n const command = new GetCommand({\n Key: { id, model },\n TableName: tableName,\n });\n\n const response = await docClient.send(command);\n return (response.Item as StorableEntity) ?? null;\n },\n});\n\n/**\n * Put (create or replace) an entity\n * Auto-populates GSI index keys via indexEntity\n *\n * Note: This is a regular async function (not fabricService) because it accepts\n * complex StorableEntity objects that can't be coerced by vocabulary's type system.\n */\nexport async function putEntity({\n entity,\n}: {\n entity: StorableEntity;\n}): Promise<StorableEntity> {\n const docClient = getDocClient();\n const tableName = getTableName();\n\n // Auto-populate index keys\n const indexedEntity = indexEntity(entity);\n\n const command = new PutCommand({\n Item: indexedEntity,\n TableName: tableName,\n });\n\n await docClient.send(command);\n return indexedEntity;\n}\n\n/**\n * Update an existing entity\n * Auto-populates GSI index keys and sets updatedAt\n *\n * Note: This is a regular async function (not fabricService) because it accepts\n * complex StorableEntity objects that can't be coerced by vocabulary's type system.\n */\nexport async function updateEntity({\n entity,\n}: {\n entity: StorableEntity;\n}): Promise<StorableEntity> {\n const docClient = getDocClient();\n const tableName = getTableName();\n\n // Update timestamp and re-index\n const updatedEntity = indexEntity({\n ...entity,\n updatedAt: new Date().toISOString(),\n });\n\n const command = new PutCommand({\n Item: updatedEntity,\n TableName: tableName,\n });\n\n await docClient.send(command);\n return updatedEntity;\n}\n\n/**\n * Soft delete an entity by setting deletedAt timestamp\n * Re-indexes with appropriate suffix based on archived/deleted state\n */\nexport const deleteEntity = fabricService({\n alias: \"deleteEntity\",\n description: \"Soft delete an entity (sets deletedAt timestamp)\",\n input: {\n id: { type: String, description: \"Entity ID (sort key)\" },\n model: { type: String, description: \"Entity model (partition key)\" },\n },\n service: async ({ id, model }): Promise<boolean> => {\n const docClient = getDocClient();\n const tableName = getTableName();\n\n // Fetch the current entity\n const existing = await getEntity({ id, model });\n if (!existing) {\n return false;\n }\n\n const now = new Date().toISOString();\n\n // Build updated entity with deletedAt\n const updatedEntity = {\n ...existing,\n deletedAt: now,\n updatedAt: now,\n };\n\n // Calculate suffix based on combined state (may already be archived)\n const suffix = calculateEntitySuffix(updatedEntity);\n const deletedEntity = indexEntity(updatedEntity, suffix);\n\n const command = new PutCommand({\n Item: deletedEntity,\n TableName: tableName,\n });\n\n await docClient.send(command);\n return true;\n },\n});\n\n/**\n * Archive an entity by setting archivedAt timestamp\n * Re-indexes with appropriate suffix based on archived/deleted state\n */\nexport const archiveEntity = fabricService({\n alias: \"archiveEntity\",\n description: \"Archive an entity (sets archivedAt timestamp)\",\n input: {\n id: { type: String, description: \"Entity ID (sort key)\" },\n model: { type: String, description: \"Entity model (partition key)\" },\n },\n service: async ({ id, model }): Promise<boolean> => {\n const docClient = getDocClient();\n const tableName = getTableName();\n\n // Fetch the current entity\n const existing = await getEntity({ id, model });\n if (!existing) {\n return false;\n }\n\n const now = new Date().toISOString();\n\n // Build updated entity with archivedAt\n const updatedEntity = {\n ...existing,\n archivedAt: now,\n updatedAt: now,\n };\n\n // Calculate suffix based on combined state (may already be deleted)\n const suffix = calculateEntitySuffix(updatedEntity);\n const archivedEntity = indexEntity(updatedEntity, suffix);\n\n const command = new PutCommand({\n Item: archivedEntity,\n TableName: tableName,\n });\n\n await docClient.send(command);\n return true;\n },\n});\n\n/**\n * Hard delete an entity (permanently removes from table)\n * Use with caution - prefer deleteEntity for soft delete\n */\nexport const destroyEntity = fabricService({\n alias: \"destroyEntity\",\n description: \"Hard delete an entity (permanently removes from table)\",\n input: {\n id: { type: String, description: \"Entity ID (sort key)\" },\n model: { type: String, description: \"Entity model (partition key)\" },\n },\n service: async ({ id, model }): Promise<boolean> => {\n const docClient = getDocClient();\n const tableName = getTableName();\n\n const command = new DeleteCommand({\n Key: { id, model },\n TableName: tableName,\n });\n\n await docClient.send(command);\n return true;\n },\n});\n\n/**\n * Write multiple entities atomically using DynamoDB transactions.\n * Each entity is auto-indexed via indexEntity before writing.\n * All entities are written to the same table in a single transaction.\n */\nexport async function transactWriteEntities({\n entities,\n}: {\n entities: StorableEntity[];\n}): Promise<void> {\n const docClient = getDocClient();\n const tableName = getTableName();\n\n const command = new TransactWriteCommand({\n TransactItems: entities.map((entity) => ({\n Put: {\n Item: indexEntity(entity),\n TableName: tableName,\n },\n })),\n });\n\n await docClient.send(command);\n}\n","import { QueryCommand } from \"@aws-sdk/lib-dynamodb\";\nimport { fabricService } from \"@jaypie/fabric\";\n\nimport { getDocClient, getTableName } from \"./client.js\";\nimport {\n ARCHIVED_SUFFIX,\n DELETED_SUFFIX,\n INDEX_ALIAS,\n INDEX_CATEGORY,\n INDEX_SCOPE,\n INDEX_TYPE,\n INDEX_XID,\n} from \"./constants.js\";\nimport {\n buildIndexAlias,\n buildIndexCategory,\n buildIndexScope,\n buildIndexType,\n buildIndexXid,\n} from \"./keyBuilders.js\";\nimport type { BaseQueryOptions, StorableEntity, QueryResult } from \"./types.js\";\n\n/**\n * Calculate the suffix based on archived/deleted flags\n * When both are true, returns combined suffix (archived first, alphabetically)\n */\nfunction calculateSuffix({\n archived,\n deleted,\n}: {\n archived?: boolean;\n deleted?: boolean;\n}): string {\n if (archived && deleted) {\n return ARCHIVED_SUFFIX + DELETED_SUFFIX;\n }\n if (archived) {\n return ARCHIVED_SUFFIX;\n }\n if (deleted) {\n return DELETED_SUFFIX;\n }\n return \"\";\n}\n\n/**\n * Execute a GSI query with common options\n */\nasync function executeQuery<T extends StorableEntity>(\n indexName: string,\n keyValue: string,\n options: BaseQueryOptions = {},\n): Promise<QueryResult<T>> {\n const { ascending = false, limit, startKey } = options;\n\n const docClient = getDocClient();\n const tableName = getTableName();\n\n const command = new QueryCommand({\n ExclusiveStartKey: startKey as Record<string, unknown> | undefined,\n ExpressionAttributeNames: {\n \"#pk\": indexName,\n },\n ExpressionAttributeValues: {\n \":pkValue\": keyValue,\n },\n IndexName: indexName,\n KeyConditionExpression: \"#pk = :pkValue\",\n ...(limit && { Limit: limit }),\n ScanIndexForward: ascending,\n TableName: tableName,\n });\n\n const response = await docClient.send(command);\n\n return {\n items: (response.Items ?? []) as T[],\n lastEvaluatedKey: response.LastEvaluatedKey,\n };\n}\n\n/**\n * Query parameters for queryByScope\n */\ninterface QueryByScopeParams extends BaseQueryOptions {\n model: string;\n scope: string;\n}\n\n/**\n * Query entities by scope (parent hierarchy)\n * Uses indexScope GSI\n *\n * Note: This is a regular async function (not fabricService) because it accepts\n * complex startKey objects that can't be coerced by vocabulary's type system.\n */\nexport async function queryByScope({\n archived = false,\n ascending = false,\n deleted = false,\n limit,\n model,\n scope,\n startKey,\n}: QueryByScopeParams): Promise<QueryResult<StorableEntity>> {\n const suffix = calculateSuffix({ archived, deleted });\n const keyValue = buildIndexScope(scope, model) + suffix;\n return executeQuery<StorableEntity>(INDEX_SCOPE, keyValue, {\n ascending,\n limit,\n startKey,\n });\n}\n\n/**\n * Query a single entity by human-friendly alias\n * Uses indexAlias GSI\n */\nexport const queryByAlias = fabricService({\n alias: \"queryByAlias\",\n description: \"Query a single entity by human-friendly alias\",\n input: {\n alias: { type: String, description: \"Human-friendly alias\" },\n archived: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Query archived entities instead of active ones\",\n },\n deleted: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Query deleted entities instead of active ones\",\n },\n model: { type: String, description: \"Entity model name\" },\n scope: { type: String, description: \"Scope (@ for root)\" },\n },\n service: async ({\n alias,\n archived,\n deleted,\n model,\n scope,\n }): Promise<StorableEntity | null> => {\n const aliasStr = alias as string;\n const archivedBool = archived as boolean | undefined;\n const deletedBool = deleted as boolean | undefined;\n const modelStr = model as string;\n const scopeStr = scope as string;\n\n const suffix = calculateSuffix({\n archived: archivedBool,\n deleted: deletedBool,\n });\n const keyValue = buildIndexAlias(scopeStr, modelStr, aliasStr) + suffix;\n const result = await executeQuery<StorableEntity>(INDEX_ALIAS, keyValue, {\n limit: 1,\n });\n return result.items[0] ?? null;\n },\n});\n\n/**\n * Query parameters for queryByCategory\n */\ninterface QueryByCategoryParams extends BaseQueryOptions {\n category: string;\n model: string;\n scope: string;\n}\n\n/**\n * Query entities by category classification\n * Uses indexCategory GSI\n *\n * Note: This is a regular async function (not fabricService) because it accepts\n * complex startKey objects that can't be coerced by vocabulary's type system.\n */\nexport async function queryByCategory({\n archived = false,\n ascending = false,\n category,\n deleted = false,\n limit,\n model,\n scope,\n startKey,\n}: QueryByCategoryParams): Promise<QueryResult<StorableEntity>> {\n const suffix = calculateSuffix({ archived, deleted });\n const keyValue = buildIndexCategory(scope, model, category) + suffix;\n return executeQuery<StorableEntity>(INDEX_CATEGORY, keyValue, {\n ascending,\n limit,\n startKey,\n });\n}\n\n/**\n * Query parameters for queryByType\n */\ninterface QueryByTypeParams extends BaseQueryOptions {\n model: string;\n scope: string;\n type: string;\n}\n\n/**\n * Query entities by type classification\n * Uses indexType GSI\n *\n * Note: This is a regular async function (not fabricService) because it accepts\n * complex startKey objects that can't be coerced by vocabulary's type system.\n */\nexport async function queryByType({\n archived = false,\n ascending = false,\n deleted = false,\n limit,\n model,\n scope,\n startKey,\n type,\n}: QueryByTypeParams): Promise<QueryResult<StorableEntity>> {\n const suffix = calculateSuffix({ archived, deleted });\n const keyValue = buildIndexType(scope, model, type) + suffix;\n return executeQuery<StorableEntity>(INDEX_TYPE, keyValue, {\n ascending,\n limit,\n startKey,\n });\n}\n\n/**\n * Query a single entity by external ID\n * Uses indexXid GSI\n */\nexport const queryByXid = fabricService({\n alias: \"queryByXid\",\n description: \"Query a single entity by external ID\",\n input: {\n archived: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Query archived entities instead of active ones\",\n },\n deleted: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Query deleted entities instead of active ones\",\n },\n model: { type: String, description: \"Entity model name\" },\n scope: { type: String, description: \"Scope (@ for root)\" },\n xid: { type: String, description: \"External ID\" },\n },\n service: async ({\n archived,\n deleted,\n model,\n scope,\n xid,\n }): Promise<StorableEntity | null> => {\n const archivedBool = archived as boolean | undefined;\n const deletedBool = deleted as boolean | undefined;\n const modelStr = model as string;\n const scopeStr = scope as string;\n const xidStr = xid as string;\n\n const suffix = calculateSuffix({\n archived: archivedBool,\n deleted: deletedBool,\n });\n const keyValue = buildIndexXid(scopeStr, modelStr, xidStr) + suffix;\n const result = await executeQuery<StorableEntity>(INDEX_XID, keyValue, {\n limit: 1,\n });\n return result.items[0] ?? null;\n },\n});\n","import {\n CreateTableCommand,\n DescribeTableCommand,\n DynamoDBClient,\n} from \"@aws-sdk/client-dynamodb\";\nimport {\n fabricService,\n getAllRegisteredIndexes,\n type IndexDefinition,\n} from \"@jaypie/fabric\";\n\nconst DEFAULT_ENDPOINT = \"http://127.0.0.1:8000\";\nconst DEFAULT_REGION = \"us-east-1\";\nconst DEFAULT_TABLE_NAME = \"jaypie-local\";\n\n// =============================================================================\n// Index to GSI Conversion\n// =============================================================================\n\n/**\n * Generate an index name from pk fields (if not provided)\n */\nfunction generateIndexName(pk: string[]): string {\n const suffix = pk\n .map((field) => field.charAt(0).toUpperCase() + field.slice(1))\n .join(\"\");\n return `index${suffix}`;\n}\n\n/**\n * Collect all unique indexes from registered models\n */\nfunction collectAllIndexes(): IndexDefinition[] {\n const indexMap = new Map<string, IndexDefinition>();\n\n for (const index of getAllRegisteredIndexes()) {\n const name = index.name ?? generateIndexName(index.pk as string[]);\n if (!indexMap.has(name)) {\n indexMap.set(name, { ...index, name });\n }\n }\n\n return Array.from(indexMap.values());\n}\n\n/**\n * Build attribute definitions from indexes\n */\nfunction buildAttributeDefinitions(\n indexes: IndexDefinition[],\n): Array<{ AttributeName: string; AttributeType: \"S\" | \"N\" }> {\n const attrs = new Map<string, \"S\" | \"N\">();\n\n // Primary key attributes\n attrs.set(\"model\", \"S\");\n attrs.set(\"id\", \"S\");\n attrs.set(\"sequence\", \"N\");\n\n // GSI attributes (partition keys are always strings)\n for (const index of indexes) {\n const indexName = index.name ?? generateIndexName(index.pk as string[]);\n attrs.set(indexName, \"S\");\n }\n\n // Sort keys (sequence is always a number, others would be strings)\n // Note: Currently all indexes use sequence as SK, so this is mostly future-proofing\n for (const index of indexes) {\n const sk = index.sk ?? [\"sequence\"];\n for (const skField of sk) {\n if (!attrs.has(skField as string)) {\n // Assume string unless it's sequence\n attrs.set(skField as string, skField === \"sequence\" ? \"N\" : \"S\");\n }\n }\n }\n\n return Array.from(attrs.entries())\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([name, type]) => ({\n AttributeName: name,\n AttributeType: type,\n }));\n}\n\n/**\n * Build GSI definitions from indexes\n */\nfunction buildGSIs(indexes: IndexDefinition[]): Array<{\n IndexName: string;\n KeySchema: Array<{ AttributeName: string; KeyType: \"HASH\" | \"RANGE\" }>;\n Projection: { ProjectionType: \"ALL\" };\n}> {\n const gsiProjection = { ProjectionType: \"ALL\" as const };\n\n return indexes.map((index) => {\n const indexName = index.name ?? generateIndexName(index.pk as string[]);\n const sk = index.sk ?? [\"sequence\"];\n\n // For GSIs, the partition key attribute name IS the index name\n // (e.g., indexOu stores the composite key value \"@#record\")\n return {\n IndexName: indexName,\n KeySchema: [\n { AttributeName: indexName, KeyType: \"HASH\" as const },\n // Use first SK field as the range key attribute\n { AttributeName: sk[0] as string, KeyType: \"RANGE\" as const },\n ],\n Projection: gsiProjection,\n };\n });\n}\n\n// =============================================================================\n// Table Creation\n// =============================================================================\n\n/**\n * DynamoDB table schema with Jaypie GSI pattern\n *\n * Collects indexes from models registered via registerModel()\n */\nfunction createTableParams(\n tableName: string,\n billingMode: \"PAY_PER_REQUEST\" | \"PROVISIONED\",\n) {\n const allIndexes = collectAllIndexes();\n\n return {\n AttributeDefinitions: buildAttributeDefinitions(allIndexes),\n BillingMode: billingMode,\n GlobalSecondaryIndexes: buildGSIs(allIndexes),\n KeySchema: [\n { AttributeName: \"model\", KeyType: \"HASH\" as const },\n { AttributeName: \"id\", KeyType: \"RANGE\" as const },\n ],\n TableName: tableName,\n };\n}\n\n/**\n * Create DynamoDB table with Jaypie GSI schema\n */\nexport const createTableHandler = fabricService({\n alias: \"dynamodb_create_table\",\n description: \"Create DynamoDB table with Jaypie GSI schema\",\n input: {\n billingMode: {\n type: [\"PAY_PER_REQUEST\", \"PROVISIONED\"] as const,\n default: \"PAY_PER_REQUEST\",\n description: \"DynamoDB billing mode\",\n },\n endpoint: {\n type: String,\n default: DEFAULT_ENDPOINT,\n description: \"DynamoDB endpoint URL\",\n },\n tableName: {\n type: String,\n default: DEFAULT_TABLE_NAME,\n description: \"Table name to create\",\n },\n },\n service: async ({ billingMode, endpoint, tableName }) => {\n const endpointStr = endpoint as string;\n const tableNameStr = tableName as string;\n const billingModeStr = billingMode as \"PAY_PER_REQUEST\" | \"PROVISIONED\";\n\n const client = new DynamoDBClient({\n credentials: {\n accessKeyId: \"local\",\n secretAccessKey: \"local\",\n },\n endpoint: endpointStr,\n region: DEFAULT_REGION,\n });\n\n try {\n // Check if table already exists\n await client.send(new DescribeTableCommand({ TableName: tableNameStr }));\n return {\n message: `Table \"${tableNameStr}\" already exists`,\n success: false,\n tableName: tableNameStr,\n };\n } catch (error) {\n if ((error as { name?: string }).name !== \"ResourceNotFoundException\") {\n throw error;\n }\n }\n\n // Create the table\n const tableParams = createTableParams(tableNameStr, billingModeStr);\n await client.send(new CreateTableCommand(tableParams));\n\n return {\n message: \"Table created successfully\",\n success: true,\n tableName: tableNameStr,\n };\n },\n});\n","import { fabricService } from \"@jaypie/fabric\";\n\nconst DEFAULT_ADMIN_PORT = 8001;\nconst DEFAULT_DYNAMODB_PORT = 8000;\nconst DEFAULT_PROJECT_NAME = \"jaypie\";\nconst DEFAULT_TABLE_NAME = \"jaypie-local\";\n\n/**\n * Generate docker-compose.yml for local DynamoDB development\n */\nexport const dockerComposeHandler = fabricService({\n alias: \"dynamodb_generate_docker_compose\",\n description: \"Generate docker-compose.yml for local DynamoDB development\",\n input: {\n adminPort: {\n type: Number,\n default: DEFAULT_ADMIN_PORT,\n description: \"Port for DynamoDB Admin UI\",\n },\n dynamodbPort: {\n type: Number,\n default: DEFAULT_DYNAMODB_PORT,\n description: \"Port for DynamoDB Local\",\n },\n projectName: {\n type: String,\n default: DEFAULT_PROJECT_NAME,\n description: \"Project name for container naming\",\n },\n tableName: {\n type: String,\n default: DEFAULT_TABLE_NAME,\n description: \"Default table name\",\n },\n },\n service: async ({ adminPort, dynamodbPort, projectName, tableName }) => {\n const dockerCompose = `name: ${projectName}-dynamodb-stack\n\nservices:\n dynamodb:\n image: amazon/dynamodb-local:latest\n container_name: ${projectName}-dynamodb\n command: \"-jar DynamoDBLocal.jar -sharedDb -dbPath /data\"\n ports:\n - \"${dynamodbPort}:8000\"\n working_dir: /home/dynamodblocal\n volumes:\n - dynamodb_data:/data\n user: \"0:0\"\n\n dynamodb-admin:\n image: aaronshaf/dynamodb-admin:latest\n container_name: ${projectName}-dynamodb-admin\n ports:\n - \"${adminPort}:8001\"\n environment:\n - DYNAMO_ENDPOINT=http://dynamodb:8000\n - AWS_REGION=us-east-1\n - AWS_ACCESS_KEY_ID=local\n - AWS_SECRET_ACCESS_KEY=local\n depends_on:\n - dynamodb\n\nvolumes:\n dynamodb_data:\n driver: local\n`;\n\n const envVars = {\n AWS_REGION: \"us-east-1\",\n DYNAMODB_ENDPOINT: `http://127.0.0.1:${dynamodbPort}`,\n DYNAMODB_TABLE_NAME: tableName,\n };\n\n const envFile = `# DynamoDB Local Configuration\nDYNAMODB_TABLE_NAME=${tableName}\nDYNAMODB_ENDPOINT=http://127.0.0.1:${dynamodbPort}\nAWS_REGION=us-east-1\n`;\n\n return {\n dockerCompose,\n envFile,\n envVars,\n };\n },\n});\n","import { ConfigurationError } from \"@jaypie/errors\";\n\nimport { initClient, isInitialized } from \"../client.js\";\n\nconst DEFAULT_REGION = \"us-east-1\";\n\n/**\n * Ensure DynamoDB client is initialized from environment variables\n * Called automatically before each MCP tool execution\n */\nexport function ensureInitialized(): void {\n if (isInitialized()) {\n return;\n }\n\n const tableName = process.env.DYNAMODB_TABLE_NAME;\n if (!tableName) {\n throw new ConfigurationError(\n \"DYNAMODB_TABLE_NAME environment variable is required\",\n );\n }\n\n initClient({\n endpoint: process.env.DYNAMODB_ENDPOINT,\n region: process.env.AWS_REGION || DEFAULT_REGION,\n tableName,\n });\n}\n","import { fabricService } from \"@jaypie/fabric\";\n\nimport { getTableName, isInitialized } from \"../../client.js\";\nimport { ensureInitialized } from \"../autoInit.js\";\n\n/**\n * Check DynamoDB connection status and configuration\n */\nexport const statusHandler = fabricService({\n alias: \"dynamodb_status\",\n description: \"Check DynamoDB connection status and configuration\",\n service: async () => {\n ensureInitialized();\n return {\n endpoint: process.env.DYNAMODB_ENDPOINT || \"AWS Default\",\n initialized: isInitialized(),\n region: process.env.AWS_REGION || \"us-east-1\",\n tableName: getTableName(),\n };\n },\n});\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { fabricMcp } from \"@jaypie/fabric/mcp\";\nimport { fabricService, type Service } from \"@jaypie/fabric\";\n\nimport {\n archiveEntity,\n deleteEntity,\n destroyEntity,\n getEntity,\n putEntity,\n queryByAlias,\n queryByCategory,\n queryByScope,\n queryByType,\n queryByXid,\n updateEntity,\n} from \"../index.js\";\nimport type { StorableEntity } from \"../types.js\";\nimport {\n createTableHandler,\n dockerComposeHandler,\n statusHandler,\n} from \"./admin/index.js\";\nimport { ensureInitialized } from \"./autoInit.js\";\n\nexport interface RegisterDynamoDbToolsConfig {\n /** MCP server to register tools with */\n server: McpServer;\n /** Include admin tools (create_table, docker_compose, status). Default: true */\n includeAdmin?: boolean;\n}\n\nexport interface RegisterDynamoDbToolsResult {\n /** Names of registered tools */\n tools: string[];\n}\n\n/**\n * Wrap a handler to auto-initialize before execution\n * Uses explicit type assertion to allow any Service type to be wrapped\n */\n\nfunction wrapWithInit(handler: Service<any, any, any>): Service {\n const wrapped = async (input: Record<string, unknown>) => {\n ensureInitialized();\n return handler(input);\n };\n // Preserve handler properties for MCP registration\n Object.assign(wrapped, {\n alias: handler.alias,\n description: handler.description,\n input: handler.input,\n });\n return wrapped as Service;\n}\n\n// MCP-specific serviceHandler wrappers for functions with complex inputs\n// Note: These wrap the regular async functions to make them work with fabricMcp\n\n/**\n * MCP wrapper for putEntity\n * Accepts entity JSON directly from LLM\n */\nconst mcpPutEntity = fabricService({\n alias: \"dynamodb_put\",\n description:\n \"Create or replace an entity in DynamoDB (auto-indexes GSI keys)\",\n input: {\n // Required entity fields\n id: { type: String, description: \"Entity ID (sort key)\" },\n model: { type: String, description: \"Entity model name (partition key)\" },\n name: { type: String, description: \"Entity name\" },\n scope: { type: String, description: \"Scope (@ for root)\" },\n // Optional fields\n alias: {\n type: String,\n required: false,\n description: \"Human-friendly alias\",\n },\n category: {\n type: String,\n required: false,\n description: \"Category classification\",\n },\n type: { type: String, required: false, description: \"Type classification\" },\n xid: { type: String, required: false, description: \"External ID\" },\n },\n service: async (input) => {\n const now = new Date().toISOString();\n const entity: StorableEntity = {\n alias: input.alias as string | undefined,\n category: input.category as string | undefined,\n createdAt: now,\n id: input.id as string,\n model: input.model as string,\n name: input.name as string,\n scope: input.scope as string,\n sequence: Date.now(),\n type: input.type as string | undefined,\n updatedAt: now,\n xid: input.xid as string | undefined,\n };\n return putEntity({ entity });\n },\n});\n\n/**\n * MCP wrapper for updateEntity\n * Accepts entity JSON directly from LLM\n */\nconst mcpUpdateEntity = fabricService({\n alias: \"dynamodb_update\",\n description:\n \"Update an entity in DynamoDB (sets updatedAt, re-indexes GSI keys)\",\n input: {\n // Required fields to identify the entity\n id: { type: String, description: \"Entity ID (sort key)\" },\n model: { type: String, description: \"Entity model name (partition key)\" },\n // Fields that can be updated\n name: { type: String, required: false, description: \"Entity name\" },\n scope: { type: String, required: false, description: \"Scope\" },\n alias: {\n type: String,\n required: false,\n description: \"Human-friendly alias\",\n },\n category: {\n type: String,\n required: false,\n description: \"Category classification\",\n },\n type: { type: String, required: false, description: \"Type classification\" },\n xid: { type: String, required: false, description: \"External ID\" },\n },\n service: async (input) => {\n // First get the existing entity\n const existing = await getEntity({\n id: input.id as string,\n model: input.model as string,\n });\n if (!existing) {\n return { error: \"Entity not found\", id: input.id, model: input.model };\n }\n // Merge updates\n const entity: StorableEntity = {\n ...existing,\n ...(input.alias !== undefined && { alias: input.alias as string }),\n ...(input.category !== undefined && {\n category: input.category as string,\n }),\n ...(input.name !== undefined && { name: input.name as string }),\n ...(input.scope !== undefined && { scope: input.scope as string }),\n ...(input.type !== undefined && { type: input.type as string }),\n ...(input.xid !== undefined && { xid: input.xid as string }),\n };\n return updateEntity({ entity });\n },\n});\n\n/**\n * MCP wrapper for queryByScope\n * Note: Pagination via startKey is not exposed to MCP; use limit instead\n */\nconst mcpQueryByScope = fabricService({\n alias: \"dynamodb_query_scope\",\n description: \"Query entities by scope (parent hierarchy)\",\n input: {\n model: { type: String, description: \"Entity model name\" },\n scope: { type: String, description: \"Scope (@ for root)\" },\n archived: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Query archived entities instead of active ones\",\n },\n ascending: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Sort ascending (oldest first)\",\n },\n deleted: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Query deleted entities instead of active ones\",\n },\n limit: {\n type: Number,\n required: false,\n description: \"Maximum number of items to return\",\n },\n },\n service: async (input) => {\n return queryByScope({\n archived: input.archived as boolean,\n ascending: input.ascending as boolean,\n deleted: input.deleted as boolean,\n limit: input.limit as number | undefined,\n model: input.model as string,\n scope: input.scope as string,\n });\n },\n});\n\n/**\n * MCP wrapper for queryByCategory\n * Note: Pagination via startKey is not exposed to MCP; use limit instead\n */\nconst mcpQueryByCategory = fabricService({\n alias: \"dynamodb_query_category\",\n description: \"Query entities by category classification\",\n input: {\n category: { type: String, description: \"Category classification\" },\n model: { type: String, description: \"Entity model name\" },\n scope: { type: String, description: \"Scope (@ for root)\" },\n archived: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Query archived entities instead of active ones\",\n },\n ascending: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Sort ascending (oldest first)\",\n },\n deleted: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Query deleted entities instead of active ones\",\n },\n limit: {\n type: Number,\n required: false,\n description: \"Maximum number of items to return\",\n },\n },\n service: async (input) => {\n return queryByCategory({\n archived: input.archived as boolean,\n ascending: input.ascending as boolean,\n category: input.category as string,\n deleted: input.deleted as boolean,\n limit: input.limit as number | undefined,\n model: input.model as string,\n scope: input.scope as string,\n });\n },\n});\n\n/**\n * MCP wrapper for queryByType\n * Note: Pagination via startKey is not exposed to MCP; use limit instead\n */\nconst mcpQueryByType = fabricService({\n alias: \"dynamodb_query_type\",\n description: \"Query entities by type classification\",\n input: {\n model: { type: String, description: \"Entity model name\" },\n scope: { type: String, description: \"Scope (@ for root)\" },\n type: { type: String, description: \"Type classification\" },\n archived: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Query archived entities instead of active ones\",\n },\n ascending: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Sort ascending (oldest first)\",\n },\n deleted: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Query deleted entities instead of active ones\",\n },\n limit: {\n type: Number,\n required: false,\n description: \"Maximum number of items to return\",\n },\n },\n service: async (input) => {\n return queryByType({\n archived: input.archived as boolean,\n ascending: input.ascending as boolean,\n deleted: input.deleted as boolean,\n limit: input.limit as number | undefined,\n model: input.model as string,\n scope: input.scope as string,\n type: input.type as string,\n });\n },\n});\n\n/**\n * Register all DynamoDB MCP tools with a server\n */\nexport function registerDynamoDbTools(\n config: RegisterDynamoDbToolsConfig,\n): RegisterDynamoDbToolsResult {\n const { includeAdmin = true, server } = config;\n const tools: string[] = [];\n\n // Entity operations\n fabricMcp({\n service: wrapWithInit(getEntity),\n name: \"dynamodb_get\",\n server,\n });\n tools.push(\"dynamodb_get\");\n\n fabricMcp({\n service: wrapWithInit(mcpPutEntity),\n name: \"dynamodb_put\",\n server,\n });\n tools.push(\"dynamodb_put\");\n\n fabricMcp({\n service: wrapWithInit(mcpUpdateEntity),\n name: \"dynamodb_update\",\n server,\n });\n tools.push(\"dynamodb_update\");\n\n fabricMcp({\n service: wrapWithInit(deleteEntity),\n name: \"dynamodb_delete\",\n server,\n });\n tools.push(\"dynamodb_delete\");\n\n fabricMcp({\n service: wrapWithInit(archiveEntity),\n name: \"dynamodb_archive\",\n server,\n });\n tools.push(\"dynamodb_archive\");\n\n fabricMcp({\n service: wrapWithInit(destroyEntity),\n name: \"dynamodb_destroy\",\n server,\n });\n tools.push(\"dynamodb_destroy\");\n\n // Query operations\n fabricMcp({\n service: wrapWithInit(mcpQueryByScope),\n name: \"dynamodb_query_scope\",\n server,\n });\n tools.push(\"dynamodb_query_scope\");\n\n fabricMcp({\n service: wrapWithInit(queryByAlias),\n name: \"dynamodb_query_alias\",\n server,\n });\n tools.push(\"dynamodb_query_alias\");\n\n fabricMcp({\n service: wrapWithInit(mcpQueryByCategory),\n name: \"dynamodb_query_category\",\n server,\n });\n tools.push(\"dynamodb_query_category\");\n\n fabricMcp({\n service: wrapWithInit(mcpQueryByType),\n name: \"dynamodb_query_type\",\n server,\n });\n tools.push(\"dynamodb_query_type\");\n\n fabricMcp({\n service: wrapWithInit(queryByXid),\n name: \"dynamodb_query_xid\",\n server,\n });\n tools.push(\"dynamodb_query_xid\");\n\n // Admin tools (MCP-only)\n if (includeAdmin) {\n fabricMcp({ service: statusHandler, server });\n tools.push(\"dynamodb_status\");\n\n fabricMcp({ service: createTableHandler, server });\n tools.push(\"dynamodb_create_table\");\n\n fabricMcp({ service: dockerComposeHandler, server });\n tools.push(\"dynamodb_generate_docker_compose\");\n }\n\n return { tools };\n}\n\n// Export individual handlers for direct use\nexport {\n createTableHandler,\n dockerComposeHandler,\n statusHandler,\n} from \"./admin/index.js\";\n\nexport { ensureInitialized } from \"./autoInit.js\";\n"],"names":["DEFAULT_REGION","DynamoDBClient","DynamoDBDocumentClient","ConfigurationError","SEPARATOR","getModelIndexes","fabricPopulateIndexKeys","ARCHIVED_SUFFIX","DELETED_SUFFIX","fabricService","GetCommand","PutCommand","DeleteCommand","QueryCommand","DEFAULT_TABLE_NAME","getAllRegisteredIndexes","DescribeTableCommand","CreateTableCommand","fabricMcp"],"mappings":";;;;;;;;A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ChD;IAEA,OAAO,EAAE,KAAK,EAAE;AAClB;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../../../src/client.ts","../../../../../src/keyBuilders.ts","../../../../../src/entities.ts","../../../../../src/queries.ts","../../../../../src/mcp/admin/createTable.ts","../../../../../src/mcp/admin/dockerCompose.ts","../../../../../src/mcp/autoInit.ts","../../../../../src/mcp/admin/status.ts","../../../../../src/mcp/index.ts"],"sourcesContent":["import { DynamoDBClient } from \"@aws-sdk/client-dynamodb\";\nimport { DynamoDBDocumentClient } from \"@aws-sdk/lib-dynamodb\";\nimport { ConfigurationError } from \"@jaypie/errors\";\n\nimport type { DynamoClientConfig } from \"./types.js\";\n\n// Environment variable names\nconst ENV_AWS_REGION = \"AWS_REGION\";\nconst ENV_DYNAMODB_TABLE_NAME = \"DYNAMODB_TABLE_NAME\";\n\n// Defaults\nconst DEFAULT_REGION = \"us-east-1\";\nconst LOCAL_CREDENTIALS = {\n accessKeyId: \"local\",\n secretAccessKey: \"local\",\n};\n\n// Module-level state\nlet docClient: DynamoDBDocumentClient | null = null;\nlet tableName: string | null = null;\n\n/**\n * Check if endpoint indicates local development mode\n */\nfunction isLocalEndpoint(endpoint?: string): boolean {\n if (!endpoint) return false;\n return endpoint.includes(\"127.0.0.1\") || endpoint.includes(\"localhost\");\n}\n\n/**\n * Initialize the DynamoDB client\n * Must be called once at application startup before using query functions\n *\n * @param config - Client configuration\n */\nexport function initClient(config: DynamoClientConfig = {}): void {\n const { endpoint } = config;\n const region = config.region ?? process.env[ENV_AWS_REGION] ?? DEFAULT_REGION;\n\n // Auto-detect local mode and use dummy credentials\n const credentials =\n config.credentials ??\n (isLocalEndpoint(endpoint) ? LOCAL_CREDENTIALS : undefined);\n\n const dynamoClient = new DynamoDBClient({\n ...(credentials && { credentials }),\n ...(endpoint && { endpoint }),\n region,\n });\n\n docClient = DynamoDBDocumentClient.from(dynamoClient, {\n marshallOptions: {\n removeUndefinedValues: true,\n },\n });\n\n tableName = config.tableName ?? process.env[ENV_DYNAMODB_TABLE_NAME] ?? null;\n}\n\n/**\n * Get the initialized DynamoDB Document Client\n * @throws ConfigurationError if client has not been initialized\n */\nexport function getDocClient(): DynamoDBDocumentClient {\n if (!docClient) {\n throw new ConfigurationError(\n \"DynamoDB client not initialized. Call initClient() first.\",\n );\n }\n return docClient;\n}\n\n/**\n * Get the configured table name\n * @throws ConfigurationError if client has not been initialized\n */\nexport function getTableName(): string {\n if (!tableName) {\n throw new ConfigurationError(\n \"DynamoDB client not initialized. Call initClient() first.\",\n );\n }\n return tableName;\n}\n\n/**\n * Check if the client has been initialized\n */\nexport function isInitialized(): boolean {\n return docClient !== null && tableName !== null;\n}\n\n/**\n * Reset the client state (primarily for testing)\n */\nexport function resetClient(): void {\n docClient = null;\n tableName = null;\n}\n","import {\n buildCompositeKey as fabricBuildCompositeKey,\n calculateScope as fabricCalculateScope,\n getModelIndexes,\n type IndexableModel,\n populateIndexKeys as fabricPopulateIndexKeys,\n} from \"@jaypie/fabric\";\n\nimport { APEX } from \"./constants.js\";\nimport type { ParentReference, StorableEntity } from \"./types.js\";\n\n// =============================================================================\n// Key Builders\n// =============================================================================\n\n/**\n * Build a composite key from entity fields\n *\n * @param entity - Entity with fields to extract\n * @param fields - Field names to combine with SEPARATOR\n * @param suffix - Optional suffix to append (e.g., \"#deleted\")\n * @returns Composite key string\n */\nexport function buildCompositeKey(\n entity: IndexableModel,\n fields: string[],\n suffix?: string,\n): string {\n return fabricBuildCompositeKey(entity, fields, suffix);\n}\n\n/**\n * Calculate the scope from a parent reference\n * @param parent - Optional parent entity reference\n * @returns APEX (\"@\") if no parent, otherwise \"{parent.model}#{parent.id}\"\n */\nexport function calculateScope(parent?: ParentReference): string {\n if (!parent) {\n return APEX;\n }\n return fabricCalculateScope(parent);\n}\n\n/**\n * Auto-populate GSI index keys on an entity and advance its write timestamps.\n *\n * - Bumps `updatedAt` to now on every call.\n * - Backfills `createdAt` to the same now if not already set.\n * - Populates GSI attributes (pk composite and sk composite when applicable)\n * using the indexes registered for the entity's model.\n *\n * Callers (putEntity, updateEntity, deleteEntity, archiveEntity,\n * transactWriteEntities) go through this one function so `updatedAt` is\n * always fresh and never forgotten.\n *\n * @param entity - The entity to index\n * @param suffix - Optional suffix override (defaults to archived/deleted state)\n * @returns A new entity with timestamps bumped and index keys populated\n */\nexport function indexEntity<T extends StorableEntity>(\n entity: T,\n suffix?: string,\n): T {\n const now = new Date().toISOString();\n const bumped = {\n ...entity,\n createdAt: entity.createdAt ?? now,\n updatedAt: now,\n } as T;\n\n const indexes = getModelIndexes(entity.model);\n return fabricPopulateIndexKeys(\n bumped as unknown as IndexableModel,\n indexes,\n suffix,\n ) as unknown as T;\n}\n","import {\n DeleteCommand,\n GetCommand,\n PutCommand,\n TransactWriteCommand,\n} from \"@aws-sdk/lib-dynamodb\";\nimport { fabricService } from \"@jaypie/fabric\";\n\nimport { getDocClient, getTableName } from \"./client.js\";\nimport { ARCHIVED_SUFFIX, DELETED_SUFFIX } from \"./constants.js\";\nimport { indexEntity } from \"./keyBuilders.js\";\nimport type { StorableEntity } from \"./types.js\";\n\n/**\n * Calculate suffix based on entity's archived/deleted state\n */\nfunction calculateEntitySuffix(entity: {\n archivedAt?: string;\n deletedAt?: string;\n}): string {\n const hasArchived = Boolean(entity.archivedAt);\n const hasDeleted = Boolean(entity.deletedAt);\n\n if (hasArchived && hasDeleted) {\n return ARCHIVED_SUFFIX + DELETED_SUFFIX;\n }\n if (hasArchived) {\n return ARCHIVED_SUFFIX;\n }\n if (hasDeleted) {\n return DELETED_SUFFIX;\n }\n return \"\";\n}\n\n/**\n * Get a single entity by primary key (id)\n */\nexport const getEntity = fabricService({\n alias: \"getEntity\",\n description: \"Get a single entity by id\",\n input: {\n id: { type: String, description: \"Entity id (partition key)\" },\n },\n service: async ({ id }): Promise<StorableEntity | null> => {\n const docClient = getDocClient();\n const tableName = getTableName();\n\n const command = new GetCommand({\n Key: { id },\n TableName: tableName,\n });\n\n const response = await docClient.send(command);\n return (response.Item as StorableEntity) ?? null;\n },\n});\n\n/**\n * Put (create or replace) an entity.\n * `indexEntity` auto-bumps `updatedAt` and backfills `createdAt`.\n */\nexport async function putEntity({\n entity,\n}: {\n entity: StorableEntity;\n}): Promise<StorableEntity> {\n const docClient = getDocClient();\n const tableName = getTableName();\n\n const indexedEntity = indexEntity(entity);\n\n const command = new PutCommand({\n Item: indexedEntity,\n TableName: tableName,\n });\n\n await docClient.send(command);\n return indexedEntity;\n}\n\n/**\n * Update an existing entity.\n * `indexEntity` auto-bumps `updatedAt` — callers never set it manually.\n */\nexport async function updateEntity({\n entity,\n}: {\n entity: StorableEntity;\n}): Promise<StorableEntity> {\n const docClient = getDocClient();\n const tableName = getTableName();\n\n const updatedEntity = indexEntity(entity);\n\n const command = new PutCommand({\n Item: updatedEntity,\n TableName: tableName,\n });\n\n await docClient.send(command);\n return updatedEntity;\n}\n\n/**\n * Soft delete an entity by setting deletedAt timestamp\n * Re-indexes with appropriate suffix based on archived/deleted state\n */\nexport const deleteEntity = fabricService({\n alias: \"deleteEntity\",\n description: \"Soft delete an entity (sets deletedAt timestamp)\",\n input: {\n id: { type: String, description: \"Entity id\" },\n },\n service: async ({ id }): Promise<boolean> => {\n const docClient = getDocClient();\n const tableName = getTableName();\n\n const existing = await getEntity({ id });\n if (!existing) {\n return false;\n }\n\n const now = new Date().toISOString();\n\n // indexEntity will bump updatedAt again; set deletedAt here.\n const updatedEntity = {\n ...existing,\n deletedAt: now,\n };\n\n const suffix = calculateEntitySuffix(updatedEntity);\n const deletedEntity = indexEntity(updatedEntity, suffix);\n\n const command = new PutCommand({\n Item: deletedEntity,\n TableName: tableName,\n });\n\n await docClient.send(command);\n return true;\n },\n});\n\n/**\n * Archive an entity by setting archivedAt timestamp\n * Re-indexes with appropriate suffix based on archived/deleted state\n */\nexport const archiveEntity = fabricService({\n alias: \"archiveEntity\",\n description: \"Archive an entity (sets archivedAt timestamp)\",\n input: {\n id: { type: String, description: \"Entity id\" },\n },\n service: async ({ id }): Promise<boolean> => {\n const docClient = getDocClient();\n const tableName = getTableName();\n\n const existing = await getEntity({ id });\n if (!existing) {\n return false;\n }\n\n const now = new Date().toISOString();\n\n const updatedEntity = {\n ...existing,\n archivedAt: now,\n };\n\n const suffix = calculateEntitySuffix(updatedEntity);\n const archivedEntity = indexEntity(updatedEntity, suffix);\n\n const command = new PutCommand({\n Item: archivedEntity,\n TableName: tableName,\n });\n\n await docClient.send(command);\n return true;\n },\n});\n\n/**\n * Hard delete an entity (permanently removes from table)\n * Use with caution - prefer deleteEntity for soft delete\n */\nexport const destroyEntity = fabricService({\n alias: \"destroyEntity\",\n description: \"Hard delete an entity (permanently removes from table)\",\n input: {\n id: { type: String, description: \"Entity id\" },\n },\n service: async ({ id }): Promise<boolean> => {\n const docClient = getDocClient();\n const tableName = getTableName();\n\n const command = new DeleteCommand({\n Key: { id },\n TableName: tableName,\n });\n\n await docClient.send(command);\n return true;\n },\n});\n\n/**\n * Write multiple entities atomically using DynamoDB transactions.\n * Each entity is auto-indexed via indexEntity before writing.\n * All entities are written to the same table in a single transaction.\n */\nexport async function transactWriteEntities({\n entities,\n}: {\n entities: StorableEntity[];\n}): Promise<void> {\n const docClient = getDocClient();\n const tableName = getTableName();\n\n const command = new TransactWriteCommand({\n TransactItems: entities.map((entity) => ({\n Put: {\n Item: indexEntity(entity),\n TableName: tableName,\n },\n })),\n });\n\n await docClient.send(command);\n}\n","import { QueryCommand } from \"@aws-sdk/lib-dynamodb\";\nimport { ConfigurationError } from \"@jaypie/errors\";\nimport {\n fabricService,\n getGsiAttributeNames,\n getModelIndexes,\n type IndexDefinition,\n SEPARATOR,\n} from \"@jaypie/fabric\";\n\nimport { getDocClient, getTableName } from \"./client.js\";\nimport { ARCHIVED_SUFFIX, DELETED_SUFFIX } from \"./constants.js\";\nimport { buildCompositeKey } from \"./keyBuilders.js\";\nimport type {\n QueryByAliasParams,\n QueryByCategoryParams,\n QueryByScopeParams,\n QueryByTypeParams,\n QueryByXidParams,\n QueryResult,\n StorableEntity,\n} from \"./types.js\";\n\n// =============================================================================\n// Helpers\n// =============================================================================\n\n/**\n * Calculate the suffix for the GSI partition key based on archived/deleted\n * flags. Suffix stays on pk so deleted/archived entities are queried as their\n * own partition (active queries skip them naturally).\n */\nfunction calculateSuffix({\n archived,\n deleted,\n}: {\n archived?: boolean;\n deleted?: boolean;\n}): string {\n if (archived && deleted) {\n return ARCHIVED_SUFFIX + DELETED_SUFFIX;\n }\n if (archived) {\n return ARCHIVED_SUFFIX;\n }\n if (deleted) {\n return DELETED_SUFFIX;\n }\n return \"\";\n}\n\n/**\n * Find the registered index for a model that matches a given partition-key\n * shape. The matching index is the first one whose pk equals the expected\n * fields. Throws ConfigurationError if no match is found.\n */\nfunction requireIndex(model: string, pkFields: string[]): IndexDefinition {\n const indexes = getModelIndexes(model);\n const match = indexes.find(\n (index) =>\n index.pk.length === pkFields.length &&\n index.pk.every((field, i) => field === pkFields[i]),\n );\n if (!match) {\n throw new ConfigurationError(\n `Model \"${model}\" has no index with pk=[${pkFields.join(\", \")}]. ` +\n `Register one with fabricIndex(${\n pkFields.length > 1 ? `\"${pkFields[1]}\"` : \"\"\n }).`,\n );\n }\n return match;\n}\n\n/**\n * Execute a GSI query.\n *\n * - pk: exact match on the index partition key\n * - skPrefix: optional begins_with on the index sort key (used when the index\n * has a composite sk like [scope, updatedAt])\n */\nasync function executeQuery<T extends StorableEntity>(\n index: IndexDefinition,\n pkValue: string,\n options: {\n ascending?: boolean;\n limit?: number;\n skPrefix?: string;\n startKey?: Record<string, unknown>;\n } = {},\n): Promise<QueryResult<T>> {\n const { ascending = false, limit, skPrefix, startKey } = options;\n const attrs = getGsiAttributeNames(index);\n const indexName = attrs.pk;\n\n const expressionAttributeNames: Record<string, string> = {\n \"#pk\": indexName,\n };\n const expressionAttributeValues: Record<string, unknown> = {\n \":pkValue\": pkValue,\n };\n let keyConditionExpression = \"#pk = :pkValue\";\n\n if (skPrefix !== undefined && attrs.sk) {\n expressionAttributeNames[\"#sk\"] = attrs.sk;\n expressionAttributeValues[\":skPrefix\"] = skPrefix;\n keyConditionExpression += \" AND begins_with(#sk, :skPrefix)\";\n }\n\n const docClient = getDocClient();\n const tableName = getTableName();\n\n const command = new QueryCommand({\n ExclusiveStartKey: startKey as Record<string, unknown> | undefined,\n ExpressionAttributeNames: expressionAttributeNames,\n ExpressionAttributeValues: expressionAttributeValues,\n IndexName: indexName,\n KeyConditionExpression: keyConditionExpression,\n ...(limit && { Limit: limit }),\n ScanIndexForward: ascending,\n TableName: tableName,\n });\n\n const response = await docClient.send(command);\n\n return {\n items: (response.Items ?? []) as T[],\n lastEvaluatedKey: response.LastEvaluatedKey,\n };\n}\n\nfunction scopePrefix(scope: string | undefined): string | undefined {\n return scope === undefined ? undefined : `${scope}${SEPARATOR}`;\n}\n\n// =============================================================================\n// Query Functions\n// =============================================================================\n\n/**\n * List entities of a model, optionally narrowed to a scope.\n * Requires the model to register `fabricIndex()` (pk=[model]).\n */\nexport async function queryByScope({\n archived = false,\n ascending = false,\n deleted = false,\n limit,\n model,\n scope,\n startKey,\n}: QueryByScopeParams): Promise<QueryResult<StorableEntity>> {\n const index = requireIndex(model, [\"model\"]);\n const suffix = calculateSuffix({ archived, deleted });\n const pkValue = buildCompositeKey({ model }, [\"model\"], suffix);\n return executeQuery<StorableEntity>(index, pkValue, {\n ascending,\n limit,\n skPrefix: scopePrefix(scope),\n startKey,\n });\n}\n\n/**\n * Query a single entity by human-friendly alias.\n * Requires the model to register `fabricIndex(\"alias\")`.\n */\nexport const queryByAlias = fabricService({\n alias: \"queryByAlias\",\n description: \"Query a single entity by human-friendly alias\",\n input: {\n alias: { type: String, description: \"Human-friendly alias\" },\n archived: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Query archived entities instead of active ones\",\n },\n deleted: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Query deleted entities instead of active ones\",\n },\n model: { type: String, description: \"Entity model name\" },\n scope: {\n type: String,\n required: false,\n description: \"Optional scope narrower (begins_with on sk)\",\n },\n },\n service: async ({\n alias,\n archived,\n deleted,\n model,\n scope,\n }): Promise<StorableEntity | null> => {\n const aliasStr = alias as string;\n const archivedBool = archived as boolean | undefined;\n const deletedBool = deleted as boolean | undefined;\n const modelStr = model as string;\n const scopeStr = scope as string | undefined;\n\n const index = requireIndex(modelStr, [\"model\", \"alias\"]);\n const suffix = calculateSuffix({\n archived: archivedBool,\n deleted: deletedBool,\n });\n const pkValue = buildCompositeKey(\n { model: modelStr, alias: aliasStr },\n [\"model\", \"alias\"],\n suffix,\n );\n const result = await executeQuery<StorableEntity>(index, pkValue, {\n limit: 1,\n skPrefix: scopePrefix(scopeStr),\n });\n return result.items[0] ?? null;\n },\n});\n\n/**\n * Query entities by category classification.\n * Requires the model to register `fabricIndex(\"category\")`.\n */\nexport async function queryByCategory({\n archived = false,\n ascending = false,\n category,\n deleted = false,\n limit,\n model,\n scope,\n startKey,\n}: QueryByCategoryParams): Promise<QueryResult<StorableEntity>> {\n const index = requireIndex(model, [\"model\", \"category\"]);\n const suffix = calculateSuffix({ archived, deleted });\n const pkValue = buildCompositeKey(\n { model, category },\n [\"model\", \"category\"],\n suffix,\n );\n return executeQuery<StorableEntity>(index, pkValue, {\n ascending,\n limit,\n skPrefix: scopePrefix(scope),\n startKey,\n });\n}\n\n/**\n * Query entities by type classification.\n * Requires the model to register `fabricIndex(\"type\")`.\n */\nexport async function queryByType({\n archived = false,\n ascending = false,\n deleted = false,\n limit,\n model,\n scope,\n startKey,\n type,\n}: QueryByTypeParams): Promise<QueryResult<StorableEntity>> {\n const index = requireIndex(model, [\"model\", \"type\"]);\n const suffix = calculateSuffix({ archived, deleted });\n const pkValue = buildCompositeKey(\n { model, type },\n [\"model\", \"type\"],\n suffix,\n );\n return executeQuery<StorableEntity>(index, pkValue, {\n ascending,\n limit,\n skPrefix: scopePrefix(scope),\n startKey,\n });\n}\n\n/**\n * Query a single entity by external ID.\n * Requires the model to register `fabricIndex(\"xid\")`.\n */\nexport const queryByXid = fabricService({\n alias: \"queryByXid\",\n description: \"Query a single entity by external ID\",\n input: {\n archived: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Query archived entities instead of active ones\",\n },\n deleted: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Query deleted entities instead of active ones\",\n },\n model: { type: String, description: \"Entity model name\" },\n scope: {\n type: String,\n required: false,\n description: \"Optional scope narrower (begins_with on sk)\",\n },\n xid: { type: String, description: \"External ID\" },\n },\n service: async ({\n archived,\n deleted,\n model,\n scope,\n xid,\n }): Promise<StorableEntity | null> => {\n const archivedBool = archived as boolean | undefined;\n const deletedBool = deleted as boolean | undefined;\n const modelStr = model as string;\n const scopeStr = scope as string | undefined;\n const xidStr = xid as string;\n\n const index = requireIndex(modelStr, [\"model\", \"xid\"]);\n const suffix = calculateSuffix({\n archived: archivedBool,\n deleted: deletedBool,\n });\n const pkValue = buildCompositeKey(\n { model: modelStr, xid: xidStr },\n [\"model\", \"xid\"],\n suffix,\n );\n const result = await executeQuery<StorableEntity>(index, pkValue, {\n limit: 1,\n skPrefix: scopePrefix(scopeStr),\n });\n return result.items[0] ?? null;\n },\n});\n\n// Internal exports for the unified query() layer\nexport { executeQuery, requireIndex, calculateSuffix, scopePrefix };\n","import {\n CreateTableCommand,\n DescribeTableCommand,\n DynamoDBClient,\n} from \"@aws-sdk/client-dynamodb\";\nimport {\n fabricService,\n getAllRegisteredIndexes,\n getGsiAttributeNames,\n type IndexDefinition,\n} from \"@jaypie/fabric\";\n\nconst DEFAULT_ENDPOINT = \"http://127.0.0.1:8000\";\nconst DEFAULT_REGION = \"us-east-1\";\nconst DEFAULT_TABLE_NAME = \"jaypie-local\";\n\n// =============================================================================\n// Index → GSI Conversion\n// =============================================================================\n\n/**\n * Build attribute definitions from registered indexes.\n * Primary key is `id` (STRING) only; GSI pk and composite sk attributes\n * are all STRING. A single-field sk (e.g., raw `updatedAt`) is also STRING.\n */\nfunction buildAttributeDefinitions(\n indexes: IndexDefinition[],\n): Array<{ AttributeName: string; AttributeType: \"S\" | \"N\" }> {\n const attrs = new Map<string, \"S\" | \"N\">();\n\n // Primary key: id only\n attrs.set(\"id\", \"S\");\n\n for (const index of indexes) {\n const { pk, sk } = getGsiAttributeNames(index);\n // All pk attributes are composite strings\n if (!attrs.has(pk)) attrs.set(pk, \"S\");\n if (sk && !attrs.has(sk)) {\n // Single-field `sequence` remains NUMBER for back-compat callers;\n // every other sk attribute (composite or not) is STRING.\n attrs.set(sk, sk === \"sequence\" ? \"N\" : \"S\");\n }\n }\n\n return Array.from(attrs.entries())\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([name, type]) => ({\n AttributeName: name,\n AttributeType: type,\n }));\n}\n\n/**\n * Build GSI definitions from registered indexes\n */\nfunction buildGSIs(indexes: IndexDefinition[]): Array<{\n IndexName: string;\n KeySchema: Array<{ AttributeName: string; KeyType: \"HASH\" | \"RANGE\" }>;\n Projection: { ProjectionType: \"ALL\" };\n}> {\n const gsiProjection = { ProjectionType: \"ALL\" as const };\n\n return indexes.map((index) => {\n const { pk, sk } = getGsiAttributeNames(index);\n const keySchema: Array<{\n AttributeName: string;\n KeyType: \"HASH\" | \"RANGE\";\n }> = [{ AttributeName: pk, KeyType: \"HASH\" }];\n if (sk) {\n keySchema.push({ AttributeName: sk, KeyType: \"RANGE\" });\n }\n return {\n IndexName: pk,\n KeySchema: keySchema,\n Projection: gsiProjection,\n };\n });\n}\n\n// =============================================================================\n// Table Creation\n// =============================================================================\n\n/**\n * DynamoDB table schema with Jaypie GSI pattern.\n * Primary key is `id` only. GSIs come from models registered via\n * `registerModel()`, shaped by `fabricIndex()`.\n */\nfunction createTableParams(\n tableName: string,\n billingMode: \"PAY_PER_REQUEST\" | \"PROVISIONED\",\n) {\n const allIndexes = getAllRegisteredIndexes();\n\n return {\n AttributeDefinitions: buildAttributeDefinitions(allIndexes),\n BillingMode: billingMode,\n GlobalSecondaryIndexes: buildGSIs(allIndexes),\n KeySchema: [{ AttributeName: \"id\", KeyType: \"HASH\" as const }],\n TableName: tableName,\n };\n}\n\n/**\n * Create DynamoDB table with Jaypie GSI schema\n */\nexport const createTableHandler = fabricService({\n alias: \"dynamodb_create_table\",\n description: \"Create DynamoDB table with Jaypie GSI schema\",\n input: {\n billingMode: {\n type: [\"PAY_PER_REQUEST\", \"PROVISIONED\"] as const,\n default: \"PAY_PER_REQUEST\",\n description: \"DynamoDB billing mode\",\n },\n endpoint: {\n type: String,\n default: DEFAULT_ENDPOINT,\n description: \"DynamoDB endpoint URL\",\n },\n tableName: {\n type: String,\n default: DEFAULT_TABLE_NAME,\n description: \"Table name to create\",\n },\n },\n service: async ({ billingMode, endpoint, tableName }) => {\n const endpointStr = endpoint as string;\n const tableNameStr = tableName as string;\n const billingModeStr = billingMode as \"PAY_PER_REQUEST\" | \"PROVISIONED\";\n\n const client = new DynamoDBClient({\n credentials: {\n accessKeyId: \"local\",\n secretAccessKey: \"local\",\n },\n endpoint: endpointStr,\n region: DEFAULT_REGION,\n });\n\n try {\n await client.send(new DescribeTableCommand({ TableName: tableNameStr }));\n return {\n message: `Table \"${tableNameStr}\" already exists`,\n success: false,\n tableName: tableNameStr,\n };\n } catch (error) {\n if ((error as { name?: string }).name !== \"ResourceNotFoundException\") {\n throw error;\n }\n }\n\n const tableParams = createTableParams(tableNameStr, billingModeStr);\n await client.send(new CreateTableCommand(tableParams));\n\n return {\n message: \"Table created successfully\",\n success: true,\n tableName: tableNameStr,\n };\n },\n});\n","import { fabricService } from \"@jaypie/fabric\";\n\nconst DEFAULT_ADMIN_PORT = 8001;\nconst DEFAULT_DYNAMODB_PORT = 8000;\nconst DEFAULT_PROJECT_NAME = \"jaypie\";\nconst DEFAULT_TABLE_NAME = \"jaypie-local\";\n\n/**\n * Generate docker-compose.yml for local DynamoDB development\n */\nexport const dockerComposeHandler = fabricService({\n alias: \"dynamodb_generate_docker_compose\",\n description: \"Generate docker-compose.yml for local DynamoDB development\",\n input: {\n adminPort: {\n type: Number,\n default: DEFAULT_ADMIN_PORT,\n description: \"Port for DynamoDB Admin UI\",\n },\n dynamodbPort: {\n type: Number,\n default: DEFAULT_DYNAMODB_PORT,\n description: \"Port for DynamoDB Local\",\n },\n projectName: {\n type: String,\n default: DEFAULT_PROJECT_NAME,\n description: \"Project name for container naming\",\n },\n tableName: {\n type: String,\n default: DEFAULT_TABLE_NAME,\n description: \"Default table name\",\n },\n },\n service: async ({ adminPort, dynamodbPort, projectName, tableName }) => {\n const dockerCompose = `name: ${projectName}-dynamodb-stack\n\nservices:\n dynamodb:\n image: amazon/dynamodb-local:latest\n container_name: ${projectName}-dynamodb\n command: \"-jar DynamoDBLocal.jar -sharedDb -dbPath /data\"\n ports:\n - \"${dynamodbPort}:8000\"\n working_dir: /home/dynamodblocal\n volumes:\n - dynamodb_data:/data\n user: \"0:0\"\n\n dynamodb-admin:\n image: aaronshaf/dynamodb-admin:latest\n container_name: ${projectName}-dynamodb-admin\n ports:\n - \"${adminPort}:8001\"\n environment:\n - DYNAMO_ENDPOINT=http://dynamodb:8000\n - AWS_REGION=us-east-1\n - AWS_ACCESS_KEY_ID=local\n - AWS_SECRET_ACCESS_KEY=local\n depends_on:\n - dynamodb\n\nvolumes:\n dynamodb_data:\n driver: local\n`;\n\n const envVars = {\n AWS_REGION: \"us-east-1\",\n DYNAMODB_ENDPOINT: `http://127.0.0.1:${dynamodbPort}`,\n DYNAMODB_TABLE_NAME: tableName,\n };\n\n const envFile = `# DynamoDB Local Configuration\nDYNAMODB_TABLE_NAME=${tableName}\nDYNAMODB_ENDPOINT=http://127.0.0.1:${dynamodbPort}\nAWS_REGION=us-east-1\n`;\n\n return {\n dockerCompose,\n envFile,\n envVars,\n };\n },\n});\n","import { ConfigurationError } from \"@jaypie/errors\";\n\nimport { initClient, isInitialized } from \"../client.js\";\n\nconst DEFAULT_REGION = \"us-east-1\";\n\n/**\n * Ensure DynamoDB client is initialized from environment variables\n * Called automatically before each MCP tool execution\n */\nexport function ensureInitialized(): void {\n if (isInitialized()) {\n return;\n }\n\n const tableName = process.env.DYNAMODB_TABLE_NAME;\n if (!tableName) {\n throw new ConfigurationError(\n \"DYNAMODB_TABLE_NAME environment variable is required\",\n );\n }\n\n initClient({\n endpoint: process.env.DYNAMODB_ENDPOINT,\n region: process.env.AWS_REGION || DEFAULT_REGION,\n tableName,\n });\n}\n","import { fabricService } from \"@jaypie/fabric\";\n\nimport { getTableName, isInitialized } from \"../../client.js\";\nimport { ensureInitialized } from \"../autoInit.js\";\n\n/**\n * Check DynamoDB connection status and configuration\n */\nexport const statusHandler = fabricService({\n alias: \"dynamodb_status\",\n description: \"Check DynamoDB connection status and configuration\",\n service: async () => {\n ensureInitialized();\n return {\n endpoint: process.env.DYNAMODB_ENDPOINT || \"AWS Default\",\n initialized: isInitialized(),\n region: process.env.AWS_REGION || \"us-east-1\",\n tableName: getTableName(),\n };\n },\n});\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { fabricMcp } from \"@jaypie/fabric/mcp\";\nimport { fabricService, type Service } from \"@jaypie/fabric\";\n\nimport {\n archiveEntity,\n deleteEntity,\n destroyEntity,\n getEntity,\n putEntity,\n queryByAlias,\n queryByCategory,\n queryByScope,\n queryByType,\n queryByXid,\n updateEntity,\n} from \"../index.js\";\nimport type { StorableEntity } from \"../types.js\";\nimport {\n createTableHandler,\n dockerComposeHandler,\n statusHandler,\n} from \"./admin/index.js\";\nimport { ensureInitialized } from \"./autoInit.js\";\n\nexport interface RegisterDynamoDbToolsConfig {\n /** MCP server to register tools with */\n server: McpServer;\n /** Include admin tools (create_table, docker_compose, status). Default: true */\n includeAdmin?: boolean;\n}\n\nexport interface RegisterDynamoDbToolsResult {\n /** Names of registered tools */\n tools: string[];\n}\n\n/**\n * Wrap a handler to auto-initialize before execution\n * Uses explicit type assertion to allow any Service type to be wrapped\n */\n\nfunction wrapWithInit(handler: Service<any, any, any>): Service {\n const wrapped = async (input: Record<string, unknown>) => {\n ensureInitialized();\n return handler(input);\n };\n // Preserve handler properties for MCP registration\n Object.assign(wrapped, {\n alias: handler.alias,\n description: handler.description,\n input: handler.input,\n });\n return wrapped as Service;\n}\n\n// MCP-specific serviceHandler wrappers for functions with complex inputs\n// Note: These wrap the regular async functions to make them work with fabricMcp\n\n/**\n * MCP wrapper for putEntity\n * Accepts entity JSON directly from LLM\n */\nconst mcpPutEntity = fabricService({\n alias: \"dynamodb_put\",\n description:\n \"Create or replace an entity in DynamoDB (auto-indexes GSI keys)\",\n input: {\n // Required entity fields\n id: { type: String, description: \"Entity ID (sort key)\" },\n model: { type: String, description: \"Entity model name (partition key)\" },\n name: { type: String, description: \"Entity name\" },\n scope: { type: String, description: \"Scope (@ for root)\" },\n // Optional fields\n alias: {\n type: String,\n required: false,\n description: \"Human-friendly alias\",\n },\n category: {\n type: String,\n required: false,\n description: \"Category classification\",\n },\n type: { type: String, required: false, description: \"Type classification\" },\n xid: { type: String, required: false, description: \"External ID\" },\n },\n service: async (input) => {\n const now = new Date().toISOString();\n const entity: StorableEntity = {\n alias: input.alias as string | undefined,\n category: input.category as string | undefined,\n createdAt: now,\n id: input.id as string,\n model: input.model as string,\n name: input.name as string,\n scope: input.scope as string,\n sequence: Date.now(),\n type: input.type as string | undefined,\n updatedAt: now,\n xid: input.xid as string | undefined,\n };\n return putEntity({ entity });\n },\n});\n\n/**\n * MCP wrapper for updateEntity\n * Accepts entity JSON directly from LLM\n */\nconst mcpUpdateEntity = fabricService({\n alias: \"dynamodb_update\",\n description:\n \"Update an entity in DynamoDB (sets updatedAt, re-indexes GSI keys)\",\n input: {\n // Required fields to identify the entity\n id: { type: String, description: \"Entity ID (sort key)\" },\n model: { type: String, description: \"Entity model name (partition key)\" },\n // Fields that can be updated\n name: { type: String, required: false, description: \"Entity name\" },\n scope: { type: String, required: false, description: \"Scope\" },\n alias: {\n type: String,\n required: false,\n description: \"Human-friendly alias\",\n },\n category: {\n type: String,\n required: false,\n description: \"Category classification\",\n },\n type: { type: String, required: false, description: \"Type classification\" },\n xid: { type: String, required: false, description: \"External ID\" },\n },\n service: async (input) => {\n // First get the existing entity\n const existing = await getEntity({\n id: input.id as string,\n model: input.model as string,\n });\n if (!existing) {\n return { error: \"Entity not found\", id: input.id, model: input.model };\n }\n // Merge updates\n const entity: StorableEntity = {\n ...existing,\n ...(input.alias !== undefined && { alias: input.alias as string }),\n ...(input.category !== undefined && {\n category: input.category as string,\n }),\n ...(input.name !== undefined && { name: input.name as string }),\n ...(input.scope !== undefined && { scope: input.scope as string }),\n ...(input.type !== undefined && { type: input.type as string }),\n ...(input.xid !== undefined && { xid: input.xid as string }),\n };\n return updateEntity({ entity });\n },\n});\n\n/**\n * MCP wrapper for queryByScope\n * Note: Pagination via startKey is not exposed to MCP; use limit instead\n */\nconst mcpQueryByScope = fabricService({\n alias: \"dynamodb_query_scope\",\n description: \"Query entities by scope (parent hierarchy)\",\n input: {\n model: { type: String, description: \"Entity model name\" },\n scope: { type: String, description: \"Scope (@ for root)\" },\n archived: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Query archived entities instead of active ones\",\n },\n ascending: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Sort ascending (oldest first)\",\n },\n deleted: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Query deleted entities instead of active ones\",\n },\n limit: {\n type: Number,\n required: false,\n description: \"Maximum number of items to return\",\n },\n },\n service: async (input) => {\n return queryByScope({\n archived: input.archived as boolean,\n ascending: input.ascending as boolean,\n deleted: input.deleted as boolean,\n limit: input.limit as number | undefined,\n model: input.model as string,\n scope: input.scope as string,\n });\n },\n});\n\n/**\n * MCP wrapper for queryByCategory\n * Note: Pagination via startKey is not exposed to MCP; use limit instead\n */\nconst mcpQueryByCategory = fabricService({\n alias: \"dynamodb_query_category\",\n description: \"Query entities by category classification\",\n input: {\n category: { type: String, description: \"Category classification\" },\n model: { type: String, description: \"Entity model name\" },\n scope: { type: String, description: \"Scope (@ for root)\" },\n archived: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Query archived entities instead of active ones\",\n },\n ascending: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Sort ascending (oldest first)\",\n },\n deleted: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Query deleted entities instead of active ones\",\n },\n limit: {\n type: Number,\n required: false,\n description: \"Maximum number of items to return\",\n },\n },\n service: async (input) => {\n return queryByCategory({\n archived: input.archived as boolean,\n ascending: input.ascending as boolean,\n category: input.category as string,\n deleted: input.deleted as boolean,\n limit: input.limit as number | undefined,\n model: input.model as string,\n scope: input.scope as string,\n });\n },\n});\n\n/**\n * MCP wrapper for queryByType\n * Note: Pagination via startKey is not exposed to MCP; use limit instead\n */\nconst mcpQueryByType = fabricService({\n alias: \"dynamodb_query_type\",\n description: \"Query entities by type classification\",\n input: {\n model: { type: String, description: \"Entity model name\" },\n scope: { type: String, description: \"Scope (@ for root)\" },\n type: { type: String, description: \"Type classification\" },\n archived: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Query archived entities instead of active ones\",\n },\n ascending: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Sort ascending (oldest first)\",\n },\n deleted: {\n type: Boolean,\n default: false,\n required: false,\n description: \"Query deleted entities instead of active ones\",\n },\n limit: {\n type: Number,\n required: false,\n description: \"Maximum number of items to return\",\n },\n },\n service: async (input) => {\n return queryByType({\n archived: input.archived as boolean,\n ascending: input.ascending as boolean,\n deleted: input.deleted as boolean,\n limit: input.limit as number | undefined,\n model: input.model as string,\n scope: input.scope as string,\n type: input.type as string,\n });\n },\n});\n\n/**\n * Register all DynamoDB MCP tools with a server\n */\nexport function registerDynamoDbTools(\n config: RegisterDynamoDbToolsConfig,\n): RegisterDynamoDbToolsResult {\n const { includeAdmin = true, server } = config;\n const tools: string[] = [];\n\n // Entity operations\n fabricMcp({\n service: wrapWithInit(getEntity),\n name: \"dynamodb_get\",\n server,\n });\n tools.push(\"dynamodb_get\");\n\n fabricMcp({\n service: wrapWithInit(mcpPutEntity),\n name: \"dynamodb_put\",\n server,\n });\n tools.push(\"dynamodb_put\");\n\n fabricMcp({\n service: wrapWithInit(mcpUpdateEntity),\n name: \"dynamodb_update\",\n server,\n });\n tools.push(\"dynamodb_update\");\n\n fabricMcp({\n service: wrapWithInit(deleteEntity),\n name: \"dynamodb_delete\",\n server,\n });\n tools.push(\"dynamodb_delete\");\n\n fabricMcp({\n service: wrapWithInit(archiveEntity),\n name: \"dynamodb_archive\",\n server,\n });\n tools.push(\"dynamodb_archive\");\n\n fabricMcp({\n service: wrapWithInit(destroyEntity),\n name: \"dynamodb_destroy\",\n server,\n });\n tools.push(\"dynamodb_destroy\");\n\n // Query operations\n fabricMcp({\n service: wrapWithInit(mcpQueryByScope),\n name: \"dynamodb_query_scope\",\n server,\n });\n tools.push(\"dynamodb_query_scope\");\n\n fabricMcp({\n service: wrapWithInit(queryByAlias),\n name: \"dynamodb_query_alias\",\n server,\n });\n tools.push(\"dynamodb_query_alias\");\n\n fabricMcp({\n service: wrapWithInit(mcpQueryByCategory),\n name: \"dynamodb_query_category\",\n server,\n });\n tools.push(\"dynamodb_query_category\");\n\n fabricMcp({\n service: wrapWithInit(mcpQueryByType),\n name: \"dynamodb_query_type\",\n server,\n });\n tools.push(\"dynamodb_query_type\");\n\n fabricMcp({\n service: wrapWithInit(queryByXid),\n name: \"dynamodb_query_xid\",\n server,\n });\n tools.push(\"dynamodb_query_xid\");\n\n // Admin tools (MCP-only)\n if (includeAdmin) {\n fabricMcp({ service: statusHandler, server });\n tools.push(\"dynamodb_status\");\n\n fabricMcp({ service: createTableHandler, server });\n tools.push(\"dynamodb_create_table\");\n\n fabricMcp({ service: dockerComposeHandler, server });\n tools.push(\"dynamodb_generate_docker_compose\");\n }\n\n return { tools };\n}\n\n// Export individual handlers for direct use\nexport {\n createTableHandler,\n dockerComposeHandler,\n statusHandler,\n} from \"./admin/index.js\";\n\nexport { ensureInitialized } from \"./autoInit.js\";\n"],"names":["DEFAULT_REGION","DynamoDBClient","DynamoDBDocumentClient","ConfigurationError","fabricBuildCompositeKey","getModelIndexes","fabricPopulateIndexKeys","ARCHIVED_SUFFIX","DELETED_SUFFIX","fabricService","GetCommand","PutCommand","DeleteCommand","getGsiAttributeNames","QueryCommand","SEPARATOR","DEFAULT_TABLE_NAME","getAllRegisteredIndexes","DescribeTableCommand","CreateTableCommand","fabricMcp"],"mappings":";;;;;;;;AAMA;AACA,MAAM,cAAc,GAAG,YAAY;AACnC,MAAM,uBAAuB,GAAG,qBAAqB;AAErD;AACA,MAAMA,gBAAc,GAAG,WAAW;AAClC,MAAM,iBAAiB,GAAG;AACxB,IAAA,WAAW,EAAE,OAAO;AACpB,IAAA,eAAe,EAAE,OAAO;CACzB;AAED;AACA,IAAI,SAAS,GAAkC,IAAI;AACnD,IAAI,SAAS,GAAkB,IAAI;AAEnC;;AAEG;AACH,SAAS,eAAe,CAAC,QAAiB,EAAA;AACxC,IAAA,IAAI,CAAC,QAAQ;AAAE,QAAA,OAAO,KAAK;AAC3B,IAAA,OAAO,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC;AACzE;AAEA;;;;;AAKG;AACG,SAAU,UAAU,CAAC,MAAA,GAA6B,EAAE,EAAA;AACxD,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM;AAC3B,IAAA,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAIA,gBAAc;;AAG7E,IAAA,MAAM,WAAW,GACf,MAAM,CAAC,WAAW;AAClB,SAAC,eAAe,CAAC,QAAQ,CAAC,GAAG,iBAAiB,GAAG,SAAS,CAAC;AAE7D,IAAA,MAAM,YAAY,GAAG,IAAIC,6BAAc,CAAC;AACtC,QAAA,IAAI,WAAW,IAAI,EAAE,WAAW,EAAE,CAAC;AACnC,QAAA,IAAI,QAAQ,IAAI,EAAE,QAAQ,EAAE,CAAC;QAC7B,MAAM;AACP,KAAA,CAAC;AAEF,IAAA,SAAS,GAAGC,kCAAsB,CAAC,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EAAE,oBAAoB,EAAE,MAAM,EAAE,CAAC;AACpD,QAAA,KAAK,CAAC,IAAI,CAAC,kCAAkC,CAAC;IAChD;IAEA,OAAO,EAAE,KAAK,EAAE;AAClB;;;;;;;;"}
@@ -1,59 +1,57 @@
1
- import type { BaseQueryOptions, StorableEntity, QueryResult } from "./types.js";
1
+ import { type IndexDefinition } from "@jaypie/fabric";
2
+ import type { QueryByCategoryParams, QueryByScopeParams, QueryByTypeParams, QueryResult, StorableEntity } from "./types.js";
2
3
  /**
3
- * Query parameters for queryByScope
4
+ * Calculate the suffix for the GSI partition key based on archived/deleted
5
+ * flags. Suffix stays on pk so deleted/archived entities are queried as their
6
+ * own partition (active queries skip them naturally).
4
7
  */
5
- interface QueryByScopeParams extends BaseQueryOptions {
6
- model: string;
7
- scope: string;
8
- }
8
+ declare function calculateSuffix({ archived, deleted, }: {
9
+ archived?: boolean;
10
+ deleted?: boolean;
11
+ }): string;
9
12
  /**
10
- * Query entities by scope (parent hierarchy)
11
- * Uses indexScope GSI
12
- *
13
- * Note: This is a regular async function (not fabricService) because it accepts
14
- * complex startKey objects that can't be coerced by vocabulary's type system.
13
+ * Find the registered index for a model that matches a given partition-key
14
+ * shape. The matching index is the first one whose pk equals the expected
15
+ * fields. Throws ConfigurationError if no match is found.
15
16
  */
16
- export declare function queryByScope({ archived, ascending, deleted, limit, model, scope, startKey, }: QueryByScopeParams): Promise<QueryResult<StorableEntity>>;
17
+ declare function requireIndex(model: string, pkFields: string[]): IndexDefinition;
17
18
  /**
18
- * Query a single entity by human-friendly alias
19
- * Uses indexAlias GSI
19
+ * Execute a GSI query.
20
+ *
21
+ * - pk: exact match on the index partition key
22
+ * - skPrefix: optional begins_with on the index sort key (used when the index
23
+ * has a composite sk like [scope, updatedAt])
20
24
  */
21
- export declare const queryByAlias: import("@jaypie/fabric").Service<Record<string, unknown>, StorableEntity | null, StorableEntity | null>;
25
+ declare function executeQuery<T extends StorableEntity>(index: IndexDefinition, pkValue: string, options?: {
26
+ ascending?: boolean;
27
+ limit?: number;
28
+ skPrefix?: string;
29
+ startKey?: Record<string, unknown>;
30
+ }): Promise<QueryResult<T>>;
31
+ declare function scopePrefix(scope: string | undefined): string | undefined;
22
32
  /**
23
- * Query parameters for queryByCategory
33
+ * List entities of a model, optionally narrowed to a scope.
34
+ * Requires the model to register `fabricIndex()` (pk=[model]).
24
35
  */
25
- interface QueryByCategoryParams extends BaseQueryOptions {
26
- category: string;
27
- model: string;
28
- scope: string;
29
- }
36
+ export declare function queryByScope({ archived, ascending, deleted, limit, model, scope, startKey, }: QueryByScopeParams): Promise<QueryResult<StorableEntity>>;
30
37
  /**
31
- * Query entities by category classification
32
- * Uses indexCategory GSI
33
- *
34
- * Note: This is a regular async function (not fabricService) because it accepts
35
- * complex startKey objects that can't be coerced by vocabulary's type system.
38
+ * Query a single entity by human-friendly alias.
39
+ * Requires the model to register `fabricIndex("alias")`.
36
40
  */
37
- export declare function queryByCategory({ archived, ascending, category, deleted, limit, model, scope, startKey, }: QueryByCategoryParams): Promise<QueryResult<StorableEntity>>;
41
+ export declare const queryByAlias: import("@jaypie/fabric").Service<Record<string, unknown>, StorableEntity | null, StorableEntity | null>;
38
42
  /**
39
- * Query parameters for queryByType
43
+ * Query entities by category classification.
44
+ * Requires the model to register `fabricIndex("category")`.
40
45
  */
41
- interface QueryByTypeParams extends BaseQueryOptions {
42
- model: string;
43
- scope: string;
44
- type: string;
45
- }
46
+ export declare function queryByCategory({ archived, ascending, category, deleted, limit, model, scope, startKey, }: QueryByCategoryParams): Promise<QueryResult<StorableEntity>>;
46
47
  /**
47
- * Query entities by type classification
48
- * Uses indexType GSI
49
- *
50
- * Note: This is a regular async function (not fabricService) because it accepts
51
- * complex startKey objects that can't be coerced by vocabulary's type system.
48
+ * Query entities by type classification.
49
+ * Requires the model to register `fabricIndex("type")`.
52
50
  */
53
51
  export declare function queryByType({ archived, ascending, deleted, limit, model, scope, startKey, type, }: QueryByTypeParams): Promise<QueryResult<StorableEntity>>;
54
52
  /**
55
- * Query a single entity by external ID
56
- * Uses indexXid GSI
53
+ * Query a single entity by external ID.
54
+ * Requires the model to register `fabricIndex("xid")`.
57
55
  */
58
56
  export declare const queryByXid: import("@jaypie/fabric").Service<Record<string, unknown>, StorableEntity | null, StorableEntity | null>;
59
- export {};
57
+ export { executeQuery, requireIndex, calculateSuffix, scopePrefix };
@@ -17,42 +17,42 @@ export interface QueryParams<T = StorableEntity> {
17
17
  ascending?: boolean;
18
18
  /** Whether to query deleted entities instead of active ones */
19
19
  deleted?: boolean;
20
- /** Filter object with field values to match. Used for index auto-detection. */
20
+ /**
21
+ * Filter object with field values to match. Used for index auto-detection
22
+ * — the picker scores indexes by how many pk fields (after `model`) are
23
+ * present in this filter.
24
+ */
21
25
  filter?: Partial<T>;
22
26
  /** Maximum number of items to return */
23
27
  limit?: number;
24
28
  /** Model name (required) */
25
29
  model: string;
26
- /** Scope (APEX or "{parent.model}#{parent.id}") */
30
+ /**
31
+ * Optional scope narrower. Applied as `begins_with` on the GSI sort key
32
+ * (composite scope + updatedAt). Omit to list across all scopes.
33
+ */
27
34
  scope?: string;
28
35
  /** Pagination cursor from previous query */
29
36
  startKey?: Record<string, unknown>;
30
37
  }
31
38
  /**
32
- * Query entities with automatic index selection
33
- *
34
- * The query function automatically selects the best GSI based on
35
- * the filter fields provided. This removes the need to know which
36
- * specific query function (queryByOu, queryByAlias, etc.) to use.
39
+ * Query entities with automatic index selection.
37
40
  *
38
41
  * @example
39
- * // Uses indexScope (pk: ["scope", "model"])
40
- * const allMessages = await query({ model: "message", scope: `chat#${chatId}` });
42
+ * // Uses indexModel (pk: ["model"]), optionally narrowed by scope
43
+ * const records = await query({ model: "record", scope: "@" });
41
44
  *
42
45
  * @example
43
- * // Uses indexAlias (pk: ["scope", "model", "alias"])
44
- * const byAlias = await query({
45
- * model: "record",
46
- * scope: "@",
47
- * filter: { alias: "my-record" },
48
- * });
46
+ * // Uses indexModelAlias (pk: ["model", "alias"])
47
+ * const byAlias = await query({
48
+ * model: "record",
49
+ * scope: "@",
50
+ * filter: { alias: "my-record" },
51
+ * });
49
52
  *
50
53
  * @example
51
- * // Uses a custom registered index if model has one
52
- * const byChat = await query({
53
- * model: "message",
54
- * filter: { chatId: "abc-123" },
55
- * });
54
+ * // Cross-scope listing (no scope narrower)
55
+ * const all = await query({ model: "record" });
56
56
  */
57
57
  export declare function query<T extends StorableEntity = StorableEntity>(params: QueryParams<T>): Promise<QueryResult<T>>;
58
58
  export { getModelIndexes };