Skip to content

Commit

Permalink
Merge pull request #6 from flotiq/feature/24741-use-codegen-cli
Browse files Browse the repository at this point in the history
used codegen-cli and flotiq-setup, updated readme, updated packages, fixed eslint errors
  • Loading branch information
MaciejLabedzkiCodewave authored May 31, 2024
2 parents d6cc168 + 12646b4 commit 5ba9cc7
Show file tree
Hide file tree
Showing 115 changed files with 12,113 additions and 1,988 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: '/'
schedule:
interval: 'weekly'
44 changes: 44 additions & 0 deletions .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: PR workflow
on:
pull_request:

permissions:
pull-requests: write

jobs:
test-build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 18.x ]
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install -g flotiq-cli
- run: flotiq import . ${{ secrets.FLOTIQ_API_KEY }}
- run: yarn install
- run: yarn build
env:
FLOTIQ_API_KEY: ${{ secrets.FLOTIQ_API_KEY }}
FLOTIQ_API_URL: ${{ secrets.FLOTIQ_API_URL }}
dependabot:
needs: test-build
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Approve a PR
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
14 changes: 10 additions & 4 deletions .github/workflows/test.yml → .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
name: test-build
on: push
name: Push workflow
on:
push:
branches:
- main
schedule:
- cron: "0 8 * * 1"
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 14.x ]
node-version: [ 18.x ]
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
Expand All @@ -21,4 +27,4 @@ jobs:
- run: yarn build
env:
FLOTIQ_API_KEY: ${{ secrets.FLOTIQ_API_KEY }}
FLOTIQ_API_URL: ${{ secrets.FLOTIQ_API_URL }}
FLOTIQ_API_URL: ${{ secrets.FLOTIQ_API_URL }}
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@ yarn-debug.log*
yarn-error.log*

# local env files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
.env*
!.env.dist

# vercel
.vercel
48 changes: 36 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<img src="https://editor.flotiq.com/fonts/fq-logo.svg" alt="Flotiq logo" title="Flotiq" align="right" height="60" />
</a>

Next JS starter boilerplate with Flotiq source
Next.js starter boilerplate with Flotiq source
===========================

