Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
jdanyow committed Aug 22, 2024
1 parent 89458c0 commit f0d449c
Show file tree
Hide file tree
Showing 31 changed files with 158 additions and 124 deletions.
72 changes: 36 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"devDependencies": {
"@changesets/cli": "^2.27.7",
"husky": "^9.1.4",
"husky": "^9.1.5",
"lint-staged": "15.2.9",
"prettier": "3.3.3"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cosmos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@
"esbuild": "^0.23.1",
"mocha": "^10.7.3",
"typescript": "^5.5.4",
"wrangler": "^3.72.0"
"wrangler": "^3.72.1"
}
}
36 changes: 26 additions & 10 deletions packages/cosmos/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ export class CosmosClient {
return new FeedResponse<Database>(response, next, 'Databases');
}

public async getDatabase(args: GetDatabaseArgs = {}) {
public async getDatabase(
args: GetDatabaseArgs = {}
): Promise<ItemResponse<Database>> {
const { dbId = this.dbId, ...headers } = args;
assertArg('dbId', dbId);
const url = this.endpoint + uri`/dbs/${dbId}`;
Expand All @@ -137,7 +139,9 @@ export class CosmosClient {
return new FeedResponse<Collection>(response, next, 'DocumentCollections');
}

public async getCollection(args: GetCollectionArgs = {}) {
public async getCollection(
args: GetCollectionArgs = {}
): Promise<ItemResponse<Collection>> {
const { dbId = this.dbId, collId = this.collId, ...headers } = args;
assertArg('dbId', dbId);
assertArg('collId', collId);
Expand All @@ -148,7 +152,9 @@ export class CosmosClient {
return new ItemResponse<Collection>(response);
}

public async createCollection(args: CreateCollectionArgs) {
public async createCollection(
args: CreateCollectionArgs
): Promise<ItemResponse<Collection>> {
const {
dbId = this.dbId,
collId = this.collId,
Expand All @@ -167,7 +173,9 @@ export class CosmosClient {
return new ItemResponse<Collection>(response);
}

public async replaceCollection(args: ReplaceCollectionArgs) {
public async replaceCollection(
args: ReplaceCollectionArgs
): Promise<ItemResponse<Collection>> {
const {
dbId = this.dbId,
collId = this.collId,
Expand All @@ -186,7 +194,9 @@ export class CosmosClient {
return new ItemResponse<Collection>(response);
}

public async deleteCollection(args: DeleteCollectionArgs = {}) {
public async deleteCollection(
args: DeleteCollectionArgs = {}
): Promise<Response> {
const { dbId = this.dbId, collId = this.collId, ...headers } = args;
assertArg('dbId', dbId);
assertArg('collId', collId);
Expand Down Expand Up @@ -215,7 +225,9 @@ export class CosmosClient {
return new FeedResponse<T & Document>(response, next, 'Documents');
}

public async getDocument<T extends Resource>(args: GetDocumentArgs) {
public async getDocument<T extends Resource>(
args: GetDocumentArgs
): Promise<ItemResponse<T & Document>> {
const { dbId = this.dbId, collId = this.collId, docId, ...headers } = args;
assertArg('dbId', dbId);
assertArg('collId', collId);
Expand All @@ -226,7 +238,9 @@ export class CosmosClient {
return new ItemResponse<T & Document>(response);
}

public async createDocument<T extends Resource>(args: CreateDocumentArgs) {
public async createDocument<T extends Resource>(
args: CreateDocumentArgs
): Promise<ItemResponse<T & Document>> {
const {
dbId = this.dbId,
collId = this.collId,
Expand All @@ -244,7 +258,9 @@ export class CosmosClient {
return new ItemResponse<T & Document>(response);
}

public async replaceDocument<T extends Resource>(args: ReplaceDocumentArgs) {
public async replaceDocument<T extends Resource>(
args: ReplaceDocumentArgs
): Promise<ItemResponse<T & Document>> {
const {
dbId = this.dbId,
collId = this.collId,
Expand All @@ -263,7 +279,7 @@ export class CosmosClient {
return new ItemResponse<T & Document>(response);
}

public async deleteDocument(args: DeleteDocumentArgs) {
public async deleteDocument(args: DeleteDocumentArgs): Promise<Response> {
const { dbId = this.dbId, collId = this.collId, docId, ...headers } = args;
assertArg('dbId', dbId);
assertArg('collId', collId);
Expand Down Expand Up @@ -316,7 +332,7 @@ export class CosmosClient {
response: Response,
args: TArgs,
fn: (args: TArgs) => Promise<FeedResponse<TResult>>
) {
): () => Promise<FeedResponse<TResult>> {
return () => {
const continuation = response.headers.get('x-ms-continuation');
if (!continuation) {
Expand Down
18 changes: 9 additions & 9 deletions packages/cosmos/src/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@ import { PersistedResource } from './types.js';
export abstract class CosmosResponse {
constructor(protected readonly response: Response) {}

get status() {
get status(): number {
return this.response.status;
}
get headers() {
get headers(): Headers {
return this.response.headers;
}
get body() {
get body(): ReadableStream<Uint8Array> | null {
return this.response.body;
}
get activityId() {
get activityId(): string | null {
return this.response.headers.get('x-ms-activity-id');
}
get etag() {
get etag(): string {
return this.response.headers.get('etag')!;
}
get requestCharge() {
get requestCharge(): number {
return parseInt(this.response.headers.get('x-ms-request-charge')!);
}
get raw() {
get raw(): Response {
return this.response;
}
}
Expand All @@ -45,10 +45,10 @@ export class FeedResponse<T> extends CosmosResponse {
super(response);
}

get count() {
get count(): number {
return parseInt(this.response.headers.get('x-ms-item-count')!);
}
get hasNext() {
get hasNext(): boolean {
return this.response.headers.has('x-ms-continuation');
}

Expand Down
2 changes: 1 addition & 1 deletion packages/cosmos/src/retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ export class DefaultRetryPolicy implements RetryPolicy {
}
}

export const defaultRetryPolicy = new DefaultRetryPolicy();
export const defaultRetryPolicy: RetryPolicy = new DefaultRetryPolicy();
Loading

0 comments on commit f0d449c

Please sign in to comment.