feature/api-development #1
|
|
@ -117,12 +117,13 @@ export class AliasService {
|
||||||
alias: string,
|
alias: string,
|
||||||
projectId: string
|
projectId: string
|
||||||
): Promise<AliasResolution | null> {
|
): Promise<AliasResolution | null> {
|
||||||
|
// Project aliases can exist on images with or without flowId
|
||||||
|
// Per spec: images with project alias should be resolvable at project level
|
||||||
const image = await db.query.images.findFirst({
|
const image = await db.query.images.findFirst({
|
||||||
where: and(
|
where: and(
|
||||||
eq(images.projectId, projectId),
|
eq(images.projectId, projectId),
|
||||||
eq(images.alias, alias),
|
eq(images.alias, alias),
|
||||||
isNull(images.deletedAt),
|
isNull(images.deletedAt)
|
||||||
isNull(images.flowId)
|
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -272,6 +272,7 @@ export class ImageService {
|
||||||
projectId: string
|
projectId: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
// Step 1: Clear alias from any existing image with this alias
|
// Step 1: Clear alias from any existing image with this alias
|
||||||
|
// Project aliases can exist on images with or without flowId
|
||||||
await db
|
await db
|
||||||
.update(images)
|
.update(images)
|
||||||
.set({
|
.set({
|
||||||
|
|
@ -282,8 +283,7 @@ export class ImageService {
|
||||||
and(
|
and(
|
||||||
eq(images.projectId, projectId),
|
eq(images.projectId, projectId),
|
||||||
eq(images.alias, alias),
|
eq(images.alias, alias),
|
||||||
isNull(images.deletedAt),
|
isNull(images.deletedAt)
|
||||||
isNull(images.flowId)
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,19 +34,15 @@ async function main() {
|
||||||
testContext.firstGenId = generation.id;
|
testContext.firstGenId = generation.id;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test 2: Lazy flow - verify flow doesn't exist yet
|
// Test 2: Lazy flow - verify flow doesn't exist yet (Section 4.1)
|
||||||
await runTest('Lazy flow - verify flow not created yet', async () => {
|
await runTest('Lazy flow - verify flow not created yet', async () => {
|
||||||
try {
|
const result = await api(`${endpoints.flows}/${testContext.lazyFlowId}`, {
|
||||||
await api(`${endpoints.flows}/${testContext.lazyFlowId}`, {
|
expectError: true,
|
||||||
expectError: true,
|
});
|
||||||
});
|
if (result.status !== 404) {
|
||||||
throw new Error('Flow should not exist yet (lazy creation)');
|
throw new Error('Flow should not exist yet (lazy creation)');
|
||||||
} catch (error: any) {
|
|
||||||
if (error.message.includes('should not exist')) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
log.detail('Flow correctly does not exist', '✓');
|
|
||||||
}
|
}
|
||||||
|
log.detail('Flow correctly does not exist', '✓');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test 3: Lazy flow - second use creates flow
|
// Test 3: Lazy flow - second use creates flow
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,9 @@ async function main() {
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = await api(endpoints.live, {
|
// Live endpoint requires prompt query parameter
|
||||||
|
const testPrompt = encodeURIComponent('A simple blue square on white background');
|
||||||
|
const result = await api(`${endpoints.live}?prompt=${testPrompt}`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -117,18 +119,15 @@ async function main() {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
});
|
});
|
||||||
|
|
||||||
// Verify deleted
|
// Verify deleted - check for 404 status
|
||||||
try {
|
const result = await api(`${endpoints.live}/scopes/test-scope`, {
|
||||||
await api(`${endpoints.live}/scopes/test-scope`, {
|
expectError: true,
|
||||||
expectError: true,
|
});
|
||||||
});
|
|
||||||
|
if (result.status !== 404) {
|
||||||
throw new Error('Scope should be deleted');
|
throw new Error('Scope should be deleted');
|
||||||
} catch (error: any) {
|
|
||||||
if (error.message.includes('should be deleted')) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
log.detail('Scope deleted', '✓');
|
|
||||||
}
|
}
|
||||||
|
log.detail('Scope deleted', '✓');
|
||||||
});
|
});
|
||||||
|
|
||||||
log.section('LIVE URL & SCOPE TESTS COMPLETED');
|
log.section('LIVE URL & SCOPE TESTS COMPLETED');
|
||||||
|
|
|
||||||
|
|
@ -313,11 +313,22 @@ export async function resolveAlias(
|
||||||
const result = await api(endpoint);
|
const result = await api(endpoint);
|
||||||
const image = result.data.data;
|
const image = result.data.data;
|
||||||
|
|
||||||
|
// Determine scope based on alias type and context
|
||||||
|
const technicalAliases = ['@last', '@first', '@upload'];
|
||||||
|
let scope: string;
|
||||||
|
if (technicalAliases.includes(alias)) {
|
||||||
|
scope = 'technical';
|
||||||
|
} else if (flowId) {
|
||||||
|
scope = 'flow';
|
||||||
|
} else {
|
||||||
|
scope = 'project';
|
||||||
|
}
|
||||||
|
|
||||||
// Adapt response to match old /resolve/ format for test compatibility
|
// Adapt response to match old /resolve/ format for test compatibility
|
||||||
return {
|
return {
|
||||||
imageId: image.id,
|
imageId: image.id,
|
||||||
alias: image.alias || alias,
|
alias: image.alias || alias,
|
||||||
scope: image.flowId ? 'flow' : 'project',
|
scope,
|
||||||
flowId: image.flowId,
|
flowId: image.flowId,
|
||||||
image,
|
image,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue