Skip to content

Commit

Permalink
Upstream release changes [0.14.0] (#297)
Browse files Browse the repository at this point in the history
* docs: update `code-item` to `CodeGroupItem`

Changes required for vuepressV2
upfrontjs/docs@946e50d

* chore(deps-dev): update eslint

* docs(services): removed typo

* ci: refined api docs deployment

* Feat/0.14.0 (#296)

## Feature:
* feat(collection): add dot notation to pluck method
* feat(collection): add `shuffle` method

## Chore:
* chore: increment version
* chore: make tsc output predictable
* chore(deps-dev): update dependencies

## Refactor:
* refactor(helpers): split out functions into files
  * This will help with maintainability and with tree-shaking when packaging separately for cjs.
* refactor: import helper methods from their respective path

## Testing:
* test: fix timestamp
* test(api-calls): removed some casting
  * The values can already be inferred from the code
* test(helpers): fix node@16 fringe testing error
  * Potentially issue due to different architecture on the runner.
  * https://github.com/upfrontjs/framework/actions/runs/3118093610/jobs/5057158718#step:5:59
* test(helpers): use real timers where possible
* test(helpers): clarified comment
  • Loading branch information
nandi95 authored Sep 24, 2022
1 parent d33649a commit 50bf5b2
Show file tree
Hide file tree
Showing 68 changed files with 1,209 additions and 1,050 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/deploy-api-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@ jobs:
run: |
git config --global user.email "[email protected]"
git config --global user.name "Nandor Kraszlan"
rm -rf types/
cp -r ./api-docs/* ./
git add -f assets
git add -f classes
git add -f interfaces
git add -f functions
git add -f types
touch .nojekyll
git add -f .nojekyll
git add -f index.html
git add -f modules.html
git commit -m "Updates from ${{ github.ref }} - {{ github.sha }}" --no-verify
git fetch
git switch gh-pages
git branch -r
git push gh-pages
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# compiled output
api-docs
index.*.js*
array.*.js*
string.*.js*
index.*.*js*
array.*.*js*
string.*.*js*
types
*.tgz

# in case gh-pages manually managed
index.html
modules.html
interfaces/
classes/
assets/
functions/
.nojekyll

# testing
Expand Down
139 changes: 75 additions & 64 deletions docs/.vuepress/links.js → docs/.vuepress/links.ts
Original file line number Diff line number Diff line change
@@ -1,64 +1,75 @@
const sidebar = [
{
title: 'Prologue',
children: [
'/prologue/contributing',
'/prologue/project-policies'
]
},
{
title: 'Getting Started',
path: '/getting-started/',
children: [
'/getting-started/installation'
]
},
{
title: 'Calliope',
path: '/calliope/',
children: [
'/calliope/attributes',
'/calliope/api-calls',
'/calliope/query-building',
'/calliope/relationships',
'/calliope/timestamps',
'/calliope/model-collection'
]
},
{
title: 'Services',
path: '/services/',
children: [
'/services/api',
'/services/api-response-handler'
]
},
{
title: 'Helpers',
path: '/helpers/',
children: [
'/helpers/collection',
'/helpers/pagination',
'/helpers/global-config',
'/helpers/event-emitter'
]
},
{
title: 'Cookbook',
path: '/cookbook'
},
{
title: 'Testing',
path: '/testing',
children: [
'/testing/factories'
]
},
]

module.exports = {
sidebar,
nav: [
{ text: 'API', link: 'https://upfrontjs.github.io/framework', target:'_blank' }
]
}
import { SidebarConfig } from "vuepress";
import { NavbarConfig } from "@vuepress/theme-default/lib/shared/nav";

const sidebar: SidebarConfig = [
{
text: 'Prologue',
collapsible: true,
children: [
'/prologue/contributing',
'/prologue/project-policies'
]
},
{
text: 'Getting Started',
collapsible: true,
children: [
'/getting-started/',
'/getting-started/installation'
]
},
{
text: 'Calliope',
collapsible: true,
children: [
'/calliope/',
'/calliope/attributes',
'/calliope/api-calls',
'/calliope/query-building',
'/calliope/relationships',
'/calliope/timestamps',
'/calliope/model-collection'
]
},
{
text: 'Services',
collapsible: true,
children: [
'/services/',
'/services/api',
'/services/api-response-handler'
]
},
{
text: 'Helpers',
collapsible: true,
children: [
'/helpers/',
'/helpers/collection',
'/helpers/pagination',
'/helpers/global-config',
'/helpers/event-emitter'
]
},
{
text: 'Testing',
collapsible: true,
children: [
'/testing/',
'/testing/factories'
]
},
{
text: 'Cookbook',
link: '/cookbook'
},
]

const navbar: NavbarConfig = [
{ text: 'API', link: 'https://upfrontjs.github.io/framework', target:'_blank' }
]

export default {
sidebar,
navbar
}
36 changes: 18 additions & 18 deletions docs/calliope/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Models have been given powerful tools to manage data without involved logic and
Casting transforms values when accessing or setting attributes on a model.
To define the casters on your model you should define a getter for the `casts` property.

<code-group>
<code-block title="Javascript">
<CodeGroup>
<CodeGroupItem title="Javascript">
```js
// User.js
import { Model } from '@upfrontjs/framework';
Expand All @@ -27,9 +27,9 @@ export default class User extends Model {
}
}
```
</code-block>
</CodeGroupItem>

<code-block title="Typescript">
<CodeGroupItem title="Typescript">
```ts
// User.ts
import { Model } from '@upfrontjs/framework';
Expand All @@ -44,8 +44,8 @@ export default class User extends Model {
}
}
```
</code-block>
</code-group>
</CodeGroupItem>
</CodeGroup>

**The following cast types are available:**

Expand All @@ -72,8 +72,8 @@ Cast the values to the [given date time](../helpers/global-config.md#datetime) b

This is an object which implements the `AttributeCaster` type. Meaning it has a `get` and a `set` method both of which accepts a value, and an `Attributes` object (the equivalent of [getRawAttributes](#getrawattributes)) argument.

<code-group>
<code-block title="Javascript">
<CodeGroup>
<CodeGroupItem title="Javascript">
```js
// User.js
import { Model } from '@upfrontjs/framework';
Expand All @@ -93,9 +93,9 @@ export default class User extends Model {
}
}
```
</code-block>
</CodeGroupItem>

<code-block title="Typescript">
<CodeGroupItem title="Typescript">
```ts
// User.ts
import { Model } from '@upfrontjs/framework';
Expand All @@ -116,8 +116,8 @@ export default class User extends Model {
}
}
```
</code-block>
</code-group>
</CodeGroupItem>
</CodeGroup>

### Further casting methods

Expand Down Expand Up @@ -328,8 +328,8 @@ user.fullName; // 'Dr. John Doe'

While some prefer to name their variables and object keys as [camelCase](../helpers/readme.md#camel) others will prefer [snake_case](../helpers/readme.md#snake) or perhaps there are different conventions between the front and back end. To accommodate such preferences you can set the `attributeCasing` getter to return either `'camel'` or `'snake'` like so:

<code-group>
<code-block title="Javascript">
<CodeGroup>
<CodeGroupItem title="Javascript">

```js
// User.js
Expand All @@ -341,9 +341,9 @@ export default class User extends Model {
}
}
```
</code-block>
</CodeGroupItem>

<code-block title="Typescript">
<CodeGroupItem title="Typescript">

```ts
// User.ts
Expand All @@ -355,8 +355,8 @@ export default class User extends Model {
}
}
```
</code-block>
</code-group>
</CodeGroupItem>
</CodeGroup>

When using mass-assignment like the [create](./readme.md#create) and the [fill](#fill) methods, all keys of the given arguments will automatically and recursively transform to the set casing. e.g.: `user.fill({ some_value: 1 }).someValue; // 1`
The default value is `'camel'`. This can be counteracted by the [serverAttributeCasing](./api-calls.md#serverattributecasing) getter method when sending data to the server.
Expand Down
12 changes: 6 additions & 6 deletions docs/calliope/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ The model is at the hearth of this package. It boasts a lot of features, so they

To create a model, you should first define your model class and define the [getName](#getname) method:

<code-group>
<CodeGroup>

<code-block title="Javascript">
<CodeGroupItem title="Javascript">

```js
// User.js
Expand All @@ -26,9 +26,9 @@ export default class User extends Model {
}
}
```
</code-block>
</CodeGroupItem>

<code-block title="Typescript">
<CodeGroupItem title="Typescript">

```ts
// User.ts
Expand All @@ -40,9 +40,9 @@ export default class User extends Model {
}
}
```
</code-block>
</CodeGroupItem>

</code-group>
</CodeGroup>

Then you can call your model in various way, for example
```js
Expand Down
12 changes: 6 additions & 6 deletions docs/cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ In the documentation simple and concise examples are favoured to avoid too much
#### Extend the collections to fit your needs.
Don't be afraid of changing and overriding methods if that solves your problem. The aim is to make development a breeze.

<code-group>
<CodeGroup>

<code-block title="Javascript">
<CodeGroupItem title="Javascript">

```js
// UserCollection.js
Expand Down Expand Up @@ -52,9 +52,9 @@ if (users.areAwake().length === modelCollection.length) {
console.log('Oh no, somebody\'s not ready yet!');
}
```
</code-block>
</CodeGroupItem>

<code-block title="Typescript">
<CodeGroupItem title="Typescript">

```ts
// UserCollection.ts
Expand Down Expand Up @@ -86,9 +86,9 @@ if (users.areAwake().length === modelCollection.length) {
console.log('Oh no, somebody\'s not ready yet!');
}
```
</code-block>
</CodeGroupItem>

</code-group>
</CodeGroup>

---

Expand Down
12 changes: 6 additions & 6 deletions docs/getting-started/installation.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Installation

<code-group>
<code-block title="npm">
<CodeGroup>
<CodeGroupItem title="npm">
```shell
npm install @upfrontjs/framework
```
</code-block>
</CodeGroupItem>

<code-block title="yarn">
<CodeGroupItem title="yarn">
```shell
yarn install @upfrontjs/framework
```
</code-block>
</code-group>
</CodeGroupItem>
</CodeGroup>

The library is transpiled to ES6 (currently the lowest supported version), but if you're using [Typescript](https://www.typescriptlang.org/), you could choose to use the source `.ts` files. To do so, import files from `/src` folder as opposed to the library root.
```js
Expand Down
Loading

0 comments on commit 50bf5b2

Please sign in to comment.