ecotransac-shared-js 0.0.1

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/.env ADDED
@@ -0,0 +1 @@
1
+ SERVER_URL=http://localhost:3000
@@ -0,0 +1,21 @@
1
+ name: Node.js Package
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ publish-gpr:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: actions/setup-node@v4
14
+ with:
15
+ node-version: 18
16
+ registry-url: https://npm.pkg.github.com/
17
+ scope: "@rabire"
18
+ run: npm i -g pnpm && pnpm install
19
+ - run: npm run publish
20
+ env:
21
+ NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
package/REASME.md ADDED
@@ -0,0 +1 @@
1
+ Shared code between ecotransac repos
package/codegen.ts ADDED
@@ -0,0 +1,22 @@
1
+ import type { CodegenConfig } from "@graphql-codegen/cli";
2
+ import { SERVER_URL } from "./src/utils/env-variables";
3
+
4
+ const config: CodegenConfig = {
5
+ overwrite: true,
6
+ schema: `${SERVER_URL}/graphql`,
7
+ generates: {
8
+ "src/types/graphql-generated.ts": {
9
+ plugins: [
10
+ "typescript",
11
+ "typescript-operations",
12
+ { add: { content: "/* eslint-disable */" } },
13
+ ],
14
+ config: {
15
+ avoidOptionals: { inputValue: false },
16
+ scalars: { DateTime: "Date" },
17
+ },
18
+ },
19
+ },
20
+ };
21
+
22
+ export default config;
@@ -0,0 +1,49 @@
1
+ type Maybe<T> = T | null;
2
+ /** All built-in and custom scalars, mapped to their actual values */
3
+ type Scalars = {
4
+ ID: {
5
+ input: string;
6
+ output: string;
7
+ };
8
+ String: {
9
+ input: string;
10
+ output: string;
11
+ };
12
+ Boolean: {
13
+ input: boolean;
14
+ output: boolean;
15
+ };
16
+ Int: {
17
+ input: number;
18
+ output: number;
19
+ };
20
+ Float: {
21
+ input: number;
22
+ output: number;
23
+ };
24
+ DateTime: {
25
+ input: Date;
26
+ output: Date;
27
+ };
28
+ Upload: {
29
+ input: any;
30
+ output: any;
31
+ };
32
+ };
33
+ type Address = {
34
+ __typename?: 'Address';
35
+ address: Scalars['String']['output'];
36
+ country: Scalars['String']['output'];
37
+ department: Scalars['String']['output'];
38
+ id: Scalars['ID']['output'];
39
+ lat?: Maybe<Scalars['Float']['output']>;
40
+ lng?: Maybe<Scalars['Float']['output']>;
41
+ locality: Scalars['String']['output'];
42
+ postalCode: Scalars['String']['output'];
43
+ url?: Maybe<Scalars['String']['output']>;
44
+ };
45
+
46
+ declare const formatAddress: (address: Pick<Address, "address" | "postalCode" | "locality">) => string;
47
+ declare const formatSeconds: (seconds: number) => string;
48
+
49
+ export { formatAddress, formatSeconds };
@@ -0,0 +1,49 @@
1
+ type Maybe<T> = T | null;
2
+ /** All built-in and custom scalars, mapped to their actual values */
3
+ type Scalars = {
4
+ ID: {
5
+ input: string;
6
+ output: string;
7
+ };
8
+ String: {
9
+ input: string;
10
+ output: string;
11
+ };
12
+ Boolean: {
13
+ input: boolean;
14
+ output: boolean;
15
+ };
16
+ Int: {
17
+ input: number;
18
+ output: number;
19
+ };
20
+ Float: {
21
+ input: number;
22
+ output: number;
23
+ };
24
+ DateTime: {
25
+ input: Date;
26
+ output: Date;
27
+ };
28
+ Upload: {
29
+ input: any;
30
+ output: any;
31
+ };
32
+ };
33
+ type Address = {
34
+ __typename?: 'Address';
35
+ address: Scalars['String']['output'];
36
+ country: Scalars['String']['output'];
37
+ department: Scalars['String']['output'];
38
+ id: Scalars['ID']['output'];
39
+ lat?: Maybe<Scalars['Float']['output']>;
40
+ lng?: Maybe<Scalars['Float']['output']>;
41
+ locality: Scalars['String']['output'];
42
+ postalCode: Scalars['String']['output'];
43
+ url?: Maybe<Scalars['String']['output']>;
44
+ };
45
+
46
+ declare const formatAddress: (address: Pick<Address, "address" | "postalCode" | "locality">) => string;
47
+ declare const formatSeconds: (seconds: number) => string;
48
+
49
+ export { formatAddress, formatSeconds };
package/dist/index.js ADDED
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ formatAddress: () => formatAddress,
24
+ formatSeconds: () => formatSeconds
25
+ });
26
+ module.exports = __toCommonJS(src_exports);
27
+
28
+ // src/format.ts
29
+ var formatAddress = (address) => `${address.address}, ${address.postalCode} ${address.locality}`;
30
+ var formatSeconds = (seconds) => {
31
+ const hours = Math.floor(seconds / 3600);
32
+ const minutes = Math.floor((seconds - hours * 3600) / 60);
33
+ if (hours === 0) return `${minutes} min`;
34
+ return `${hours} h ${minutes}`;
35
+ };
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ formatAddress,
39
+ formatSeconds
40
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,12 @@
1
+ // src/format.ts
2
+ var formatAddress = (address) => `${address.address}, ${address.postalCode} ${address.locality}`;
3
+ var formatSeconds = (seconds) => {
4
+ const hours = Math.floor(seconds / 3600);
5
+ const minutes = Math.floor((seconds - hours * 3600) / 60);
6
+ if (hours === 0) return `${minutes} min`;
7
+ return `${hours} h ${minutes}`;
8
+ };
9
+ export {
10
+ formatAddress,
11
+ formatSeconds
12
+ };
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "ecotransac-shared-js",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "modules": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "keywords": [],
9
+ "author": "ecotransac",
10
+ "license": "MIT",
11
+ "scripts": {
12
+ "build": "tsup",
13
+ "test": "echo \"Error: no test specified\" && exit 0",
14
+ "generate": "graphql-codegen --config codegen.ts"
15
+ },
16
+ "dependencies": {
17
+ "dotenv": "^16.4.5"
18
+ },
19
+ "devDependencies": {
20
+ "@graphql-codegen/cli": "^5.0.3",
21
+ "@graphql-codegen/typescript": "^4.1.0",
22
+ "tsup": "^8.3.0",
23
+ "typescript": "^5.6.3"
24
+ }
25
+ }