From 0cca6ba718b7983fdcd9af9b672d4bd9c7393146 Mon Sep 17 00:00:00 2001 From: Christopher Kendrick Date: Sun, 3 Mar 2024 17:27:06 -0800 Subject: [PATCH 1/5] updated nodejs examples --- .gitignore | 1 + nodejs/README.md | 115 ++++++++ nodejs/index.ts | 247 ++++++++++------ nodejs/package-lock.json | 611 ++++++++++++++++++++++++++++----------- nodejs/package.json | 16 +- nodejs/tsconfig.json | 17 +- 6 files changed, 750 insertions(+), 257 deletions(-) create mode 100644 nodejs/README.md diff --git a/.gitignore b/.gitignore index 57872d0..161c3b9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /vendor/ +node_modules diff --git a/nodejs/README.md b/nodejs/README.md new file mode 100644 index 0000000..66f6b3d --- /dev/null +++ b/nodejs/README.md @@ -0,0 +1,115 @@ +```markdown +# CurriClientService Documentation + +The `CurriClientService` class enables interaction with the Curri API, facilitating operations such as fetching delivery quotes, booking deliveries, managing deliveries with multiple stops, retrieving delivery information, estimating delivery times, and canceling deliveries. This README details how to install, configure, and utilize this service in your projects. + +## Installation + +Ensure Node.js is installed on your system. Include this library in your project using npm or yarn if lib on public registry: + +### Using npm + +```bash +npm install @your-namespace/curri --save +``` + +### Using yarn + +```bash +yarn add @your-namespace/curri +``` + +## Configuration + +If not on public registry require file manually. Obtain your user ID and API key from your Curri API account. Initialize the `CurriClientService` with these credentials: + +```javascript +const { CurriClientService } = require('./dist'); +const curri = new CurriClientService({ userID: "********", apiKey: "********" }); +``` + +## Methods + +`CurriClientService` provides methods for: + +- Booking deliveries +- Booking deliveries with multiple stops +- Fetching delivery quotes +- Fetching quotes for deliveries with multiple stops +- Retrieving delivery information +- Estimating delivery times +- Canceling deliveries + +### Examples + +#### Booking a Delivery + +```javascript +async function bookDelivery() { + const booking = await curri.book(req.body); + console.log(booking); +} +``` + +#### Booking a Delivery with Multiple Stops + +```javascript +async function bookMultiDelivery() { + const bookingMulti = await curri.bookMulti(req.body); + console.log(bookingMulti); +} +``` + +#### Fetching a Quote for a Delivery with Multiple Stops + +```javascript +async function fetchMultistopQuote() { + const quoteMulti = await curri.quoteMultistop(req.query); + console.log(quoteMulti); +} +``` + +#### Retrieving Delivery Information + +```javascript +async function retrieveDelivery() { + const delivery = await curri.getDelivery(req.query.delivery_id); + console.log(delivery); +} +``` + +#### Estimating Delivery Times + +```javascript +async function estimateDelivery() { + const originLocation = {/* Define origin location */}; + const selectedDeliveryMethod = "MethodHere"; // Define delivery method + const derivedDeliveryEstimate = await curri.deliveryDerivedEstimate(originLocation, selectedDeliveryMethod); + console.log(derivedDeliveryEstimate); +} +``` + +#### Canceling a Delivery + +```javascript +async function cancelDeliveryAction() { + const delivery_id = "YourDeliveryIDHere"; // Define delivery ID + const reason = "YourReasonHere"; // Define cancellation reason + const cancelDelivery = await curri.cancelDelivery(delivery_id, `Cancel Delivery Reason: ${reason}`); + console.log(cancelDelivery); +} +``` + +#### Fetching a Delivery Quote + +```javascript +async function fetchQuote() { + const quote = await curri.quote(req.query); + console.log(quote); +} +``` + +## Support + +For any issues, questions, or contributions, refer to the project's GitHub repository or directly contact the project maintainers. +``` \ No newline at end of file diff --git a/nodejs/index.ts b/nodejs/index.ts index 85445f5..28de2f7 100644 --- a/nodejs/index.ts +++ b/nodejs/index.ts @@ -1,97 +1,182 @@ -import { ApolloClient, InMemoryCache, HttpLink, gql } from '@apollo/client' -import fetch from 'node-fetch' +// Import required modules and classes +import fetch from 'cross-fetch'; +import { ApolloClient, InMemoryCache, HttpLink, gql } from '@apollo/client/core'; +import { Buffer } from 'node:buffer'; -process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; +// Define the CurriClientService class +class CurriClientService { + // Private fields to store user ID, API key, GraphQL client instance, and current user details + private userID:string; + private apiKey:string; + private client:any; + private currentUser:any; -const client = new ApolloClient({ - cache: new InMemoryCache(), - link: new HttpLink({ - uri: 'https://api.curri.com/graphql', - fetch, - headers: { - authorization: `Basic ${process.env.CURRI_API_KEY || 'INSERT_BASE_64_USERID_AND_APIKEY'}` - } - }) -}); + // Constructor initializes the client with given configuration + constructor(config:any) { + this.userID = config.userID; + this.apiKey = config.apiKey; + // Setup the GraphQL client with the API URL and authentication credentials + this.setClient("https://api.curri.com/graphql", this.userID, this.apiKey); + } -(async () => { - const userResponse = await client - .query({ - query: gql` - { - currentUser { - id - } - } - ` - }) + // Method to fetch a delivery quote based on provided arguments + public async quote(quoteArgs:any) { + // GraphQL query for fetching a delivery quote + const query = gql` + query DeliveryQuote($origin:AddressInput, $destination:AddressInput, $priority:String, $deliveryMethod:String, $manifestItems:[ManifestItemInput]){ + deliveryQuote( + origin: $origin, + destination: $destination, + priority: $priority, + deliveryMethod: $deliveryMethod, + manifestItems: $manifestItems + ) + { + id + fee + distance + duration + pickupDuration + deliveryMethod + } + } + `; - console.log(userResponse) - if (!userResponse.data.currentUser.id) { - throw new Error('We were unable to authenticate you') + // Execute the query with provided arguments and return the result + const res = await this.client + .query({ + query:query, + variables:{ + quoteArgs:quoteArgs, + origin:quoteArgs.origin, + destination:quoteArgs.destination, + priority:quoteArgs.priority, + deliveryMethod:quoteArgs.deliveryMethod, + manifestItems:quoteArgs.manifestItems, + } + }) + return res.data.deliveryQuote; } - console.log('Logged in as:', userResponse) - - const quoteResponse = await client - .query({ - query: gql` - query { - deliveryQuote( - destination: { - name: "Curri Incubator", - addressLine1: "54 S Oak St.", - city: "Ventura", - state: "CA", - postalCode: 93001 - }, - origin: { - name: "305 South Kalorama Street", - addressLine1: "305 S Kalorama St", - city: "Ventura", - state: "CA", - postalCode: 93001 - }, - deliveryMethod: "truck" - ) { - id - fee - distance - duration - pickupDuration - deliveryMethod + // Method to fetch a quote for a delivery with multiple stops + public async quoteMultistop(quoteArgs:any) { + // GraphQL mutation for creating a booking quote with multiple stops + const mutation = gql` + mutation CreateBookingQuote($stops:[BookingQuoteStopInput!]!, $priority:String!, $deliveryMethods:[String!]){ + createBookingQuote( + stops: $stops, + priority: $priority, + deliveryMethods: $deliveryMethods + ) + { + id + deliveryMethod + price + distance + } } - } - ` - }) + `; - console.log('Quote:', quoteResponse) + // Execute the mutation with provided arguments and return the result + try { + const res = await this.client.mutate({ + mutation:mutation, + variables:{ + quoteArgs:quoteArgs, + stops:quoteArgs.stops, + priority:quoteArgs.priority, + deliveryMethods:quoteArgs.deliveryMethods + } + }) + return res.data.createBookingQuote; + }catch(error:any) { + throw error; + } + } - try { - const bookResponse = await client - .mutate({ - mutation: gql` - mutation { - bookDelivery( - data: { - deliveryQuoteId: "${quoteResponse.data.deliveryQuote.id}" + // Method to book a delivery with given booking arguments + public async book(bookingArgs:any) { + // GraphQL mutation for booking a delivery + const mutation = gql` + mutation Delivery($bookingArgs:BookDeliveryInput!){ + bookDelivery( + data: $bookingArgs + ) + { + id + price + createdAt + deliveryMethod + deliveredAt } - ) - { - id - price - createdAt - deliveryMethod - deliveredAt } + `; + // Execute the mutation with provided arguments and return the result + const res = await this.client + .mutate({ + mutation:mutation, + variables:{ + bookingArgs:bookingArgs } - ` - }) + }) + return res.data.bookDelivery; + } + + // Method to book a delivery with multiple stops + public async bookMulti(bookingArgs:any) { + // GraphQL mutation for creating a booking with multiple stops + const mutation = gql` + mutation CreateBooking($quoteId:String, $stops:[BookingStopInput], $scheduledAt:String, $declaredValue:Int, $manifestItems:[ManifestItemInput!], $notesForDispatcher:String, $attachments: [DeliveryAttachmentInput!]){ + createBooking( + quoteId:$quoteId, + stops:$stops, + scheduledAt:$scheduledAt, + declaredValue:$declaredValue, + manifestItems:$manifestItems, + notesForDispatcher:$notesForDispatcher, + attachments: $attachments + ) + { + id + price + distance + deliveryMethod + deliveryIds + } + } + `; + // Execute the mutation with provided arguments and return the result + const res = await this.client + } - console.log('Book Delivery:', bookResponse) - } catch (error) { - console.log(error) + private setClient(uri:string = "https://api.curri.com/graphql", userID:string, apiKey:String) { + + const defaultOptions:any = { + watchQuery: { + fetchPolicy: 'no-cache', + errorPolicy: 'ignore', + }, + query: { + fetchPolicy: 'no-cache', + errorPolicy: 'all', + }, + } + + const base64Auth = Buffer.from(`${userID}:${apiKey}`).toString('base64'); + this.client = new ApolloClient({ + cache: new InMemoryCache({resultCaching:false}), + link: new HttpLink({ + uri: uri, + fetch, + headers: { + authorization: `Basic ${base64Auth}` + } + }), + defaultOptions:defaultOptions + }); } -})() + +} + diff --git a/nodejs/package-lock.json b/nodejs/package-lock.json index 17c1b15..741dbfb 100644 --- a/nodejs/package-lock.json +++ b/nodejs/package-lock.json @@ -1,224 +1,511 @@ { "name": "nodejs", "version": "1.0.0", - "lockfileVersion": 1, + "lockfileVersion": 3, "requires": true, - "dependencies": { - "@apollo/client": { - "version": "3.0.0-beta.43", - "resolved": "https://registry.npmjs.org/@apollo/client/-/client-3.0.0-beta.43.tgz", - "integrity": "sha512-ufE0QubCI6kP/BudcnV3AGZVgsN/ZJNWy70k6ZwcR8fnYWqPfjxW1aATTq8Ud54latHpO83UtKHVOHUQiClQOA==", - "requires": { - "@types/zen-observable": "^0.8.0", - "@wry/equality": "^0.1.9", - "fast-json-stable-stringify": "^2.0.0", - "graphql-tag": "^2.10.2", - "optimism": "^0.11.5", - "symbol-observable": "^1.2.0", - "ts-invariant": "^0.4.4", - "tslib": "^1.10.0", - "zen-observable": "^0.8.14" - } - }, - "@types/node": { - "version": "13.11.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.11.1.tgz", - "integrity": "sha512-eWQGP3qtxwL8FGneRrC5DwrJLGN4/dH1clNTuLfN81HCrxVtxRjygDTUoZJ5ASlDEeo0ppYFQjQIlXhtXpOn6g==", - "dev": true + "packages": { + "": { + "name": "nodejs", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "@apollo/client": "^3.7.0", + "@apollo/react-hooks": "^4.0.0", + "cross-fetch": "^3.1.5", + "graphql": "^16.6.0", + "node-fetch": "^3.2.10" + }, + "devDependencies": { + "@types/node": "^18.8.5", + "@types/node-fetch": "^2.6.2", + "tslib": "^2.4.0", + "typescript": "^4.8.4" + } + }, + "node_modules/@apollo/client": { + "version": "3.9.5", + "resolved": "https://registry.npmjs.org/@apollo/client/-/client-3.9.5.tgz", + "integrity": "sha512-7y+c8MTPU+hhTwvcGVtMMGIgWduzrvG1mz5yJMRyqYbheBkkky3Lki6ADWVSBXG1lZoOtPYvB2zDgVfKb2HSsw==", + "dependencies": { + "@graphql-typed-document-node/core": "^3.1.1", + "@wry/caches": "^1.0.0", + "@wry/equality": "^0.5.6", + "@wry/trie": "^0.5.0", + "graphql-tag": "^2.12.6", + "hoist-non-react-statics": "^3.3.2", + "optimism": "^0.18.0", + "prop-types": "^15.7.2", + "rehackt": "0.0.5", + "response-iterator": "^0.2.6", + "symbol-observable": "^4.0.0", + "ts-invariant": "^0.10.3", + "tslib": "^2.3.0", + "zen-observable-ts": "^1.2.5" + }, + "peerDependencies": { + "graphql": "^15.0.0 || ^16.0.0", + "graphql-ws": "^5.5.5", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0", + "subscriptions-transport-ws": "^0.9.0 || ^0.11.0" + }, + "peerDependenciesMeta": { + "graphql-ws": { + "optional": true + }, + "react": { + "optional": true + }, + "react-dom": { + "optional": true + }, + "subscriptions-transport-ws": { + "optional": true + } + } + }, + "node_modules/@apollo/react-hooks": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@apollo/react-hooks/-/react-hooks-4.0.0.tgz", + "integrity": "sha512-fCu0cbne3gbUl0QbA8X4L33iuuFVQbC5Jo2MIKRK8CyawR6PoxDpFdFA1kc6033ODZuZZ9Eo4RdeJFlFIIYcLA==", + "dependencies": { + "@apollo/client": "latest" + } + }, + "node_modules/@graphql-typed-document-node/core": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@graphql-typed-document-node/core/-/core-3.2.0.tgz", + "integrity": "sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ==", + "peerDependencies": { + "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } }, - "@types/node-fetch": { - "version": "2.5.6", - "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.6.tgz", - "integrity": "sha512-2w0NTwMWF1d3NJMK0Uiq2UNN8htVCyOWOD0jIPjPgC5Ph/YP4dVhs9YxxcMcuLuwAslz0dVEcZQUaqkLs3IzOQ==", + "node_modules/@types/node": { + "version": "18.19.21", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.21.tgz", + "integrity": "sha512-2Q2NeB6BmiTFQi4DHBzncSoq/cJMLDdhPaAoJFnFCyD9a8VPZRf7a1GAwp1Edb7ROaZc5Jz/tnZyL6EsWMRaqw==", "dev": true, - "requires": { + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/@types/node-fetch": { + "version": "2.6.11", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.11.tgz", + "integrity": "sha512-24xFj9R5+rfQJLRyM56qh+wnVSYhyXC2tkoBndtY0U+vubqNsYXGjufB2nn8Q6gt0LrARwL6UBtMCSVCwl4B1g==", + "dev": true, + "dependencies": { "@types/node": "*", - "form-data": "^3.0.0" + "form-data": "^4.0.0" } }, - "@types/zen-observable": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@types/zen-observable/-/zen-observable-0.8.0.tgz", - "integrity": "sha512-te5lMAWii1uEJ4FwLjzdlbw3+n0FZNOvFXHxQDKeT0dilh7HOzdMzV2TrJVUzq8ep7J4Na8OUYPRLSQkJHAlrg==" + "node_modules/@wry/caches": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@wry/caches/-/caches-1.0.1.tgz", + "integrity": "sha512-bXuaUNLVVkD20wcGBWRyo7j9N3TxePEWFZj2Y+r9OoUzfqmavM84+mFykRicNsBqatba5JLay1t48wxaXaWnlA==", + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": ">=8" + } }, - "@wry/context": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/@wry/context/-/context-0.5.2.tgz", - "integrity": "sha512-B/JLuRZ/vbEKHRUiGj6xiMojST1kHhu4WcreLfNN7q9DqQFrb97cWgf/kiYsPSUCAMVN0HzfFc8XjJdzgZzfjw==", - "requires": { - "tslib": "^1.9.3" + "node_modules/@wry/context": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/@wry/context/-/context-0.7.4.tgz", + "integrity": "sha512-jmT7Sb4ZQWI5iyu3lobQxICu2nC/vbUhP0vIdd6tHC9PTfenmRmuIFqktc6GH9cgi+ZHnsLWPvfSvc4DrYmKiQ==", + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": ">=8" } }, - "@wry/equality": { - "version": "0.1.11", - "resolved": "https://registry.npmjs.org/@wry/equality/-/equality-0.1.11.tgz", - "integrity": "sha512-mwEVBDUVODlsQQ5dfuLUS5/Tf7jqUKyhKYHmVi4fPB6bDMOfWvUPJmKgS1Z7Za/sOI3vzWt4+O7yCiL/70MogA==", - "requires": { - "tslib": "^1.9.3" + "node_modules/@wry/equality": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/@wry/equality/-/equality-0.5.7.tgz", + "integrity": "sha512-BRFORjsTuQv5gxcXsuDXx6oGRhuVsEGwZy6LOzRRfgu+eSfxbhUQ9L9YtSEIuIjY/o7g3iWFjrc5eSY1GXP2Dw==", + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": ">=8" } }, - "arg": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", - "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", - "dev": true + "node_modules/@wry/trie": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@wry/trie/-/trie-0.5.0.tgz", + "integrity": "sha512-FNoYzHawTMk/6KMQoEG5O4PuioX19UbwdQKF44yw0nLfOypfQdjtfZzo/UIJWAJ23sNIFbD1Ug9lbaDGMwbqQA==", + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": ">=8" + } }, - "asynckit": { + "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", - "dev": true - }, - "buffer-from": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", - "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", "dev": true }, - "combined-stream": { + "node_modules/combined-stream": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", "dev": true, - "requires": { + "dependencies": { "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" } }, - "delayed-stream": { + "node_modules/cross-fetch": { + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.8.tgz", + "integrity": "sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg==", + "dependencies": { + "node-fetch": "^2.6.12" + } + }, + "node_modules/cross-fetch/node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/data-uri-to-buffer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", + "engines": { + "node": ">= 12" + } + }, + "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", - "dev": true - }, - "diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", - "dev": true + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } }, - "fast-json-stable-stringify": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" + "node_modules/fetch-blob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "paypal", + "url": "https://paypal.me/jimmywarting" + } + ], + "dependencies": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + }, + "engines": { + "node": "^12.20 || >= 14.13" + } }, - "form-data": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz", - "integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==", + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", "dev": true, - "requires": { + "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" } }, - "graphql": { - "version": "15.0.0", - "resolved": "https://registry.npmjs.org/graphql/-/graphql-15.0.0.tgz", - "integrity": "sha512-ZyVO1xIF9F+4cxfkdhOJINM+51B06Friuv4M66W7HzUOeFd+vNzUn4vtswYINPi6sysjf1M2Ri/rwZALqgwbaQ==" + "node_modules/formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "dependencies": { + "fetch-blob": "^3.1.2" + }, + "engines": { + "node": ">=12.20.0" + } }, - "graphql-tag": { - "version": "2.10.3", - "resolved": "https://registry.npmjs.org/graphql-tag/-/graphql-tag-2.10.3.tgz", - "integrity": "sha512-4FOv3ZKfA4WdOKJeHdz6B3F/vxBLSgmBcGeAFPf4n1F64ltJUvOOerNj0rsJxONQGdhUMynQIvd6LzB+1J5oKA==" + "node_modules/graphql": { + "version": "16.8.1", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.8.1.tgz", + "integrity": "sha512-59LZHPdGZVh695Ud9lRzPBVTtlX9ZCV150Er2W43ro37wVof0ctenSaskPPjN7lVTIN8mSZt8PHUNKZuNQUuxw==", + "engines": { + "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" + } }, - "make-error": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", - "dev": true + "node_modules/graphql-tag": { + "version": "2.12.6", + "resolved": "https://registry.npmjs.org/graphql-tag/-/graphql-tag-2.12.6.tgz", + "integrity": "sha512-FdSNcu2QQcWnM2VNvSCCDCVS5PpPqpzgFT8+GXzqJuoDd0CBncxCY278u4mhRO7tMgo2JjgJA5aZ+nWSQ/Z+xg==", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "graphql": "^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" + } }, - "mime-db": { - "version": "1.43.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz", - "integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==", - "dev": true + "node_modules/hoist-non-react-statics": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", + "integrity": "sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==", + "dependencies": { + "react-is": "^16.7.0" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, - "mime-types": { - "version": "2.1.26", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz", - "integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==", + "node_modules/loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", "dev": true, - "requires": { - "mime-db": "1.43.0" + "engines": { + "node": ">= 0.6" } }, - "node-fetch": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", - "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } }, - "optimism": { - "version": "0.11.5", - "resolved": "https://registry.npmjs.org/optimism/-/optimism-0.11.5.tgz", - "integrity": "sha512-twCHmBb64DYzEZ8A3O+TLCuF/RmZPBhXPQYv4agoiALRLlW9SidMzd7lwUP9mL0jOZhzhnBmb8ajqA00ECo/7g==", - "requires": { - "@wry/context": "^0.5.0" + "node_modules/node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "github", + "url": "https://paypal.me/jimmywarting" + } + ], + "engines": { + "node": ">=10.5.0" } }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true + "node_modules/node-fetch": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", + "dependencies": { + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-fetch" + } }, - "source-map-support": { - "version": "0.5.16", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.16.tgz", - "integrity": "sha512-efyLRJDr68D9hBBNIPWFjhpFzURh+KJykQwvMyW5UiZzYwoF6l4YMMDIJJEyFWxWCqfyxLzz6tSfUFR+kXXsVQ==", - "dev": true, - "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/optimism": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/optimism/-/optimism-0.18.0.tgz", + "integrity": "sha512-tGn8+REwLRNFnb9WmcY5IfpOqeX2kpaYJ1s6Ae3mn12AeydLkR3j+jSCmVQFoXqU8D41PAJ1RG1rCRNWmNZVmQ==", + "dependencies": { + "@wry/caches": "^1.0.0", + "@wry/context": "^0.7.0", + "@wry/trie": "^0.4.3", + "tslib": "^2.3.0" + } + }, + "node_modules/optimism/node_modules/@wry/trie": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@wry/trie/-/trie-0.4.3.tgz", + "integrity": "sha512-I6bHwH0fSf6RqQcnnXLJKhkSXG45MFral3GxPaY4uAl0LYDZM+YDVDAiU9bYwjTuysy1S0IeecWtmq1SZA3M1w==", + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/prop-types": { + "version": "15.8.1", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", + "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", + "dependencies": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.13.1" } }, - "symbol-observable": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz", - "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==" + "node_modules/react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, - "ts-invariant": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/ts-invariant/-/ts-invariant-0.4.4.tgz", - "integrity": "sha512-uEtWkFM/sdZvRNNDL3Ehu4WVpwaulhwQszV8mrtcdeE8nN00BV9mAmQ88RkrBhFgl9gMgvjJLAQcZbnPXI9mlA==", - "requires": { - "tslib": "^1.9.3" + "node_modules/rehackt": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/rehackt/-/rehackt-0.0.5.tgz", + "integrity": "sha512-BI1rV+miEkaHj8zd2n+gaMgzu/fKz7BGlb4zZ6HAiY9adDmJMkaDcmuXlJFv0eyKUob+oszs3/2gdnXUrzx2Tg==", + "peerDependencies": { + "@types/react": "*", + "react": "*" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "react": { + "optional": true + } } }, - "ts-node": { - "version": "8.8.2", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.8.2.tgz", - "integrity": "sha512-duVj6BpSpUpD/oM4MfhO98ozgkp3Gt9qIp3jGxwU2DFvl/3IRaEAvbLa8G60uS7C77457e/m5TMowjedeRxI1Q==", + "node_modules/response-iterator": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/response-iterator/-/response-iterator-0.2.6.tgz", + "integrity": "sha512-pVzEEzrsg23Sh053rmDUvLSkGXluZio0qu8VT6ukrYuvtjVfCbDZH9d6PGXb8HZfzdNZt8feXv/jvUzlhRgLnw==", + "engines": { + "node": ">=0.8" + } + }, + "node_modules/symbol-observable": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-4.0.0.tgz", + "integrity": "sha512-b19dMThMV4HVFynSAM1++gBHAbk2Tc/osgLIBZMKsyqh34jb2e8Os7T6ZW/Bt3pJFdBTd2JwAnAAEQV7rSNvcQ==", + "engines": { + "node": ">=0.10" + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/ts-invariant": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/ts-invariant/-/ts-invariant-0.10.3.tgz", + "integrity": "sha512-uivwYcQaxAucv1CzRp2n/QdYPo4ILf9VXgH19zEIjFx2EJufV16P0JtJVpYHy89DItG6Kwj2oIUjrcK5au+4tQ==", + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" + }, + "node_modules/typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "dev": true, - "requires": { - "arg": "^4.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "source-map-support": "^0.5.6", - "yn": "3.1.1" - } - }, - "tslib": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.11.1.tgz", - "integrity": "sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA==" - }, - "typescript": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz", - "integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==", - "dev": true + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } }, - "yn": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", - "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", "dev": true }, - "zen-observable": { + "node_modules/web-streams-polyfill": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", + "engines": { + "node": ">= 8" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/zen-observable": { "version": "0.8.15", "resolved": "https://registry.npmjs.org/zen-observable/-/zen-observable-0.8.15.tgz", "integrity": "sha512-PQ2PC7R9rslx84ndNBZB/Dkv8V8fZEpk83RLgXtYd0fwUgEjseMn1Dgajh2x6S8QbZAFa9p2qVCEuYZNgve0dQ==" + }, + "node_modules/zen-observable-ts": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/zen-observable-ts/-/zen-observable-ts-1.2.5.tgz", + "integrity": "sha512-QZWQekv6iB72Naeake9hS1KxHlotfRpe+WGNbNx5/ta+R3DNjVO2bswf63gXlWDcs+EMd7XY8HfVQyP1X6T4Zg==", + "dependencies": { + "zen-observable": "0.8.15" + } } } } diff --git a/nodejs/package.json b/nodejs/package.json index d2a8400..9a74a12 100644 --- a/nodejs/package.json +++ b/nodejs/package.json @@ -10,13 +10,17 @@ "author": "Curri Engineering", "license": "ISC", "dependencies": { - "@apollo/client": "3.0.0-beta.43", - "graphql": "15.0.0", - "node-fetch": "2.6.0" + "@apollo/client": "^3.7.0", + "@apollo/react-hooks": "^4.0.0", + "cross-fetch": "^3.1.5", + "graphql": "^16.6.0", + "node-fetch": "^3.2.10" }, "devDependencies": { - "@types/node-fetch": "2.5.6", - "ts-node": "8.8.2", - "typescript": "3.8.3" + "@types/node": "^18.8.5", + "@types/node-fetch": "^2.6.2", + "tslib": "^2.4.0", + "typescript": "^4.8.4" + } } diff --git a/nodejs/tsconfig.json b/nodejs/tsconfig.json index 3e1c22f..ac20c24 100644 --- a/nodejs/tsconfig.json +++ b/nodejs/tsconfig.json @@ -5,22 +5,23 @@ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ "lib": [ - "ES2015" + "ES2015", + "dom" ], /* Specify library files to be included in the compilation. */ - // "allowJs": true, /* Allow javascript files to be compiled. */ - // "checkJs": true, /* Report errors in .js files. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - // "declaration": true, /* Generates corresponding '.d.ts' file. */ + "allowJs": true, /* Allow javascript files to be compiled. */ + //"checkJs": false, /* Report errors in .js files. */ + "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + //"declaration": true, /* Generates corresponding '.d.ts' file. */ // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ // "sourceMap": true, /* Generates corresponding '.map' file. */ // "outFile": "./", /* Concatenate and emit output to single file. */ - // "outDir": "./", /* Redirect output structure to the directory. */ + "outDir": "../dist", /* Redirect output structure to the directory. */ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ // "composite": true, /* Enable project compilation */ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ // "removeComments": true, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + "importHelpers": true, /* Import emit helpers from 'tslib'. */ // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ /* Strict Type-Checking Options */ @@ -59,4 +60,4 @@ /* Advanced Options */ "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ } -} +} \ No newline at end of file From ccc1902a58225b3e0b50f0f39952fc378d9ce87d Mon Sep 17 00:00:00 2001 From: Christopher Kendrick Date: Sun, 3 Mar 2024 17:46:26 -0800 Subject: [PATCH 2/5] fixed readme typo --- nodejs/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/nodejs/README.md b/nodejs/README.md index 66f6b3d..0b5aded 100644 --- a/nodejs/README.md +++ b/nodejs/README.md @@ -1,4 +1,3 @@ -```markdown # CurriClientService Documentation The `CurriClientService` class enables interaction with the Curri API, facilitating operations such as fetching delivery quotes, booking deliveries, managing deliveries with multiple stops, retrieving delivery information, estimating delivery times, and canceling deliveries. This README details how to install, configure, and utilize this service in your projects. From c95b9ad2e1fe890ed81d8e79fd1769f58b035a0f Mon Sep 17 00:00:00 2001 From: Christopher Kendrick Date: Sun, 3 Mar 2024 17:52:08 -0800 Subject: [PATCH 3/5] fixed another readme typo --- nodejs/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nodejs/README.md b/nodejs/README.md index 0b5aded..805617c 100644 --- a/nodejs/README.md +++ b/nodejs/README.md @@ -110,5 +110,4 @@ async function fetchQuote() { ## Support -For any issues, questions, or contributions, refer to the project's GitHub repository or directly contact the project maintainers. -``` \ No newline at end of file +For any issues, questions, or contributions, refer to the project's GitHub repository or directly contact the project maintainers. \ No newline at end of file From 240238c3bb3cba4e793ce32f51d9940cb9f11637 Mon Sep 17 00:00:00 2001 From: Christopher Kendrick Date: Sun, 3 Mar 2024 18:06:56 -0800 Subject: [PATCH 4/5] added missing methods --- nodejs/index.ts | 365 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 355 insertions(+), 10 deletions(-) diff --git a/nodejs/index.ts b/nodejs/index.ts index 28de2f7..79e643d 100644 --- a/nodejs/index.ts +++ b/nodejs/index.ts @@ -149,19 +149,364 @@ class CurriClientService { const res = await this.client } + public async updateDelivery(updateDeliveryArgs:any) { + const mutation = gql` + mutation updateDelivery($updateDeliveryArgs:UpdateDeliveryInput!){ + updateDelivery( + data: $updateDeliveryArgs + ) + { + id + distance + price + } + } + `; + const res = await this.client + .mutate({ + mutation:mutation, + variables:{ + updateDeliveryArgs:updateDeliveryArgs + } + }) + return res.data.updateDelivery; + } - private setClient(uri:string = "https://api.curri.com/graphql", userID:string, apiKey:String) { + public async cancelDelivery(id:any, reason:any) { + const mutation = gql` + mutation CancelDelivery($id:String, $reason:String){ + cancelDelivery(id:$id, reason:$reason) + { + id + } + } + `; + const res = await this.client + .mutate({ + mutation:mutation, + variables:{ + id:id, + reason:reason + } + }) + return res.data.cancelDelivery; + } - const defaultOptions:any = { - watchQuery: { - fetchPolicy: 'no-cache', - errorPolicy: 'ignore', - }, - query: { - fetchPolicy: 'no-cache', - errorPolicy: 'all', - }, +public async getDelivery(id: any) { + const query = gql` + query Delivery($id: IDCustomScalar) { + delivery(id: $id) { + ...DeliveryFields + __typename + } + } + + fragment DeliveryFields on Delivery { + id + realId + trackingId + externalId + createdAt + distance + price + estimatedTravelTime + deliveryMethod + deliveryMethodDisplayName + priority + scheduledAt + deliveredAt + receivedBy + images + isCurrentUserAuthorizedToModify + declaredValue + deliveryServiceProviderQuoteId + parentDeliveryId + childDeliveryId + deliveryMeta { + dropoffNote + pickupNote + poNumber + orderNumber + bolNumber + originCustomAddressLine2 + destinationCustomAddressLine2 + __typename + } + attachments { + id + filename + url + isDeleted + isInternal + __typename + } + deliveryStatus { + name + code + __typename + } + origin { + id + name + addressLine1 + addressLine2 + city + state + postalCode + latitude + longitude + zipCodeData { + timezone + __typename + } + __typename + } + destination { + id + name + addressLine1 + addressLine2 + city + state + postalCode + latitude + longitude + zipCodeData { + timezone + __typename + } + __typename + } + originatingUser { + id + externalId + emailAddress + firstName + lastName + phoneNumber + profileImageUrl + walletBalance + __typename + } + driver { + id + firstName + lastName + lastKnownLocation { + driverId + latitude + longitude + heading + __typename + } + ratings { + average + count + __typename + } + __typename + } + invoice { + subtotal + appliedCreditAmount + total + __typename + } + pickupContact { + name + phoneNumber + company + emailAddress + __typename + } + dropoffContact { + name + phoneNumber + company + emailAddress + __typename + } + deliveryDriverReviews { + customerRating + customerReview + __typename + } + deliveryUnfulfilledReason { + code + __typename + } + customerRating + customerReview + manifestItems { + id + height + width + length + weight + description + value + quantity + __typename + } + __typename + } + `; + + const res = await this.client.query({ + query: query, + variables: { + id: id + } + }); + if (res.errors && res.errors.length) { + throw res.errors[0]; + } else { + return res.data.delivery; + } +} + + public async listDeliveries() { + const query = gql` + query { + deliveries { + id + createdAt + distance + price + estimatedTravelTime + deliveryMethod + deliveredAt + deliveryMeta { + dropoffNote + pickupNote + poNumber + orderNumber + } + deliveryStatus { + name + code + } + origin { + name + addressLine1 + addressLine2 + city + state + postalCode + latitude + longitude + } + destination { + name + addressLine1 + addressLine2 + city + state + postalCode + latitude + longitude + } + driver { + firstName + lastName + phoneNumber + profileImageUrl + } + images + } + }`; + + const res = await this.client.query({ + query:query + }) + + return res.data.deliveries; + } + + public async deliveryEstimates(id:any) { + const query = gql` + query DeliveryEstimates($id:String!){ + deliveryEstimates(deliveryId:$id) + { + createdAt + driverLocationLastUpdatedAt + driverLatitude + driverLongitude + address { + addressLine1 + addressLine2 + city + state + postalCode + } + distance + bestGuessEstimate + estimateType + } + } + `; + const res = await this.client + .query({ + query:query, + variables:{ + id:id + } + }) + return res.data.deliveryEstimates; + } + + public async deliveryDerivedEstimate(originLocation:any, selectedDeliveryMethod:any) { + const query = gql` + query DeliveryDerivedEstimatesCalculate($originLocation:DeliveryDerivedEstimateOriginLocationInput!, $selectedDeliveryMethod:String!){ + deliveryDerivedEstimatesCalculate(originLocation:$originLocation, selectedDeliveryMethod:$selectedDeliveryMethod) + { + estimateInSeconds + } + } + `; + const res = await this.client + .query({ + query:query, + variables:{ + originLocation:originLocation, + selectedDeliveryMethod:selectedDeliveryMethod + } + }) + return res.data.deliveryDerivedEstimatesCalculate; + } + + public async getCurrentUser() { + const res = await this.client + .query({ + query: gql` + { + currentUser { + id + } + } + ` + }) + + if(res.data.currentUser.id) { + this.currentUser = res.data.currentUser; + return this.currentUser; + }else{ + throw new Error('We were unable to authenticate you'); } + } + + private setClient(uri:string = "https://api.curri.com/graphql", userID:string, apiKey:String) { + + const defaultOptions:any = { + watchQuery: { + fetchPolicy: 'no-cache', + errorPolicy: 'ignore', + }, + query: { + fetchPolicy: 'no-cache', + errorPolicy: 'all', + }, + } const base64Auth = Buffer.from(`${userID}:${apiKey}`).toString('base64'); this.client = new ApolloClient({ From a4d6b11b4243ef23d1c20633dc9311c16f0785c7 Mon Sep 17 00:00:00 2001 From: Christopher Kendrick Date: Tue, 5 Mar 2024 09:54:49 -0800 Subject: [PATCH 5/5] updated readme --- nodejs/README.md | 39 ++++++ nodejs/index.ts | 340 +++++++++++++++++++++++------------------------ 2 files changed, 209 insertions(+), 170 deletions(-) diff --git a/nodejs/README.md b/nodejs/README.md index 805617c..8b9e398 100644 --- a/nodejs/README.md +++ b/nodejs/README.md @@ -38,6 +38,9 @@ const curri = new CurriClientService({ userID: "********", apiKey: "********" }) - Retrieving delivery information - Estimating delivery times - Canceling deliveries +- Updating a delivery +- Listing deliveries +- Get current API User ### Examples @@ -108,6 +111,42 @@ async function fetchQuote() { } ``` +#### Updating a Delivery + +```javascript +async function updateDelivery() { + const updatedDelivery = await curri.updateDelivery(req.body); + console.log(updatedDelivery); +} +``` + +#### List Deliveries + +```javascript +async function listDeliveries() { + const deliveries = await curri.listDeliveries(); + console.log(deliveries); +} +``` + +#### Delivery Estimates + +```javascript +async function deliveryEstimates() { + const deliveryEstimates = await curri.deliveryEstimates(delivery_id); + console.log(deliveryEstimates); +} +``` + +#### Get Current User + +```javascript +async function currentUser() { + const currentUser = await curri.getCurrentUser(); + console.log(currentUser); +} +``` + ## Support For any issues, questions, or contributions, refer to the project's GitHub repository or directly contact the project maintainers. \ No newline at end of file diff --git a/nodejs/index.ts b/nodejs/index.ts index 79e643d..fff7367 100644 --- a/nodejs/index.ts +++ b/nodejs/index.ts @@ -192,178 +192,178 @@ class CurriClientService { return res.data.cancelDelivery; } -public async getDelivery(id: any) { - const query = gql` - query Delivery($id: IDCustomScalar) { - delivery(id: $id) { - ...DeliveryFields - __typename - } - } + public async getDelivery(id: any) { + const query = gql` + query Delivery($id: IDCustomScalar) { + delivery(id: $id) { + ...DeliveryFields + __typename + } + } - fragment DeliveryFields on Delivery { - id - realId - trackingId - externalId - createdAt - distance - price - estimatedTravelTime - deliveryMethod - deliveryMethodDisplayName - priority - scheduledAt - deliveredAt - receivedBy - images - isCurrentUserAuthorizedToModify - declaredValue - deliveryServiceProviderQuoteId - parentDeliveryId - childDeliveryId - deliveryMeta { - dropoffNote - pickupNote - poNumber - orderNumber - bolNumber - originCustomAddressLine2 - destinationCustomAddressLine2 - __typename - } - attachments { - id - filename - url - isDeleted - isInternal - __typename - } - deliveryStatus { - name - code - __typename - } - origin { - id - name - addressLine1 - addressLine2 - city - state - postalCode - latitude - longitude - zipCodeData { - timezone - __typename - } - __typename - } - destination { - id - name - addressLine1 - addressLine2 - city - state - postalCode - latitude - longitude - zipCodeData { - timezone - __typename - } - __typename - } - originatingUser { - id - externalId - emailAddress - firstName - lastName - phoneNumber - profileImageUrl - walletBalance - __typename - } - driver { - id - firstName - lastName - lastKnownLocation { - driverId - latitude - longitude - heading - __typename - } - ratings { - average - count - __typename - } - __typename - } - invoice { - subtotal - appliedCreditAmount - total - __typename - } - pickupContact { - name - phoneNumber - company - emailAddress - __typename - } - dropoffContact { - name - phoneNumber - company - emailAddress - __typename - } - deliveryDriverReviews { - customerRating - customerReview - __typename - } - deliveryUnfulfilledReason { - code - __typename - } - customerRating - customerReview - manifestItems { - id - height - width - length - weight - description - value - quantity - __typename - } - __typename - } - `; + fragment DeliveryFields on Delivery { + id + realId + trackingId + externalId + createdAt + distance + price + estimatedTravelTime + deliveryMethod + deliveryMethodDisplayName + priority + scheduledAt + deliveredAt + receivedBy + images + isCurrentUserAuthorizedToModify + declaredValue + deliveryServiceProviderQuoteId + parentDeliveryId + childDeliveryId + deliveryMeta { + dropoffNote + pickupNote + poNumber + orderNumber + bolNumber + originCustomAddressLine2 + destinationCustomAddressLine2 + __typename + } + attachments { + id + filename + url + isDeleted + isInternal + __typename + } + deliveryStatus { + name + code + __typename + } + origin { + id + name + addressLine1 + addressLine2 + city + state + postalCode + latitude + longitude + zipCodeData { + timezone + __typename + } + __typename + } + destination { + id + name + addressLine1 + addressLine2 + city + state + postalCode + latitude + longitude + zipCodeData { + timezone + __typename + } + __typename + } + originatingUser { + id + externalId + emailAddress + firstName + lastName + phoneNumber + profileImageUrl + walletBalance + __typename + } + driver { + id + firstName + lastName + lastKnownLocation { + driverId + latitude + longitude + heading + __typename + } + ratings { + average + count + __typename + } + __typename + } + invoice { + subtotal + appliedCreditAmount + total + __typename + } + pickupContact { + name + phoneNumber + company + emailAddress + __typename + } + dropoffContact { + name + phoneNumber + company + emailAddress + __typename + } + deliveryDriverReviews { + customerRating + customerReview + __typename + } + deliveryUnfulfilledReason { + code + __typename + } + customerRating + customerReview + manifestItems { + id + height + width + length + weight + description + value + quantity + __typename + } + __typename + } + `; - const res = await this.client.query({ - query: query, - variables: { - id: id - } - }); - if (res.errors && res.errors.length) { - throw res.errors[0]; - } else { - return res.data.delivery; - } -} + const res = await this.client.query({ + query: query, + variables: { + id: id + } + }); + if (res.errors && res.errors.length) { + throw res.errors[0]; + } else { + return res.data.delivery; + } + } public async listDeliveries() { const query = gql`