Skip to content

Commit 1aa5646

Browse files
committed
remove unused ok/error wrapper from appDeploymentDocumentHashes
1 parent f3efe71 commit 1aa5646

File tree

5 files changed

+17
-74
lines changed

5 files changed

+17
-74
lines changed

integration-tests/tests/api/app-deployments.spec.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5226,14 +5226,7 @@ const GetExistingDocumentHashes = graphql(`
52265226
$hashes: [String!]!
52275227
) {
52285228
target(reference: { bySelector: $targetSelector }) {
5229-
appDeploymentDocumentHashes(appName: $appName, hashes: $hashes) {
5230-
ok {
5231-
hashes
5232-
}
5233-
error {
5234-
message
5235-
}
5236-
}
5229+
appDeploymentDocumentHashes(appName: $appName, hashes: $hashes)
52375230
}
52385231
}
52395232
`);
@@ -5657,9 +5650,10 @@ test('appDeploymentDocumentHashes returns existing hashes for delta upload', asy
56575650
authToken: token.secret,
56585651
}).then(res => res.expectNoGraphQLErrors());
56595652

5660-
expect(targetResult?.appDeploymentDocumentHashes.ok?.hashes).toContain(hash1);
5661-
expect(targetResult?.appDeploymentDocumentHashes.ok?.hashes).toContain(hash2);
5662-
expect(targetResult?.appDeploymentDocumentHashes.ok?.hashes?.length).toBe(2);
5653+
expect(targetResult?.appDeploymentDocumentHashes).toContain(hash1);
5654+
expect(targetResult?.appDeploymentDocumentHashes).toContain(hash2);
5655+
expect(targetResult?.appDeploymentDocumentHashes).not.toContain('nonexistent-hash');
5656+
expect(targetResult?.appDeploymentDocumentHashes?.length).toBe(2);
56635657
});
56645658

56655659
test('v2 format prevents hash collision by rejecting non-sha256 hashes', async () => {
@@ -5858,7 +5852,7 @@ test('v2 format enables cross-version document sharing', async () => {
58585852
authToken: token.secret,
58595853
}).then(res => res.expectNoGraphQLErrors());
58605854

5861-
expect(targetResult?.appDeploymentDocumentHashes.ok?.hashes).toContain(sharedHash);
5855+
expect(targetResult?.appDeploymentDocumentHashes).toContain(sharedHash);
58625856

58635857
// Add the same document to v2.0.0 (should succeed, uses shared storage)
58645858
const { addDocumentsToAppDeployment } = await execute({
@@ -6007,6 +6001,5 @@ test('appDeploymentDocumentHashes returns empty array for app with no previous d
60076001
}).then(res => res.expectNoGraphQLErrors());
60086002

60096003
// Should return empty array, not error
6010-
expect(targetResult?.appDeploymentDocumentHashes.ok?.hashes).toEqual([]);
6011-
expect(targetResult?.appDeploymentDocumentHashes.error).toBeNull();
6004+
expect(targetResult?.appDeploymentDocumentHashes).toEqual([]);
60126005
});

packages/libraries/cli/src/commands/app/create.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -196,19 +196,15 @@ export default class AppCreate extends Command<typeof AppCreate> {
196196
},
197197
});
198198

199-
if (hashesResult.target?.appDeploymentDocumentHashes.error) {
199+
if (!hashesResult.target) {
200200
this.logWarning(
201-
`Could not fetch existing document hashes: ${hashesResult.target.appDeploymentDocumentHashes.error.message}. Delta optimization disabled.`,
201+
`Target not found when fetching existing hashes. Delta optimization disabled.`,
202202
);
203-
} else if (hashesResult.target?.appDeploymentDocumentHashes.ok?.hashes) {
204-
existingHashes = new Set(hashesResult.target.appDeploymentDocumentHashes.ok.hashes);
203+
} else {
204+
existingHashes = new Set(hashesResult.target.appDeploymentDocumentHashes);
205205
if (flags.showTiming) {
206206
this.log(`Found ${existingHashes.size} existing documents (will skip)`);
207207
}
208-
} else if (!hashesResult.target) {
209-
this.logWarning(
210-
`Target not found when fetching existing hashes. Delta optimization disabled.`,
211-
);
212208
}
213209
}
214210

@@ -370,14 +366,7 @@ const GetExistingDocumentHashesQuery = graphql(/* GraphQL */ `
370366
$hashes: [String!]!
371367
) {
372368
target(reference: $target) {
373-
appDeploymentDocumentHashes(appName: $appName, hashes: $hashes) {
374-
ok {
375-
hashes
376-
}
377-
error {
378-
message
379-
}
380-
}
369+
appDeploymentDocumentHashes(appName: $appName, hashes: $hashes)
381370
}
382371
}
383372
`);

packages/services/api/src/modules/app-deployments/module.graphql.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -141,23 +141,7 @@ export default gql`
141141
appDeploymentDocumentHashes(
142142
appName: String!
143143
hashes: [String!]!
144-
): AppDeploymentDocumentHashesResult!
145-
}
146-
147-
type AppDeploymentDocumentHashesResult {
148-
ok: AppDeploymentDocumentHashesOk
149-
error: AppDeploymentDocumentHashesError
150-
}
151-
152-
type AppDeploymentDocumentHashesOk {
153-
"""
154-
List of document hashes that already exist for this app.
155-
"""
156-
hashes: [String!]!
157-
}
158-
159-
type AppDeploymentDocumentHashesError implements Error {
160-
message: String!
144+
): [String!]!
161145
}
162146
163147
extend type Mutation {

packages/services/api/src/modules/app-deployments/providers/app-deployments-manager.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,7 @@ export class AppDeploymentsManager {
285285
targetId: string;
286286
appName: string;
287287
hashes: readonly string[];
288-
}): Promise<
289-
{ type: 'success'; hashes: string[] } | { type: 'error'; error: { message: string } }
290-
> {
288+
}): Promise<string[]> {
291289
await this.session.assertPerformAction({
292290
action: 'appDeployment:create',
293291
organizationId: args.organizationId,
@@ -299,15 +297,10 @@ export class AppDeploymentsManager {
299297
},
300298
});
301299

302-
const hashes = await this.appDeployments.getExistingDocumentHashes({
300+
return this.appDeployments.getExistingDocumentHashes({
303301
targetId: args.targetId,
304302
appName: args.appName,
305303
hashes: args.hashes,
306304
});
307-
308-
return {
309-
type: 'success',
310-
hashes,
311-
};
312305
}
313306
}

packages/services/api/src/modules/app-deployments/resolvers/Target.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,13 @@ export const Target: Pick<
5757
},
5858
});
5959
},
60-
appDeploymentDocumentHashes: async (target, args, { injector }) => {
61-
const result = await injector.get(AppDeploymentsManager).getExistingDocumentHashes({
60+
appDeploymentDocumentHashes: (target, args, { injector }) => {
61+
return injector.get(AppDeploymentsManager).getExistingDocumentHashes({
6262
organizationId: target.orgId,
6363
projectId: target.projectId,
6464
targetId: target.id,
6565
appName: args.appName,
6666
hashes: args.hashes,
6767
});
68-
69-
if (result.type === 'error') {
70-
return {
71-
ok: null,
72-
error: {
73-
message: result.error.message,
74-
},
75-
};
76-
}
77-
78-
return {
79-
ok: {
80-
hashes: result.hashes,
81-
},
82-
error: null,
83-
};
8468
},
8569
};

0 commit comments

Comments
 (0)