uranio 0.1.4 → 0.1.7
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/.uranio/src/uranio-client.ts +25 -0
- package/README.md +70 -0
- package/client/package.json +35 -0
- package/client/src/index.ts +3 -0
- package/client/tsconfig.json +33 -0
- package/dist/bin.js +1 -1
- package/dist/bin.js.map +1 -1
- package/package.json +2 -3
- package/scripts/version.sh +71 -33
- package/src/bin.ts +1 -1
- package/dot/src/uranio-client.ts +0 -25
- /package/{dot → .uranio}/package.json +0 -0
- /package/{dot → .uranio}/src/atom.ts +0 -0
- /package/{dot → .uranio}/src/client.ts +0 -0
- /package/{dot → .uranio}/src/index.ts +0 -0
- /package/{dot → .uranio}/src/log/index.ts +0 -0
- /package/{dot → .uranio}/src/query.ts +0 -0
- /package/{dot → .uranio}/src/types.ts +0 -0
- /package/{dot → .uranio}/tsconfig.json +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* UranioClient module
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {Client, ClientParams} from './client';
|
|
10
|
+
// import {Atom} from './types';
|
|
11
|
+
// import {AtomClient} from './atom';
|
|
12
|
+
|
|
13
|
+
// interface Product extends Atom {
|
|
14
|
+
// title: string;
|
|
15
|
+
// price: number;
|
|
16
|
+
// }
|
|
17
|
+
|
|
18
|
+
export class UranioClient extends Client{
|
|
19
|
+
// public product: AtomClient<Product>;
|
|
20
|
+
constructor(params: ClientParams) {
|
|
21
|
+
super(params);
|
|
22
|
+
// this.product = new AtomClient<Product>(this.db, 'product');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Uranio
|
|
2
|
+
|
|
3
|
+
Uranio is a Typescript Object Document Mapper (ODM) for MongoDB.\
|
|
4
|
+
It creates a client for querying collections in a database by just parsing
|
|
5
|
+
the types in a repository.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm install uranio
|
|
11
|
+
yarn add uranio
|
|
12
|
+
pnpm add uranio
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## How it works
|
|
16
|
+
|
|
17
|
+
Run:
|
|
18
|
+
```
|
|
19
|
+
uranio generate
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The above command search for all interfaces in your repository that extends
|
|
23
|
+
the `uranio.atom` interface.\
|
|
24
|
+
For each of these interfaces it creates a method to query a collection with a
|
|
25
|
+
name of the interface.
|
|
26
|
+
|
|
27
|
+
For example if in your code you have:
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import uranio from 'uranio';
|
|
31
|
+
|
|
32
|
+
interface Product extends uranio.atom {
|
|
33
|
+
title: string;
|
|
34
|
+
description: string;
|
|
35
|
+
price: number;
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
then Uranio generates a method for querying a collection named `products`:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import uranio from 'uranio';
|
|
43
|
+
|
|
44
|
+
const uri = process.env.MONGO_DATABASE_URI || '';
|
|
45
|
+
const db_name = process.env.MONGO_DATABASE_NAME || '';
|
|
46
|
+
|
|
47
|
+
const urn = uranio.Client({uri, db_name});
|
|
48
|
+
|
|
49
|
+
// Get all products
|
|
50
|
+
const products = await urn.products.find({});
|
|
51
|
+
|
|
52
|
+
// Create a product
|
|
53
|
+
await urn.products.insert({
|
|
54
|
+
title: 'Uranio mug',
|
|
55
|
+
description: 'A radioactive mug for your coding breakfast',
|
|
56
|
+
price: 4.99
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Uranio types
|
|
61
|
+
|
|
62
|
+
You can use uranio types to better define the schema of your collections.\
|
|
63
|
+
For example:
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
interface Customer extends uranio.atom {
|
|
67
|
+
_id: uranio.primary<string>;
|
|
68
|
+
email: uranio.unique<string>;
|
|
69
|
+
}
|
|
70
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "uranio-client",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Uranio client is an auto-generated, type-safe ODM client for MongoDB",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"repository": "git+ssh://git@github.com/x71c9/uranio.git",
|
|
8
|
+
"author": "x71c9 <108585118+x71c9@users.noreply.github.com>",
|
|
9
|
+
"license": "UNLICENSED",
|
|
10
|
+
"peerDependencies": {
|
|
11
|
+
"uranio": "*"
|
|
12
|
+
},
|
|
13
|
+
"peerDependenciesMeta": {
|
|
14
|
+
"uranio": {
|
|
15
|
+
"optional": true
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "yarn tsc -b",
|
|
21
|
+
"dev": "yarn tsc -w",
|
|
22
|
+
"link:.uranio": "ln -s ~/repos/uranio/.uranio ~/repos/uranio/uranio/packages/client/node_modules/.uranio",
|
|
23
|
+
"push:patch": "sh ./scripts/version.sh patch",
|
|
24
|
+
"push:minor": "sh ./scripts/version.sh minor",
|
|
25
|
+
"push:major": "sh ./scripts/version.sh major"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^20.9.0",
|
|
29
|
+
"typescript": "^5.2.2"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"i0n": "^0.7.3",
|
|
33
|
+
"mongodb": "^6.2.0"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"alwaysStrict": true,
|
|
4
|
+
"allowJs": true,
|
|
5
|
+
"baseUrl": ".",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"experimentalDecorators": true,
|
|
9
|
+
"incremental": false,
|
|
10
|
+
"lib": ["ESNext", "ESNext.AsyncIterable", "DOM", "ES2021"],
|
|
11
|
+
"module": "CommonJS",
|
|
12
|
+
"moduleResolution": "node",
|
|
13
|
+
"noEmit": false,
|
|
14
|
+
"noFallthroughCasesInSwitch": true,
|
|
15
|
+
"noImplicitThis": true,
|
|
16
|
+
"noImplicitAny": true,
|
|
17
|
+
"noUncheckedIndexedAccess": true,
|
|
18
|
+
"noUnusedLocals": true,
|
|
19
|
+
"noUnusedParameters": true,
|
|
20
|
+
"outDir": "./dist",
|
|
21
|
+
"rootDir": "./src",
|
|
22
|
+
"skipLibCheck": true,
|
|
23
|
+
"sourceMap": true,
|
|
24
|
+
"strict": true,
|
|
25
|
+
"strictNullChecks": true,
|
|
26
|
+
"strictFunctionTypes": true,
|
|
27
|
+
"strictPropertyInitialization": true,
|
|
28
|
+
"target": "ES2018",
|
|
29
|
+
"typeRoots": ["node_modules/@types"]
|
|
30
|
+
},
|
|
31
|
+
"include": ["src/**/*.ts"],
|
|
32
|
+
"exclude": ["node_modules"]
|
|
33
|
+
}
|
package/dist/bin.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
const i0n_1 = __importDefault(require("i0n"));
|
|
8
8
|
const log = i0n_1.default.create();
|
|
9
9
|
const index_1 = require("./generate/index");
|
|
10
|
-
const tsconfig_path = `/
|
|
10
|
+
const tsconfig_path = `/Users/x71c9/repos/uranio/builder/tsconfig.json`;
|
|
11
11
|
const response = (0, index_1.generate)(tsconfig_path);
|
|
12
12
|
log.debug(response);
|
|
13
13
|
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";;;;;;AAEA,8CAAsB;AACtB,MAAM,GAAG,GAAG,aAAG,CAAC,MAAM,EAAE,CAAC;AACzB,4CAA0C;AAC1C,MAAM,aAAa,GAAG,
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";;;;;;AAEA,8CAAsB;AACtB,MAAM,GAAG,GAAG,aAAG,CAAC,MAAM,EAAE,CAAC;AACzB,4CAA0C;AAC1C,MAAM,aAAa,GAAG,iDAAiD,CAAC;AACxE,MAAM,QAAQ,GAAG,IAAA,gBAAQ,EAAC,aAAa,CAAC,CAAC;AACzC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uranio",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Uranio is a type-safe ODM for MongoDB",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -38,8 +38,7 @@
|
|
|
38
38
|
"typescript": "^5.2.2"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"husky": "^8.0.3",
|
|
42
41
|
"i0n": "^0.7.3",
|
|
43
|
-
"plutonio": "^0.
|
|
42
|
+
"plutonio": "^0.4.1"
|
|
44
43
|
}
|
|
45
44
|
}
|
package/scripts/version.sh
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
if [[ `git status --porcelain` ]]; then
|
|
4
|
+
echo
|
|
5
|
+
echo "Error: Git working directory is not clean. Please commit your changes or stash them."
|
|
6
|
+
echo
|
|
7
|
+
exit 1
|
|
8
|
+
fi;
|
|
9
|
+
|
|
10
|
+
SEMANTIC_NAME=""
|
|
11
|
+
FORCE_FLAG=""
|
|
12
|
+
|
|
13
|
+
# Parse command line arguments
|
|
14
|
+
while [ "$#" -gt 0 ]; do
|
|
15
|
+
case "$1" in
|
|
16
|
+
--force)
|
|
17
|
+
FORCE_FLAG="--force"
|
|
18
|
+
shift
|
|
19
|
+
;;
|
|
20
|
+
*)
|
|
21
|
+
if [ -z "$SEMANTIC_NAME" ]; then
|
|
22
|
+
SEMANTIC_NAME="$1"
|
|
23
|
+
else
|
|
24
|
+
echo "Unknown argument: $1"
|
|
25
|
+
exit 1
|
|
26
|
+
fi
|
|
27
|
+
shift
|
|
28
|
+
;;
|
|
29
|
+
esac
|
|
30
|
+
done
|
|
4
31
|
|
|
5
32
|
if [ "$SEMANTIC_NAME" == "" ]; then
|
|
6
33
|
echo
|
|
@@ -10,43 +37,54 @@ if [ "$SEMANTIC_NAME" == "" ]; then
|
|
|
10
37
|
exit 1
|
|
11
38
|
fi
|
|
12
39
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
40
|
+
if [ "$FORCE_FLAG" == "--force" ]; then
|
|
41
|
+
response="y"
|
|
42
|
+
else
|
|
43
|
+
case "$SEMANTIC_NAME" in
|
|
44
|
+
patch)
|
|
45
|
+
read -p "Are you sure you want to increase the patch version? [y/n] " response
|
|
46
|
+
;;
|
|
47
|
+
minor)
|
|
48
|
+
read -p "Are you sure you want to increase the minor version? [y/n] " respnose
|
|
49
|
+
;;
|
|
50
|
+
major)
|
|
51
|
+
read -p "Are you sure you want to increase the major version? [y/n] " respnose
|
|
52
|
+
;;
|
|
53
|
+
*)
|
|
54
|
+
echo
|
|
55
|
+
echo "Invalid semantic name parameter. Valid values are [patch, minor, major]"
|
|
56
|
+
echo
|
|
57
|
+
echo "Example: sh $0 patch"
|
|
58
|
+
exit 1
|
|
59
|
+
;;
|
|
60
|
+
esac
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
case "$response" in
|
|
64
|
+
[Yy]* )
|
|
65
|
+
case "$SEMANTIC_NAME" in
|
|
66
|
+
patch)
|
|
67
|
+
npm version patch
|
|
68
|
+
;;
|
|
69
|
+
minor)
|
|
70
|
+
npm version minor
|
|
71
|
+
;;
|
|
72
|
+
major)
|
|
73
|
+
npm version major
|
|
74
|
+
;;
|
|
75
|
+
esac
|
|
29
76
|
;;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
case $yn in
|
|
34
|
-
[Yy]* ) break;;
|
|
35
|
-
[Nn]* ) exit;;
|
|
36
|
-
* ) echo "Please answer [y]es or [n]o.";;
|
|
37
|
-
esac
|
|
38
|
-
done
|
|
39
|
-
yarn version --major --no-git-tag-version
|
|
40
|
-
break;
|
|
77
|
+
[Nn]* )
|
|
78
|
+
echo "Changing version canceled."
|
|
79
|
+
exit 1
|
|
41
80
|
;;
|
|
42
81
|
*)
|
|
43
|
-
echo
|
|
44
|
-
echo "Invalid semantic name parameter. Valid values are [patch, minor, major]"
|
|
45
|
-
echo
|
|
46
|
-
echo "Example: sh $0 patch"
|
|
82
|
+
echo "Please answer [y]es or [n]o."
|
|
47
83
|
exit 1
|
|
48
84
|
;;
|
|
49
85
|
esac
|
|
50
86
|
|
|
87
|
+
git push origin
|
|
51
88
|
VERSION=$(node -p "require('./package.json').version")
|
|
52
|
-
|
|
89
|
+
git push origin v$VERSION
|
|
90
|
+
yarn publish --new-version $VERSION
|
package/src/bin.ts
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
import ion from 'i0n';
|
|
4
4
|
const log = ion.create();
|
|
5
5
|
import {generate} from './generate/index';
|
|
6
|
-
const tsconfig_path = `/
|
|
6
|
+
const tsconfig_path = `/Users/x71c9/repos/uranio/builder/tsconfig.json`;
|
|
7
7
|
const response = generate(tsconfig_path);
|
|
8
8
|
log.debug(response);
|
package/dot/src/uranio-client.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* UranioClient module
|
|
4
|
-
*
|
|
5
|
-
* @packageDocumentation
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import {Client, ClientParams} from './client';
|
|
10
|
-
import {Atom} from './types';
|
|
11
|
-
import {AtomClient} from './atom';
|
|
12
|
-
|
|
13
|
-
interface Product extends Atom {
|
|
14
|
-
title: string;
|
|
15
|
-
price: number;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export class UranioClient extends Client{
|
|
19
|
-
public product: AtomClient<Product>;
|
|
20
|
-
constructor(params: ClientParams) {
|
|
21
|
-
super(params);
|
|
22
|
-
this.product = new AtomClient<Product>(this.db, 'product');
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|