@pbvision/firestore-orm 0.0.2
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/LICENSE +204 -0
- package/README.md +860 -0
- package/environment.js +2 -0
- package/package.json +81 -0
- package/requirements.txt +1 -0
- package/scripts/ci/lint-format-js.sh +13 -0
- package/scripts/ci/markdown-link.sh +8 -0
- package/scripts/start-local-db.sh +2 -0
- package/src/async-emitter.js +50 -0
- package/src/context.js +677 -0
- package/src/data.js +24 -0
- package/src/db-error.js +12 -0
- package/src/default-db.js +21 -0
- package/src/errors.js +149 -0
- package/src/fields.js +526 -0
- package/src/firestore.js +75 -0
- package/src/key.js +66 -0
- package/src/models.js +542 -0
- package/src/utils.js +75 -0
package/environment.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pbvision/firestore-orm",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Firestore ORM Library",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"main": "src/default-db.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build-doc": "./docs/build.sh",
|
|
9
|
+
"check-markdown-link": "./scripts/ci/markdown-link.sh",
|
|
10
|
+
"debug": "yarn start-local-db; ./node_modules/nodemon/bin/nodemon.js --no-lazy --legacy-watch --watch ./src --watch ./example --watch ./test --inspect=9229 ./node_modules/jest/bin/jest.js --coverage --config=./jest.config.json --runInBand",
|
|
11
|
+
"lint": "./scripts/ci/lint-format-js.sh",
|
|
12
|
+
"restart-local-db": "./scripts/start-local-db.sh --force-recreate",
|
|
13
|
+
"setup": "yarn install --frozen-lockfile && pip install -r requirements.txt",
|
|
14
|
+
"start-local-db": "./scripts/start-local-db.sh",
|
|
15
|
+
"test": "./node_modules/jest/bin/jest.js --coverage --config=./jest.config.json"
|
|
16
|
+
},
|
|
17
|
+
"contributors": [
|
|
18
|
+
"Yu Guan",
|
|
19
|
+
"David Underhill",
|
|
20
|
+
"Solaman Huq",
|
|
21
|
+
"Shimul Bhowmik",
|
|
22
|
+
"Biru Lyu"
|
|
23
|
+
],
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/pbv-public/firestore-orm.git"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"registry": "https://registry.npmjs.org"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"environment.js",
|
|
33
|
+
"requirements.txt",
|
|
34
|
+
"scripts/**",
|
|
35
|
+
"src/**"
|
|
36
|
+
],
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@google-cloud/firestore": "^7.1.0",
|
|
39
|
+
"deep-object-diff": "^1.1.7",
|
|
40
|
+
"fast-deep-equal": "^3.1.3",
|
|
41
|
+
"fast-json-stable-stringify": "^2.1.0",
|
|
42
|
+
"rfdc": "^1.1.4",
|
|
43
|
+
"uuid": "^8.3.2"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@pbvision/schema": "^0.1.4"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@babel/core": "^7.17.12",
|
|
50
|
+
"@babel/eslint-parser": "^7.17.0",
|
|
51
|
+
"@babel/preset-env": "^7.17.12",
|
|
52
|
+
"@pbvision/schema": "^0.1.4",
|
|
53
|
+
"@pbvision/jest-unit-test": "^0.2.0",
|
|
54
|
+
"eslint": "^8.22.0",
|
|
55
|
+
"eslint-config-standard": "15.0.0",
|
|
56
|
+
"eslint-plugin-import": "^2.22.0",
|
|
57
|
+
"eslint-plugin-node": "^11.1.0",
|
|
58
|
+
"eslint-plugin-promise": "^6.0.0",
|
|
59
|
+
"eslint-plugin-standard": "^4.0.1",
|
|
60
|
+
"jest": "^29",
|
|
61
|
+
"jsdoc": "3.6.4",
|
|
62
|
+
"nodemon": "^2.0.20",
|
|
63
|
+
"remark-cli": "^9.0.0",
|
|
64
|
+
"remark-validate-links": "^10.0.2",
|
|
65
|
+
"snazzy": "^8.0.0",
|
|
66
|
+
"standard": "^15.0.0",
|
|
67
|
+
"tui-jsdoc-template": "^1.2.2"
|
|
68
|
+
},
|
|
69
|
+
"standard": {
|
|
70
|
+
"envs": [
|
|
71
|
+
"jest"
|
|
72
|
+
],
|
|
73
|
+
"globals": [
|
|
74
|
+
"fail"
|
|
75
|
+
],
|
|
76
|
+
"ignore": [
|
|
77
|
+
"**/node_modules/**"
|
|
78
|
+
],
|
|
79
|
+
"parser": "@babel/eslint-parser"
|
|
80
|
+
}
|
|
81
|
+
}
|
package/requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
embed-markdown
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -o errexit
|
|
3
|
+
set -o nounset
|
|
4
|
+
|
|
5
|
+
cd "`dirname \"$0\"`"
|
|
6
|
+
cd ../..
|
|
7
|
+
|
|
8
|
+
files=`find . -name '*.js' -not -path '*node_modules*' -not -path '*generated*'`
|
|
9
|
+
|
|
10
|
+
echo -e Running standard at `date` ...
|
|
11
|
+
node_modules/standard/bin/cmd.js --verbose $files | node_modules/snazzy/bin/cmd.js
|
|
12
|
+
echo -e Running eslint at `date` ...
|
|
13
|
+
node_modules/eslint/bin/eslint.js $files
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const uuidv4 = require('uuid').v4
|
|
2
|
+
|
|
3
|
+
class AsyncEmitter {
|
|
4
|
+
constructor () {
|
|
5
|
+
this.handlers = {}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
__addHandler (event, handler, handlerName = uuidv4()) {
|
|
9
|
+
const handlers = this.handlers[event] || {}
|
|
10
|
+
this.handlers[event] = handlers
|
|
11
|
+
if (handlers[handlerName]) {
|
|
12
|
+
throw new Error(
|
|
13
|
+
`Handler with the same name ${handlerName} already exists`)
|
|
14
|
+
}
|
|
15
|
+
handlers[handlerName] = handler
|
|
16
|
+
return handlerName
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
removeHandler (event, handlerName) {
|
|
20
|
+
const handlers = this.handlers[event] || {}
|
|
21
|
+
delete handlers[handlerName]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
once (event, handler, handlerName = undefined) {
|
|
25
|
+
return this.__addHandler(event, {
|
|
26
|
+
handler,
|
|
27
|
+
once: true
|
|
28
|
+
}, handlerName)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
on (event, handler, handlerName = undefined) {
|
|
32
|
+
return this.__addHandler(event, {
|
|
33
|
+
handler,
|
|
34
|
+
once: false
|
|
35
|
+
}, handlerName)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async emit (event, ...args) {
|
|
39
|
+
const entries = Object.entries(this.handlers[event] || {})
|
|
40
|
+
for (const [handlerName, handlerData] of entries) {
|
|
41
|
+
const { handler, once } = handlerData
|
|
42
|
+
if (once) {
|
|
43
|
+
this.removeHandler(event, handlerName)
|
|
44
|
+
}
|
|
45
|
+
await handler(...args)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module.exports = AsyncEmitter
|