@goatlab/fluent-formio 0.2.4 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,359 +1,31 @@
1
- # FLUENT
2
-
3
- A JS library that gives a readable query builder. It takes care of the heavy work for you to enjoy quering your services.
4
- Fluent works for both Local and Remote Storage/API providers
5
-
6
- ### Installing
7
-
8
- To install this package in your project, you can use the following command within your terminal.
9
-
10
- ```
11
- npm install --save fast-fluent
12
- ```
13
-
14
- # Config
15
-
16
- Fluent offers a handy configuration method that will get you up and running in seconds.
17
-
18
- ```javascript
19
- import {Fluent} from 'fast-fluent';
20
-
21
- Fluent.config(
22
- {
23
- REMOTE_CONNECTORS: [{}],
24
- LOCAL_CONNECTORS: [{}],
25
- MERGE_CONNECTORS: [{}]
26
- }
27
- );
28
- ```
29
-
30
- ## Connectors
31
- All Fluent connectors are independent libraries, so you will need to download them separetly.
32
-
33
- Here is an example of a REMOTE connector using fluent-formio
34
-
35
- ```javascript
36
- import formio from 'fluent-formio'
37
- {
38
- name: 'formio',
39
- baseUrl: 'https://ydrahgggqviwquft.form.io/',
40
- connector: formio
41
- }
42
-
43
- ```
44
- You can use as many connectors as you like. All available connectors are listed bellow.
45
-
46
- ### REMOTE
47
-
48
- Remote connectors give you access to API's or Databases, such as MongoDB, Formio
49
- | Provider | Library |
50
- | --------------- | --------------- |
51
- | Formio | fluent-formio |
52
-
53
- ### LOCAL
54
- Local connectors give you access to in Browser/Memory DB's such as LokiJs, IndexedDB, LocalStorage
55
-
56
- | Provider | Library |
57
- | --------------- | --------------- |
58
- | LockiJS | fluent-loki |
59
-
60
- ### MERGE
61
- Merge connectors will pull from both Local and Remote storage providers and will merge results
62
- to give you access to all your data from one call
63
-
64
- | Provider | Library |
65
- | --------------- | --------------- |
66
- | Loki-Formio | fluent-loki-formio |
67
-
68
- ### Your first Model
69
-
70
- To start using Fluent your will need to create a Fluent Model.
71
- Every Fluent Model is a @stampit, so you can further compose it as you like.
72
- If you only defined one connector it will be used as default, so no need to configure your models
73
-
74
- ```javascript
75
- const Mymodel = Fluent.model({
76
- properties: {
77
- name: 'Mymodel',
78
- }
79
- })
80
- ```
81
-
82
- In case you defined multiple connectors, your model will need to choose where to get its data from
83
-
84
- ```javascript
85
- const Mymodel = Fluent.model({
86
- properties: {
87
- name: 'Mymodel',
88
- config: {
89
- remote: {
90
- connector: 'formio'
91
- },
92
- local: {
93
- connector: 'loki'
94
- }
95
- }
96
- }
97
- })
98
- ```
99
-
100
-
101
- Onother way of defining a connector as default when using multiple connectors, is to set it on the Fluent.config
102
-
103
- ```javascript
104
- import {Fluent} from 'fast-fluent';
105
- import formio from 'fluent-formio'
106
-
107
- Fluent.config(
108
- {
109
- REMOTE_CONNECTORS: [{
110
- default: true,
111
- name: 'formio',
112
- baseUrl: 'https://ydrahgggqviwquft.form.io/',
113
- connector: formio
114
- }, {...}, {...}],
115
- }
116
- );
117
-
118
-
119
- ```
120
-
121
- # Using a Fluent Model
122
-
123
- ## Remote, Local or Merge?
124
-
125
- Every Fluent Model can pull/push data from those 3 sources. All Fluent methods are ASYNC functions
126
- be patient and AWAIT for them ;)
127
-
128
- ```javascript
129
- const Mymodel = Fluent.model({
130
- properties: {
131
- name: 'Mymodel',
132
- }
133
- })()
134
-
135
- // Option 1
136
- let model = await Mymodel.remote()
137
- // Option 2
138
- let model = await Mymodel.local()
139
- // Option 3
140
- let model = await Mymodel.merge()
141
- ```
142
-
143
- After deciding where to pull/push the data from you will have access to quite a few helpful methods
144
-
145
- ## Basic CRUD methods
146
-
147
- ### Creating
148
- ```javascript
149
- const Mymodel = Fluent.model({
150
- properties: {
151
- name: 'Mymodel',
152
- }
153
- })()
154
- const myObj = { foo : "bar", pin: "pon"}
155
- const myArrayOfObjs = [{ foo : "bar", pin: "pon"}, { foo : "bar", pin: "pon"}]
156
- // Single insert example
157
- let inserted = await Mymodel.remote().insert(myObj)
158
-
159
- // Multiple insert example
160
- let inserted = await Mymodel.remote().insert(myArrayOfObjs)
161
-
162
- ```
163
-
164
- ### Updating
165
- All Fluent models identify records by de _id identifier. To update a record you MUST give it the _id
166
-
167
- ```javascript
168
- const Mymodel = Fluent.model({
169
- properties: {
170
- name: 'Mymodel',
171
- }
172
- })()
173
- // Single insert example
174
- let updated = await Mymodel.remote().update({_id : 'abcdefghjklmnopqrsuvwxyz', myNewData: 'SomeNewData' })
175
- ```
176
-
177
- ### Deleting
178
- To remove a records you must provide its ID
179
-
180
- ```javascript
181
- const Mymodel = Fluent.model({
182
- properties: {
183
- name: 'Mymodel',
184
- }
185
- })()
186
- // Single insert example
187
- let updated = await Mymodel.remote().remove('abcdefghjklmnopqrsuvwxyz')
188
- ```
189
-
190
- # Reading - Query Builder
191
-
192
- Here is where we start having fun with Fluent.
193
- Fluent offers a powerful QueryBuilder HEAVILY inspired in Laravel (Thanks Taylor Otwell!!)
194
-
195
- ## Get all Objects (rows)
196
- ```javascript
197
- const Users = Fluent.model({
198
- properties: {
199
- name: 'Users',
200
- }
201
- })()
202
- // Single insert example
203
- let users = await Users.remote().get()
204
- ```
205
- Unlike Laravel, Fluent get() Method returns and Array with the requested Objects, ready for you to use.
206
-
207
- ```javascript
208
- users.forEach(user => console.log(user.name))
209
- ```
210
-
211
- ## Get a single Object (row)
212
-
213
- ```javascript
214
- const Users = Fluent.model({
215
- properties: {
216
- name: 'Users',
217
- }
218
- })()
219
- // Single insert example
220
- let user = await Users.remote().first()
221
- ```
222
-
223
- In this case Fluent will return a single Object
224
-
225
- ```javascript
226
- user.name
227
- ```
228
-
229
-
230
- ## Get a list of Column Values
231
- ```javascript
232
- const Users = Fluent.model({
233
- properties: {
234
- name: 'Users',
235
- }
236
- })()
237
- // Single insert example
238
- let names = await Users.remote().pluck('name')
239
- ```
240
-
241
-
242
- ## Select
243
-
244
- ```javascript
245
- const Users = Fluent.model({
246
- properties: {
247
- name: 'Users',
248
- }
249
- })()
250
- // Single insert example
251
- let users = await Users.remote().select('name', 'last_name as lastName').get()
252
-
253
- // Its also possible to pass it as an Array
254
- let users = await Users.remote().select(['name', 'last_name as lastName']).get()
255
- ```
256
-
257
- ## Ordering, Grouping, Limit & Offset
258
-
259
- ### orderBy
260
-
261
- ```javascript
262
- const Users = Fluent.model({
263
- properties: {
264
- name: 'Users',
265
- }
266
- })()
267
- // Single insert example
268
- let users = await Users.remote().select('name', 'last_name as lastName').orderBy('lastName', 'asc')get()
269
-
270
- ```
271
-
272
-
273
- ### skip / take
274
-
275
- ```javascript
276
- const Users = Fluent.model({
277
- properties: {
278
- name: 'Users',
279
- }
280
- })()
281
- // Single insert example
282
- let users = await Users.remote().select('name')
283
- .skip(10)
284
- .take(10)
285
- .get()
286
- ```
287
- Is the same as
288
-
289
- ```javascript
290
- const Users = Fluent.model({
291
- properties: {
292
- name: 'Users',
293
- }
294
- })()
295
- // Single insert example
296
- let users = await Users.remote().select('name')
297
- .offset(10)
298
- .limit(10)
299
- .get()
300
- ```
301
-
302
-
303
- # Collections
304
-
305
- To further operate your data, you can turn your results into Collections (Yes, Thanks again Taylor!)
306
- Just make sure to call the collect method instead of the get()
307
- ```javascript
308
- const Users = Fluent.model({
309
- properties: {
310
- name: 'Users',
311
- }
312
- })()
313
- // Single insert example
314
- let users = await Users.remote()
315
- .limit(10)
316
- .collect()
317
- ```
318
- You can also turn any array into a Fluent Collection by using the collect method
319
-
320
- ```javascript
321
- let users = [{name: 'John', age: 20}, {name: 'Michael', age: 40}]
322
- // Single insert example
323
- let users = Fluent.collect(users)
324
- ```
325
-
326
- Now with the collection on hand, you can use the following operators
327
-
328
- ## average
329
- Alias for avg()
330
- ```javascript
331
- users.average('age')
332
-
333
- // 30
334
- ```
335
-
336
- ## avg
337
- ```javascript
338
- users.avg('age')
339
-
340
- // 30
341
- ```
342
-
343
- ## Chunk
344
- Chunk will just get all results and then separate them in smaller Arrays.
345
-
346
- ```javascript
347
- users.chunk(1)
348
-
349
- // [[{name: 'John', age: 20}],[{name: 'Michael', age: 40}]]
350
- ```
351
-
352
-
353
- ## Collapse
354
-
355
- ```javascript
356
- let collection = Fluent.collect(users.chunk(1));
357
- collection.collapse()
358
- // [{name: 'John', age: 20}, {name: 'Michael', age: 40}]
359
- ```
1
+ <!-- PROJECT SHIELDS -->
2
+
3
+ [![Stargazers][stars-shield]][stars-url]
4
+ [![Issues][issues-shield]][issues-url]
5
+ [![MIT License][license-shield]][license-url]
6
+ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
7
+
8
+ <!-- PROJECT LOGO -->
9
+ <br />
10
+ <p align="center">
11
+ <a href="https://github.com/github_username/repo">
12
+ <img src="https://docs.goatlab.io/logo.png" alt="Logo" width="150" height="150">
13
+ </a>
14
+
15
+ <h3 align="center">GOAT-FLUENT</h3>
16
+
17
+ <p align="center">
18
+ Readable query Interface & API generator
19
+ <br />
20
+ <a href="https://docs.goatlab.io/#/0.5.x/fluent/fluent"><strong>Explore the docs »</strong></a>
21
+ <br />
22
+ <br />
23
+ <a href="https://codesandbox.io/s/goat-nestjs-tytmv?file=/src/main.ts">View Demo</a>
24
+ ·
25
+ <a href="https://github.com/goat-io/fluent/issues">Report Bug</a>
26
+ ·
27
+ <a href="https://github.com/goat-io/fluent/issues">Request Feature</a>
28
+ </p>
29
+ </p>
30
+
31
+ # Goat - Fluent
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Formioconnector = void 0;
4
+ const FormioConnector_1 = require("./FormioConnector");
5
+ Object.defineProperty(exports, "Formioconnector", { enumerable: true, get: function () { return FormioConnector_1.Formioconnector; } });
package/package.json CHANGED
@@ -1,73 +1,141 @@
1
1
  {
2
2
  "name": "@goatlab/fluent-formio",
3
- "version": "0.2.4",
4
- "description": "Fluent Connector for Formio submissions",
5
- "main": "lib/@goatlab/fluent-formio.min.js",
6
- "directories": {
7
- "lib": "lib",
8
- "test": "test"
3
+ "version": "0.6.3",
4
+ "description": "Readable query Interface & API generator for TS and Node",
5
+ "homepage": "https://docs.goatlab.io",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "private": false,
9
+ "publishConfig": {
10
+ "access": "public"
9
11
  },
12
+ "files": [
13
+ "./dist/**/*"
14
+ ],
10
15
  "scripts": {
11
- "build": "rm -rf lib/* && webpack --env build",
12
- "rebuild": "rm -rf node_modules && npm install && npm run build",
13
- "dev": "rm -rf lib/* && webpack --progress --colors --watch --env dev",
14
- "test": "mocha-webpack --colors --recursive -w --timeout 100000 --webpack-config test/config/webpack.config.test.js --require mock-local-storage --require test/config/setup.js --exit src/**/**/*.spec.js --exit ",
15
- "test:watch": "mocha-webpack --webpack-config webpack.config.test.js --watch --glob '*.spect.js' --recursive test"
16
- },
17
- "repository": {
18
- "type": "git",
19
- "url": "https://gitlab.com/goatlabs/goat-fluent-formio.git"
16
+ "prebuild": "rimraf dist",
17
+ "prestart": "rimraf dist",
18
+ "predev": "rimraf dist",
19
+ "test": "jest --forceExit --passWithNoTests",
20
+ "dev": "tsc --watch",
21
+ "lint": "eslint src --fix",
22
+ "format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
23
+ "update:packages": "npm-check-updates -u && yarn",
24
+ "serve": "tsc -w",
25
+ "build": "tsc",
26
+ "pack": "npm-pack-zip",
27
+ "release": "release-it patch --no-npm.publish --ci",
28
+ "release:patch": "release-it patch --no-npm.publish --ci",
29
+ "release:minor": "release-it minor --no-npm.publish --ci",
30
+ "release:major": "release-it major --no-npm.publish --ci ",
31
+ "rc": "release-it --no-npm.publish --ci --preRelease=rc",
32
+ "rc:patch": "release-it patch --no-npm.publish --ci --preRelease=rc",
33
+ "rc:minor": "release-it minor --no-npm.publish --ci --preRelease=rc",
34
+ "rc:major": "release-it major --no-npm.publish --ci --preRelease=rc",
35
+ "changelog": "auto-changelog --template changelog-template.hbs -p -u --commit-limit false",
36
+ "changelog-debug": "auto-changelog --template changelog-template.hbs -p --template json --output changelog-data.json"
20
37
  },
21
38
  "keywords": [
22
- "form.io",
23
- "js",
24
- "cordova",
25
- "browser"
39
+ "typescript",
40
+ "TS"
26
41
  ],
27
- "author": "Ignacio Cabrera",
42
+ "author": "ignacio.cabrera@goatlab.io",
28
43
  "license": "MIT",
29
- "bugs": {
30
- "url": "https://gitlab.com/goatlabs/goat-fluent-formio.git/issues"
44
+ "commitlint": {
45
+ "extends": [
46
+ "@commitlint/config-conventional"
47
+ ],
48
+ "rules": {
49
+ "subject-case": [
50
+ 2,
51
+ "never",
52
+ []
53
+ ]
54
+ }
55
+ },
56
+ "husky": {
57
+ "hooks": {
58
+ "pre-commit": "pretty-quick --staged && npm test",
59
+ "commit-msg": "exec < /dev/tty && git cz --hook || true && commitlint -E HUSKY_GIT_PARAMS",
60
+ "pre-push": "npm run build"
61
+ }
62
+ },
63
+ "release-it": {
64
+ "src": {
65
+ "commitMessage": "ci: CI-1 [Release] v%s"
66
+ },
67
+ "git": {
68
+ "requireBranch": "master",
69
+ "commitArgs": [
70
+ "--no-verify"
71
+ ]
72
+ },
73
+ "hooks": {
74
+ "before:init": [
75
+ "npm run build",
76
+ "npm run pack"
77
+ ],
78
+ "after:bump": "npm run changelog",
79
+ "after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
80
+ },
81
+ "github": {
82
+ "release": true,
83
+ "assets": [
84
+ "./*.zip"
85
+ ]
86
+ }
87
+ },
88
+ "auto-changelog": {
89
+ "commitLimit": false,
90
+ "unreleased": true,
91
+ "issueUrl": "https://goatlab.atlassian.net/browse/{id}",
92
+ "replaceText": {
93
+ "[Ff]eature:": "",
94
+ "[Ff]ix:": "",
95
+ "[Bb]reak:": "",
96
+ "([A-Z]+-\\d+)": "[$1](https://goatlab.atlassian.net/browse//$1) - "
97
+ },
98
+ "includeBranch": [
99
+ "master"
100
+ ]
101
+ },
102
+ "config": {
103
+ "commitizen": {
104
+ "path": "./node_modules/@digitalroute/cz-conventional-changelog-for-jira"
105
+ },
106
+ "mongodbMemoryServer": {
107
+ "version": "latest"
108
+ }
31
109
  },
32
- "homepage": "https://gitlab.com/goatlabs/goat-fluent-formio.git#readme",
33
110
  "dependencies": {
34
- "@goatlab/goat-fluent": "^0.2.4",
35
- "await-to-js": "^2.1.1",
36
- "axios": "^0.18.0",
37
- "bluebird": "^3.5.3",
38
- "jwt-decode": "^2.2.0",
39
- "moment": "^2.24.0"
111
+ "@goatlab/fluent": "^0.6.15"
40
112
  },
41
113
  "devDependencies": {
42
- "axios-mock-adapter": "^1.15.0",
43
- "babel-cli": "^6.26.0",
44
- "babel-core": "^6.26.3",
45
- "babel-eslint": "^8.2.3",
46
- "babel-loader": "^7.1.4",
47
- "babel-plugin-add-module-exports": "^0.2.1",
48
- "babel-plugin-lodash": "^3.3.4",
49
- "babel-plugin-transform-es2015-arrow-functions": "^6.22.0",
50
- "babel-preset-env": "^1.7.0",
51
- "babel-preset-stage-2": "^6.24.1",
52
- "buffer": "^5.2.1",
53
- "chai": "^4.1.2",
54
- "custom-event": "^1.0.1",
55
- "eslint": "^4.19.1",
56
- "eslint-loader": "^2.0.0",
57
- "isomorphic-fetch": "^2.2.1",
58
- "jsdom": "11.11.0",
59
- "jsdom-global": "3.0.2",
60
- "lodash-webpack-plugin": "^0.11.5",
61
- "mocha": "^5.2.0",
62
- "mocha-webpack": "^2.0.0-beta.0",
63
- "mock-local-storage": "^1.0.5",
64
- "node-fetch": "^2.2.0",
65
- "webpack": "^4.20.2",
66
- "webpack-bundle-analyzer": "^2.13.1",
67
- "webpack-cli": "^3.1.1",
68
- "webpack-node-externals": "^1.7.2",
69
- "xmlhttprequest": "^1.8.0",
70
- "yargs": "^11.0.0"
114
+ "@commitlint/cli": "^16.2.3",
115
+ "@commitlint/config-conventional": "^16.2.1",
116
+ "@commitlint/prompt-cli": "^16.2.3",
117
+ "@digitalroute/cz-conventional-changelog-for-jira": "^7.2.1",
118
+ "@types/jest": "^27.4.1",
119
+ "@types/node": "^17.0.23",
120
+ "auto-changelog": "^2.4.0",
121
+ "commitizen": "^4.2.4",
122
+ "cz-conventional-changelog": "^3.3.0",
123
+ "cz-jira-smart-commit": "^3.0.0",
124
+ "dotenv-cli": "^5.1.0",
125
+ "eslint": "^8.5.0",
126
+ "husky": "^7.0.4",
127
+ "jest": "^27.5.1",
128
+ "jest-environment-node": "^27.5.1",
129
+ "npm-pack-zip": "^1.3.0",
130
+ "prettier": "^2.6.1",
131
+ "pretty-quick": "^3.1.3",
132
+ "release-it": "^14.13.1",
133
+ "ts-jest": "^27.1.4",
134
+ "ts-node": "^10.7.0",
135
+ "turbo": "^1.1.10",
136
+ "typescript": "^4.6.3"
71
137
  },
72
- "gitHead": "143a63c3c23a55d09c2c25f547ba6a293bbbe6b9"
138
+ "engines": {
139
+ "node": ">=14.16.0"
140
+ }
73
141
  }
package/.DS_Store DELETED
Binary file
package/.babelrc DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "presets": [
3
- "env",
4
- "stage-2"
5
- ],
6
- "plugins": [
7
- "transform-es2015-arrow-functions"
8
- ]
9
- }
package/.eslintignore DELETED
@@ -1,2 +0,0 @@
1
- lib/*
2
- node_modules/*
package/.eslintrc.js DELETED
@@ -1,61 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- parser: "babel-eslint",
4
- parserOptions: {
5
- sourceType: "module"
6
- },
7
- env: {
8
- browser: true
9
- },
10
- // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
11
- extends: ["standard"],
12
- // required to lint *.vue files
13
- plugins: ["html", "import"],
14
- globals: {
15
- XLSC: true,
16
- XLS: true,
17
- Connection: true,
18
- universalLinks: true,
19
- LocalFileSystem: true,
20
- cordova: true,
21
- html2pdf: true,
22
- DEV: true,
23
- PROD: true,
24
- __THEME: true,
25
- sms: true,
26
- logOb: true
27
- },
28
- // add your custom rules here
29
- rules: {
30
- // allow paren-less arrow functions
31
- "arrow-parens": 0,
32
- "one-var": 0,
33
- "import/first": 0,
34
- "import/named": 2,
35
- "import/namespace": 2,
36
- "import/default": 2,
37
- "import/export": 2,
38
- // allow debugger during development
39
- "no-debugger": process.env.NODE_ENV === "production" ? 2 : 0,
40
- "no-debugger": process.env.NODE_ENV === "production" ? 2 : 0,
41
- "no-mixed-spaces-and-tabs": [0],
42
- "no-tabs": 0,
43
- skipBlankLines: 0,
44
- ignoreComments: 0,
45
- "no-unreachable": 0,
46
- "no-unused-expressions": 0,
47
- "space-before-function-paren": 0,
48
- "no-trailing-spaces": [2, { skipBlankLines: true }],
49
- indent: 0,
50
- "no-multiple-empty-lines": 0,
51
- "brace-style": 0,
52
- "no-useless-return": 0,
53
- "no-unexpected-multiline": 0,
54
- "func-call-spacing": 0,
55
- quotes: 0,
56
- semi: 0,
57
- "operator-linebreak": 0,
58
- "no-new-func": 0,
59
- "comma-dangle": 0
60
- }
61
- };