Kick off your project with this hello-world boilerplate. This starter ships with the main Next JS configuration files you might need to get up and running blazing fast with the blazing fast app generator for React.
Expand All @@ -28,17 +28,16 @@ Check out live demo: [https://flotiq-nextjs-boilerplate.netlify.app](https://flo

The next step is to configure our application to know from where it has to fetch the data.

Copy `.env.dist` as `.env.local`
Flotiq provides a tool for automatically populating `.env` files with your Flotiq API keys.

```bash
cp .env.dist .env.local
npx flotiq-setup
```

and add api key:

```
FLOTIQ_API_KEY=YOUR FLOTIQ API KEY
```
After executing this command, a browser window will open with the Flotiq login screen. Upon successful authentication,
the command will automatically generate appropriately filled .env files for you.

_Note: If there are existing .env files in the project, flotiq-setup may overwrite them._

4. **Install dependencies**

Expand All @@ -47,25 +46,50 @@ Check out live demo: [https://flotiq-nextjs-boilerplate.netlify.app](https://flo
```bash
yarn install
```

5. **Start developing.**

5. **Flotiq codegen**

This package simplifies Typescript Fetch API integration for your Flotiq project, tailored to your Flotiq account
data. To build your customized API package, just run this command:

```bash
npx flotiq-codegen-ts generate --compiled-js
```

Now, in your project, you can use the `FlotiqApi` class for easy and convenient communication with the Flotiq API.

```javascript
import {FlotiqApi} from '../flotiqApi/index';
const api = new FlotiqApi(apiKey);
```

Examples of its usage can be found in the `lib/event.js` file of this project or can be explored in the
[flotiq-codegen-ts repository](https://github.com/flotiq/flotiq-codegen-ts)

_Note: If you make any changes (additions or deletions) to the `content type definitions` in your Flotiq account, you will need to rerun `npx flotiq-codegen-ts generate --compiled-js` command._

6. **Start developing.**

Navigate into your new site’s directory and start it up.

```shell
yarn dev
```

6. **Open the source code and start editing!**
7. **Open the source code and start editing!**

Your site is now running at `http://localhost:3000`!

Open the `my-hello-world-starter` directory in your code editor of choice and edit `pages/index.js`. Save your changes and the browser will update in real time!

7. **Manage your content using Flotiq editor**
8. **Manage your content using Flotiq editor**

You can now easily manage your content using [Flotiq editor](https://editor.flotiq.com)

_Note: If you are using `FlotiqApi` generated from `flotiq-codegen-ts` remember to rerun `npx flotiq-codegen-ts generate --compiled-js`
command after changes (additions or edits) to the `content type definitions` in your Flotiq_

## Deploy

Deploy this starter with one click on [Vercel](https://vercel.com/):
Expand Down
189 changes: 189 additions & 0 deletions flotiqApi/apis/ExampleAPI.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
/**
* Flotiq User API
* ## Getting started This API Documentation reflects the endpoints defined in your [Flotiq](https://flotiq.com) account. The documentation is generated using an OpenAPI schema describing the API, which can be obtained in several flavors: - [OAS 3.0](https://api.flotiq.com/api/v1/open-api-schema.json?auth_token=REPLACE_KEY_VALUE) - without hydration, will not expand relations between content types (this is the default version which provides maximum compatibility with downstream systems) - with hydration, pass [hydrate=1](https://api.flotiq.com/api/v1/open-api-schema.json?auth_token=REPLACE_KEY_VALUE&amp;hydrate=1) - use this for a better type support in exported OpenAPI schemas - without system endpoints, pass [user_only=1](https://api.flotiq.com/api/v1/open-api-schema.json?auth_token=REPLACE_KEY_VALUE&amp;hydrate=1&amp;user_only=1) - use this to only include your endpoints, without system ones - [OAS 2.0](https://api.flotiq.com/api/v1/open-api-schema.json?auth_token=REPLACE_KEY_VALUE&amp;version=2) - provided for compatibility with several older systems Check Flotiq documentation for more information about [Flotiq OpenAPI capabilities](https://flotiq.com/docs/API/open-api-schema/), instructions how to generate code and other useful tips. ### Access to data There are several methods that you can use to access your data: * Live API docs - available via &lt;code&gt;Try it out&lt;/code&gt; button available next to each endpoint * Copying example code on the right side of each endpoint * By downloading the SDKs available in mulitple languages. * By downloading the Postman collection and importing it into Postman. Each of these methods is described in length in the [user documentation](https://flotiq.com/docs/). ### Authorization In order to make use of the provided documentation, example code, SDKs and so on - you will need to pull out your API key. We recommend that you start with the ReadOnly API Key which will allow you to make all the `GET` requests but will error-out when you try to modify content. Please remember to replace the key for `POST`, `PUT` and `DELETE` calls. It&#039;s also possible to use scoped API keys - you can create those in the API keys section of the Flotiq user interface. This will allow you to create a key that only authorizes access to a specific content type (or a set of content types, if you choose so). Read more about how to use and create API keys in the [API keys documentation](https://flotiq.com/docs/API/). ## Object access Once you define a Content Type it will become available in your Content API as a set of endpoints that will allow you to work with objects: * create * list * update * delete * batch create * retrieve single object. ### Hydration When you build Content Types that have relation to others your objects will optionally support hydration of related entities. The endpoints that support object retrieval accept a `hydrate` parameter, which can be used to easily fetch hydrated objects. Since this breaks the standard REST concepts - it&#039;s not enabled by default, but it&#039;s a very handy feature that allows to reduce the amount of HTTP requests sent over the wire and we strongly recommend to use it.
*
* The version of the OpenAPI document: 2.0.1
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import * as runtime from '../runtime';
import type { BatchResponseSuccess, Example, ExampleBatchDelete200Response, ExampleList, ExampleVersionsList, ExampleWithoutInternal, ExampleWithoutRequired } from '../models/index';
export interface ExampleAPIDeleteRequest {
id: string;
}
export interface ExampleAPIBatchCreateRequest {
updateExisting?: boolean;
ExampleWithoutInternal?: Array<ExampleWithoutInternal>;
}
export interface ExampleAPIBatchDeleteRequest {
request_body?: Array<string>;
}
export interface ExampleAPIBatchPatchRequest {
ExampleWithoutInternal?: Array<ExampleWithoutInternal>;
}
export interface ExampleAPICreateRequest {
ExampleWithoutInternal?: ExampleWithoutInternal;
}
export interface ExampleAPIGetRequest {
id: string;
hydrate?: number;
}
export interface ExampleAPIGetRemovedRequest {
deletedAfter?: string;
}
export interface ExampleAPIGetVersionsRequest {
id: string;
versionId: string;
}
export interface ExampleAPIListRequest {
page?: number;
limit?: number;
order_by?: string;
order_direction?: string;
hydrate?: number;
filters?: string;
ids?: Array<string>;
}
export interface ExampleAPIListVersionRequest {
id: string;
page?: number;
limit?: number;
order_by?: string;
order_direction?: string;
}
export interface ExampleAPIPatchRequest {
id: string;
ExampleWithoutRequired?: ExampleWithoutRequired;
}
export interface ExampleAPIUpdateRequest {
id: string;
ExampleWithoutInternal?: ExampleWithoutInternal;
}
/**
*
*/
export declare class ExampleAPI extends runtime.BaseAPI {
/**
* Removes Example object.<br />
* Delete a Example object
*/
_deleteRaw(requestParameters: ExampleAPIDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>>;
/**
* Removes Example object.<br />
* Delete a Example object
*/
_delete(requestParameters: ExampleAPIDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void>;
/**
* Allows you to create or create and update up to 100 objects of Example type. <br />
* Create a batch of example objects
*/
batchCreateRaw(requestParameters: ExampleAPIBatchCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<BatchResponseSuccess>>;
/**
* Allows you to create or create and update up to 100 objects of Example type. <br />
* Create a batch of example objects
*/
batchCreate(requestParameters?: ExampleAPIBatchCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<BatchResponseSuccess>;
/**
* Allows you to delete up to 100 objects of Example type. <br />Request body accepts an array of content object IDs that are to be deleted.<br />
* Delete a batch of Example objects
*/
batchDeleteRaw(requestParameters: ExampleAPIBatchDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ExampleBatchDelete200Response>>;
/**
* Allows you to delete up to 100 objects of Example type. <br />Request body accepts an array of content object IDs that are to be deleted.<br />
* Delete a batch of Example objects
*/
batchDelete(requestParameters?: ExampleAPIBatchDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ExampleBatchDelete200Response>;
/**
* Allows you to update up to 100 objects of Example type. <br />
* Update selected fields of a batch of objects
*/
batchPatchRaw(requestParameters: ExampleAPIBatchPatchRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<BatchResponseSuccess>>;
/**
* Allows you to update up to 100 objects of Example type. <br />
* Update selected fields of a batch of objects
*/
batchPatch(requestParameters?: ExampleAPIBatchPatchRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<BatchResponseSuccess>;
/**
* Allows you to create object of Example type. <br />
* Create a Example object
*/
createRaw(requestParameters: ExampleAPICreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Example>>;
/**
* Allows you to create object of Example type. <br />
* Create a Example object
*/
create(requestParameters?: ExampleAPICreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Example>;
/**
* Returns all information about Example object. <br />
* Get Example object by Id
*/
getRaw(requestParameters: ExampleAPIGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Example>>;
/**
* Returns all information about Example object. <br />
* Get Example object by Id
*/
get(requestParameters: ExampleAPIGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Example>;
/**
* Get ids of removed Example objects. <br />
* Get removed object identifiers
*/
getRemovedRaw(requestParameters: ExampleAPIGetRemovedRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<string>>>;
/**
* Get ids of removed Example objects. <br />
* Get removed object identifiers
*/
getRemoved(requestParameters?: ExampleAPIGetRemovedRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<string>>;
/**
* Return version of Example object. <br />
* Get a specific version of Example object
*/
getVersionsRaw(requestParameters: ExampleAPIGetVersionsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Example>>;
/**
* Return version of Example object. <br />
* Get a specific version of Example object
*/
getVersions(requestParameters: ExampleAPIGetVersionsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Example>;
/**
* List objects of Example type. <br />
* List Example objects
*/
listRaw(requestParameters: ExampleAPIListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ExampleList>>;
/**
* List objects of Example type. <br />
* List Example objects
*/
list(requestParameters?: ExampleAPIListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ExampleList>;
/**
* List objects versions of Example type. <br />
* List all versions of a Example object
*/
listVersionRaw(requestParameters: ExampleAPIListVersionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ExampleVersionsList>>;
/**
* List objects versions of Example type. <br />
* List all versions of a Example object
*/
listVersion(requestParameters: ExampleAPIListVersionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ExampleVersionsList>;
/**
* Allows update of the Example object, but it is unnecessary to specify all the object\'s properties. Properties not included in the payload will be completed with data from the database. <br />
* Update selected fields of Example object
*/
patchRaw(requestParameters: ExampleAPIPatchRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Example>>;
/**
* Allows update of the Example object, but it is unnecessary to specify all the object\'s properties. Properties not included in the payload will be completed with data from the database. <br />
* Update selected fields of Example object
*/
patch(requestParameters: ExampleAPIPatchRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Example>;
/**
* Allows update of the Example object, it has to have all fields, as this operation overwrites the object. All properties not included in the payload will be lost. <br />
* Update existing Example object
*/
updateRaw(requestParameters: ExampleAPIUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Example>>;
/**
* Allows update of the Example object, it has to have all fields, as this operation overwrites the object. All properties not included in the payload will be lost. <br />
* Update existing Example object
*/
update(requestParameters: ExampleAPIUpdateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Example>;
}
Loading

0 comments on commit 5ba9cc7

Please sign in to comment.