Skip to content

Commit

Permalink
Merge pull request #209 from axiomhq/arne/create-referrer
Browse files Browse the repository at this point in the history
feate(js): Add referrer opt to dataset creation
  • Loading branch information
dasfmi authored Jul 12, 2024
2 parents 4746e68 + 18151fe commit 1403426
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/js/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@axiomhq/js",
"description": "The official javascript bindings for the Axiom API",
"version": "1.0.0",
"version": "1.1.0",
"author": "Axiom, Inc.",
"license": "MIT",
"contributors": [
Expand Down Expand Up @@ -52,4 +52,4 @@
"require": "./dist/cjs/index.cjs",
"default": "./dist/esm/index.js"
}
}
}
11 changes: 10 additions & 1 deletion packages/js/src/datasets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export namespace datasets {
description?: string;
}

export interface CreateOptions {
referrer?: string;
}

export interface UpdateRequest {
description: string;
}
Expand All @@ -41,7 +45,12 @@ export namespace datasets {

get = (id: string): Promise<Dataset> => this.client.get(this.localPath + '/' + id);

create = (req: CreateRequest): Promise<Dataset> => this.client.post(this.localPath, { body: JSON.stringify(req) });
create = (req: CreateRequest, opts?: CreateOptions): Promise<Dataset> => {
const params = new URLSearchParams();
params.set('referrer', opts?.referrer ?? '');
let path = `/v2/datasets?${params.toString()}`;
return this.client.post(path, { body: JSON.stringify(req) });
};

update = (id: string, req: UpdateRequest): Promise<Dataset> =>
this.client.put(this.localPath + '/' + id, { body: JSON.stringify(req) });
Expand Down
3 changes: 1 addition & 2 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
"integration": {
"dependsOn": [
"^build",
"^build:cjs",
"^test"
"^build:cjs"
]
},
"e2e": {
Expand Down

0 comments on commit 1403426

Please sign in to comment.