Skip to content

Commit

Permalink
Better exports
Browse files Browse the repository at this point in the history
  • Loading branch information
j3lte committed Dec 8, 2023
1 parent b66d6d7 commit 685eea5
Show file tree
Hide file tree
Showing 73 changed files with 8,354 additions and 6,202 deletions.
17 changes: 3 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Node:
## Usage

```typescript

import {
KentekenVoertuigen,
KentekenVoertuigenAssen,
Expand All @@ -41,18 +40,11 @@ import {
} from "https://deno.land/x/rdw_data/mod.ts";

/*
* Example: search for a license plate and combine the results
*/
* Example: search for a license plate and combine the results
*/
const search = (
kenteken: string,
): Promise<
& KentekenVoertuigen.ResponseData
& KentekenVoertuigenAssen.ResponseData
& KentekenVoertuigenBrandstof.ResponseData
& KentekenVoertuigenCarrosserie.ResponseData
& KentekenVoertuigenCarrosserieSpecificatie.ResponseData
& KentekenVoertuigenVoertuigklasse.ResponseData
> =>
) =>
Promise.all([
KentekenVoertuigen.RDWQuery().where(
Where.like(KentekenVoertuigen.Fields.Kenteken, kenteken),
Expand Down Expand Up @@ -91,16 +83,13 @@ const combined = await search("XXXXX");

console.log(data.count);
console.log(combined);

```

<!-- START FUNCTIONS -->
## API

These are auto generated providers and use `[email protected]`.

An overview can be found [here](https://deno.land/x/rdw_data/src/providers/mod.ts)

### Overview

| Provider | Name | Category |
Expand Down
52 changes: 26 additions & 26 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
{
"tasks": {
"fetch": "deno run -A scripts/fetch-databases.ts",
"format": "deno fmt",
"lint": "deno lint ./src/",
"fetch-data": "deno run -A scripts/fetch-databases.ts && deno fmt -q ./src/providers && deno lint",
"npm": "deno run -A ./scripts/build-npm.ts"
"tasks": {
"fetch": "deno run -A scripts/fetch-databases.ts",
"format": "deno fmt",
"lint": "deno lint ./src/",
"fetch-data": "deno run -A scripts/fetch-databases.ts && deno fmt -q ./src/providers && deno lint",
"npm": "deno run -A ./scripts/build-npm.ts"
},
"fmt": {
"options": {
"indentWidth": 2,
"lineWidth": 100,
"singleQuote": false,
"useTabs": false,
"proseWrap": "preserve"
},
"fmt": {
"options": {
"indentWidth": 2,
"lineWidth": 100,
"singleQuote": false,
"useTabs": false,
"proseWrap": "preserve"
},
"exclude": []
"exclude": []
},
"lint": {
"rules": {
"include": [
"ban-untagged-todo",
"explicit-function-return-type"
]
},
"lint": {
"rules": {
"include": [
"ban-untagged-todo",
"explicit-function-return-type"
]
},
"exclude": [
"npm/"
]
}
"exclude": [
"npm/"
]
}
}
3 changes: 2 additions & 1 deletion scripts/templates/mod.ts.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export {
Where,
} from "https://deno.land/x/soda@<%= it.sodaVersion %>/mod.ts";
<% it.items.forEach(function (item) { %>
export * as <%= item.name %> from "./<%= item.name %>.ts";<% }); %>
export { <%= item.name %> } from "./<%= item.name %>.ts";
export type { <%= item.name %>_ResponseData } from "./<%= item.name %>.ts";<% }); %>
49 changes: 34 additions & 15 deletions scripts/templates/provider.ts.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
//
// *******************************************************
import type { AuthOpts, FieldObject, Options } from "https://deno.land/x/soda@<%= it.item.sodaVersion %>/mod.ts";
import type { AuthOpts, Options } from "https://deno.land/x/soda@<%= it.item.sodaVersion %>/mod.ts";
import { createQueryWithDataset, DataType, Field } from "https://deno.land/x/soda@<%= it.item.sodaVersion %>/mod.ts";
/**
* Return Data for <%= it.item.full_name %>
*/
export interface ResponseData {<% it.item.columns.forEach(function(column) { %>
export interface <%= it.item.name %>_ResponseData {<% it.item.columns.forEach(function(column) { %>
/**
* ### <%= column.name %>
*
Expand All @@ -43,19 +43,17 @@ export interface ResponseData {<% it.item.columns.forEach(function(column) { %>
*
* > You can use these fieldnames in your queries to filter, group, or sort your data.
*/
export interface IFields {<% it.item.columns.forEach(function(column) { %>
export const Fields = {<% it.item.columns.forEach(function(column) { %>
/**
* ### <%= column.name %>
*
* <% column.description.forEach(function(line) { %>
* <%= line %><% }); %>
*
* **Type**: <%= column.datatype %>
*/
<%= column.big_name %>: FieldObject<<%= column.datatypeTemplate %>>;<% }); %>
};
export const Fields: IFields = {<% it.item.columns.forEach(function(column) { %>
* ### <%= column.name %>
*
* <% column.description.forEach(function(line) { %>
* <%= line %><% }); %>
*
* **Type**: <%= column.datatype %>
*
* **Database Column Name**: `<%= column.field_name %>`
*/
<%= column.big_name %>: Field("<%= column.field_name %>", <%= column.datatypeTemplate %>),<% }); %>
};
Expand All @@ -82,9 +80,30 @@ export const Info = {
* **Dataset ID:** <%= it.item.id %>
*
* **Category:** <%= it.item.category %>
*
* -----------------------
* This generates a SodaQuery for the <%= it.item.full_name %> dataset.
*
* @param auth - Authentification options
* @param opts - Query options
*
* @example
* ```ts
* const data = await RDWQuery()
* .where(Where.like(Fields.<%= it.item.columns[0].big_name %>, "some_value")
* .limit(10)
* .offset(0);
* .execute();
* ```
*/
export const RDWQuery = (auth: AuthOpts = {}, opts: Options = {}) =>
createQueryWithDataset<ResponseData>(Info.domain, Info.dataset, auth, {
createQueryWithDataset<<%= it.item.name %>_ResponseData>(Info.domain, Info.dataset, auth, {
...opts,
strict: typeof opts.strict === "boolean" ? opts.strict : true,
});
export const <%= it.item.name %> = {
RDWQuery,
Fields: Fields,
Info: Info,
};
Loading

0 comments on commit 685eea5

Please sign in to comment.