Skip to content

Commit

Permalink
Merge pull request #626 from karrioapi/patch-2024.6-rc21
Browse files Browse the repository at this point in the history
[rc21] UPS Package Description
  • Loading branch information
danh91 authored Jul 25, 2024
2 parents b8dca42 + 8687982 commit 34e1764
Show file tree
Hide file tree
Showing 29 changed files with 1,474 additions and 1,078 deletions.
2 changes: 1 addition & 1 deletion apps/api/karrio/server/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024.6-rc20
2024.6-rc21
58 changes: 35 additions & 23 deletions apps/dashboard/src/layouts/authenticated-page.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { CreateOrganizationModalProvider } from '@karrio/ui/modals/create-organization-modal';
import { AcceptInvitationProvider } from '@karrio/ui/modals/accept-invitation-modal';
import { forceSignOut, ServerError, ServerErrorCode } from '@karrio/lib';
import NextSessionProvider, { NextSession } from '@karrio/hooks/session';
import { ErrorBoundary } from '@karrio/ui/components/error-boudaries';
import { OrganizationProvider } from '@karrio/hooks/organization';
import { SubscriptionProvider } from '@karrio/hooks/subscription';
import { LoadingProvider } from '@karrio/ui/components/loader';
import { Notifier } from '@karrio/ui/components/notifier';
import AppModeProvider from '@karrio/hooks/app-mode';
import React, { useContext, useEffect } from 'react';
import { useRouter } from 'next/dist/client/router';

import { CreateOrganizationModalProvider } from "@karrio/ui/modals/create-organization-modal";
import { AcceptInvitationProvider } from "@karrio/ui/modals/accept-invitation-modal";
import { forceSignOut, ServerError, ServerErrorCode } from "@karrio/lib";
import NextSessionProvider, { NextSession } from "@karrio/hooks/session";
import { ErrorBoundary } from "@karrio/ui/components/error-boudaries";
import { OrganizationProvider } from "@karrio/hooks/organization";
import { SubscriptionProvider } from "@karrio/hooks/subscription";
import { LoadingProvider } from "@karrio/ui/components/loader";
import { Notifier } from "@karrio/ui/components/notifier";
import AppModeProvider from "@karrio/hooks/app-mode";
import React, { useContext, useEffect } from "react";
import { useRouter } from "next/dist/client/router";
import { useKarrio } from "@karrio/hooks/karrio";

const CONTEXT_PROVIDERS: React.FC<{ children?: React.ReactNode }>[] = [
OrganizationProvider,
Expand All @@ -19,9 +19,14 @@ const CONTEXT_PROVIDERS: React.FC<{ children?: React.ReactNode }>[] = [
LoadingProvider,
];


const ContextProviders: React.FC<{ children?: React.ReactNode }> = ({ children, ...props }) => {
const NestedContexts = CONTEXT_PROVIDERS.reduce((_, Ctx) => <Ctx {...props}>{_}</Ctx>, children);
const ContextProviders: React.FC<{ children?: React.ReactNode }> = ({
children,
...props
}) => {
const NestedContexts = CONTEXT_PROVIDERS.reduce(
(_, Ctx) => <Ctx {...props}>{_}</Ctx>,
children,
);

return (
<>
Expand All @@ -31,13 +36,22 @@ const ContextProviders: React.FC<{ children?: React.ReactNode }> = ({ children,
};

export const AuthenticatedPage = (content: any, pageProps?: any | {}) => {
const SessionWrapper: React.FC<{ error?: ServerError, children?: React.ReactNode }> = ({ children, error }) => {
const SessionWrapper: React.FC<{
error?: ServerError;
children?: React.ReactNode;
}> = ({ children, error }) => {
const router = useRouter();
const karrio = useKarrio();
const session = useContext(NextSession);

useEffect(() => {
if (session === null || (session as any)?.error === "RefreshAccessTokenError") {
router.push('/login?next=' + window.location.pathname + window.location.search);
if (
session === null ||
(session as any)?.error === "RefreshAccessTokenError"
) {
router.push(
"/login?next=" + window.location.pathname + window.location.search,
);
}
if (error?.code === ServerErrorCode.API_AUTH_ERROR) {
forceSignOut();
Expand All @@ -48,7 +62,7 @@ export const AuthenticatedPage = (content: any, pageProps?: any | {}) => {
<>
<ContextProviders {...(pageProps || {})}>
<ErrorBoundary>
{session && children}
{session && karrio?.isAuthenticated && children}
</ErrorBoundary>
</ContextProviders>
</>
Expand All @@ -60,12 +74,10 @@ export const AuthenticatedPage = (content: any, pageProps?: any | {}) => {
<SessionWrapper {...(pageProps || {})}>
<AcceptInvitationProvider>
<CreateOrganizationModalProvider>

{content}

</CreateOrganizationModalProvider>
</AcceptInvitationProvider>
</SessionWrapper>
</NextSessionProvider>
)
);
};
1 change: 0 additions & 1 deletion apps/dashboard/src/layouts/section-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const SectionLayout: React.FC<SectionLayoutProps> = ({
error,
children,
}) => {
console.log("metadata", metadata);
return (
<MainLayout error={error}>
<section className="hero is-fullheight">
Expand Down
2 changes: 1 addition & 1 deletion apps/www/docs/reference/api/create-orders.api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,7 @@ Create order batch. `Beta`
value={"Example (from schema)"}
>
<ResponseSamples
responseExample={"{\n \"id\": \"string\",\n \"status\": \"queued\",\n \"resource_type\": \"orders\",\n \"resources\": [\n {\n \"id\": \"string\",\n \"status\": \"queued\",\n \"errors\": {}\n }\n ],\n \"created_at\": \"2024-07-23T18:58:00.098Z\",\n \"updated_at\": \"2024-07-23T18:58:00.098Z\",\n \"test_mode\": true\n}"}
responseExample={"{\n \"id\": \"string\",\n \"status\": \"queued\",\n \"resource_type\": \"orders\",\n \"resources\": [\n {\n \"id\": \"string\",\n \"status\": \"queued\",\n \"errors\": {}\n }\n ],\n \"created_at\": \"2024-07-25T17:11:44.008Z\",\n \"updated_at\": \"2024-07-25T17:11:44.008Z\",\n \"test_mode\": true\n}"}
language={"json"}
>

Expand Down
2 changes: 1 addition & 1 deletion apps/www/docs/reference/api/create-shipments.api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2266,7 +2266,7 @@ Create shipment batch. `Beta`
value={"Example (from schema)"}
>
<ResponseSamples
responseExample={"{\n \"id\": \"string\",\n \"status\": \"queued\",\n \"resource_type\": \"orders\",\n \"resources\": [\n {\n \"id\": \"string\",\n \"status\": \"queued\",\n \"errors\": {}\n }\n ],\n \"created_at\": \"2024-07-23T18:58:00.102Z\",\n \"updated_at\": \"2024-07-23T18:58:00.102Z\",\n \"test_mode\": true\n}"}
responseExample={"{\n \"id\": \"string\",\n \"status\": \"queued\",\n \"resource_type\": \"orders\",\n \"resources\": [\n {\n \"id\": \"string\",\n \"status\": \"queued\",\n \"errors\": {}\n }\n ],\n \"created_at\": \"2024-07-25T17:11:44.012Z\",\n \"updated_at\": \"2024-07-25T17:11:44.012Z\",\n \"test_mode\": true\n}"}
language={"json"}
>

Expand Down
2 changes: 1 addition & 1 deletion apps/www/docs/reference/api/create-trackers.api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ Create tracker batch. `Beta`
value={"Example (from schema)"}
>
<ResponseSamples
responseExample={"{\n \"id\": \"string\",\n \"status\": \"queued\",\n \"resource_type\": \"orders\",\n \"resources\": [\n {\n \"id\": \"string\",\n \"status\": \"queued\",\n \"errors\": {}\n }\n ],\n \"created_at\": \"2024-07-23T18:58:00.104Z\",\n \"updated_at\": \"2024-07-23T18:58:00.104Z\",\n \"test_mode\": true\n}"}
responseExample={"{\n \"id\": \"string\",\n \"status\": \"queued\",\n \"resource_type\": \"orders\",\n \"resources\": [\n {\n \"id\": \"string\",\n \"status\": \"queued\",\n \"errors\": {}\n }\n ],\n \"created_at\": \"2024-07-25T17:11:44.014Z\",\n \"updated_at\": \"2024-07-25T17:11:44.014Z\",\n \"test_mode\": true\n}"}
language={"json"}
>

Expand Down
2 changes: 1 addition & 1 deletion apps/www/docs/reference/api/create-webhook.api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ Create a new webhook.
value={"Example (from schema)"}
>
<ResponseSamples
responseExample={"{\n \"id\": \"string\",\n \"url\": \"string\",\n \"description\": \"string\",\n \"enabled_events\": [\n \"all\"\n ],\n \"disabled\": true,\n \"object_type\": \"webhook\",\n \"last_event_at\": \"2024-07-23T18:58:00.348Z\",\n \"secret\": \"string\",\n \"test_mode\": true\n}"}
responseExample={"{\n \"id\": \"string\",\n \"url\": \"string\",\n \"description\": \"string\",\n \"enabled_events\": [\n \"all\"\n ],\n \"disabled\": true,\n \"object_type\": \"webhook\",\n \"last_event_at\": \"2024-07-25T17:11:44.269Z\",\n \"secret\": \"string\",\n \"test_mode\": true\n}"}
language={"json"}
>

Expand Down
2 changes: 1 addition & 1 deletion apps/www/docs/reference/api/import-file.api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ the import progression.**
value={"Example (from schema)"}
>
<ResponseSamples
responseExample={"{\n \"id\": \"string\",\n \"status\": \"queued\",\n \"resource_type\": \"orders\",\n \"resources\": [\n {\n \"id\": \"string\",\n \"status\": \"queued\",\n \"errors\": {}\n }\n ],\n \"created_at\": \"2024-07-23T18:58:00.094Z\",\n \"updated_at\": \"2024-07-23T18:58:00.094Z\",\n \"test_mode\": true\n}"}
responseExample={"{\n \"id\": \"string\",\n \"status\": \"queued\",\n \"resource_type\": \"orders\",\n \"resources\": [\n {\n \"id\": \"string\",\n \"status\": \"queued\",\n \"errors\": {}\n }\n ],\n \"created_at\": \"2024-07-25T17:11:44.003Z\",\n \"updated_at\": \"2024-07-25T17:11:44.003Z\",\n \"test_mode\": true\n}"}
language={"json"}
>

Expand Down
2 changes: 1 addition & 1 deletion apps/www/docs/reference/api/list-batch-operations.api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ Retrieve all batch operations. `Beta`
value={"Example (from schema)"}
>
<ResponseSamples
responseExample={"{\n \"count\": 0,\n \"next\": \"string\",\n \"previous\": \"string\",\n \"results\": [\n {\n \"id\": \"string\",\n \"status\": \"queued\",\n \"resource_type\": \"orders\",\n \"resources\": [\n {\n \"id\": \"string\",\n \"status\": \"queued\",\n \"errors\": {}\n }\n ],\n \"created_at\": \"2024-07-23T18:58:00.095Z\",\n \"updated_at\": \"2024-07-23T18:58:00.095Z\",\n \"test_mode\": true\n }\n ]\n}"}
responseExample={"{\n \"count\": 0,\n \"next\": \"string\",\n \"previous\": \"string\",\n \"results\": [\n {\n \"id\": \"string\",\n \"status\": \"queued\",\n \"resource_type\": \"orders\",\n \"resources\": [\n {\n \"id\": \"string\",\n \"status\": \"queued\",\n \"errors\": {}\n }\n ],\n \"created_at\": \"2024-07-25T17:11:44.004Z\",\n \"updated_at\": \"2024-07-25T17:11:44.004Z\",\n \"test_mode\": true\n }\n ]\n}"}
language={"json"}
>

Expand Down
2 changes: 1 addition & 1 deletion apps/www/docs/reference/api/list-webhooks.api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ Retrieve all webhooks.
value={"Example (from schema)"}
>
<ResponseSamples
responseExample={"{\n \"count\": 0,\n \"next\": \"string\",\n \"previous\": \"string\",\n \"results\": [\n {\n \"id\": \"string\",\n \"url\": \"string\",\n \"description\": \"string\",\n \"enabled_events\": [\n \"all\"\n ],\n \"disabled\": true,\n \"object_type\": \"webhook\",\n \"last_event_at\": \"2024-07-23T18:58:00.347Z\",\n \"secret\": \"string\",\n \"test_mode\": true\n }\n ]\n}"}
responseExample={"{\n \"count\": 0,\n \"next\": \"string\",\n \"previous\": \"string\",\n \"results\": [\n {\n \"id\": \"string\",\n \"url\": \"string\",\n \"description\": \"string\",\n \"enabled_events\": [\n \"all\"\n ],\n \"disabled\": true,\n \"object_type\": \"webhook\",\n \"last_event_at\": \"2024-07-25T17:11:44.268Z\",\n \"secret\": \"string\",\n \"test_mode\": true\n }\n ]\n}"}
language={"json"}
>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ Retrieve a batch operation. `Beta`
value={"Example (from schema)"}
>
<ResponseSamples
responseExample={"{\n \"id\": \"string\",\n \"status\": \"queued\",\n \"resource_type\": \"orders\",\n \"resources\": [\n {\n \"id\": \"string\",\n \"status\": \"queued\",\n \"errors\": {}\n }\n ],\n \"created_at\": \"2024-07-23T18:58:00.096Z\",\n \"updated_at\": \"2024-07-23T18:58:00.096Z\",\n \"test_mode\": true\n}"}
responseExample={"{\n \"id\": \"string\",\n \"status\": \"queued\",\n \"resource_type\": \"orders\",\n \"resources\": [\n {\n \"id\": \"string\",\n \"status\": \"queued\",\n \"errors\": {}\n }\n ],\n \"created_at\": \"2024-07-25T17:11:44.006Z\",\n \"updated_at\": \"2024-07-25T17:11:44.006Z\",\n \"test_mode\": true\n}"}
language={"json"}
>

Expand Down
2 changes: 1 addition & 1 deletion apps/www/docs/reference/api/retrieve-webhook.api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ Retrieve a webhook.
value={"Example (from schema)"}
>
<ResponseSamples
responseExample={"{\n \"id\": \"string\",\n \"url\": \"string\",\n \"description\": \"string\",\n \"enabled_events\": [\n \"all\"\n ],\n \"disabled\": true,\n \"object_type\": \"webhook\",\n \"last_event_at\": \"2024-07-23T18:58:00.349Z\",\n \"secret\": \"string\",\n \"test_mode\": true\n}"}
responseExample={"{\n \"id\": \"string\",\n \"url\": \"string\",\n \"description\": \"string\",\n \"enabled_events\": [\n \"all\"\n ],\n \"disabled\": true,\n \"object_type\": \"webhook\",\n \"last_event_at\": \"2024-07-25T17:11:44.270Z\",\n \"secret\": \"string\",\n \"test_mode\": true\n}"}
language={"json"}
>

Expand Down
2 changes: 1 addition & 1 deletion apps/www/docs/reference/api/update-webhook.api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ update a webhook.
value={"Example (from schema)"}
>
<ResponseSamples
responseExample={"{\n \"id\": \"string\",\n \"url\": \"string\",\n \"description\": \"string\",\n \"enabled_events\": [\n \"all\"\n ],\n \"disabled\": true,\n \"object_type\": \"webhook\",\n \"last_event_at\": \"2024-07-23T18:58:00.350Z\",\n \"secret\": \"string\",\n \"test_mode\": true\n}"}
responseExample={"{\n \"id\": \"string\",\n \"url\": \"string\",\n \"description\": \"string\",\n \"enabled_events\": [\n \"all\"\n ],\n \"disabled\": true,\n \"object_type\": \"webhook\",\n \"last_event_at\": \"2024-07-25T17:11:44.271Z\",\n \"secret\": \"string\",\n \"test_mode\": true\n}"}
language={"json"}
>

Expand Down
4 changes: 2 additions & 2 deletions bin/deploy-hobby
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

export KARRIO_TAG="${KARRIO_TAG:-2024.6-rc20}"
export KARRIO_TAG="${KARRIO_TAG:-2024.6-rc21}"
export SENTRY_DSN="${SENTRY_DSN:-'https://[email protected]/1'}"

SECRET_KEY=$(head -c 28 /dev/urandom | sha224sum -b | head -c 56)
Expand All @@ -23,7 +23,7 @@ if ! [ -z "$1" ]
then
export KARRIO_TAG=$1
else
echo "What version of Karrio would you like to install? (We default to '2024.6-rc20')"
echo "What version of Karrio would you like to install? (We default to '2024.6-rc21')"
echo "You can check out available versions here: https://hub.docker.com/r/karrio/server/tags"
read -r KARRIO_TAG_READ
if [ -z "$KARRIO_TAG_READ" ]
Expand Down
2 changes: 1 addition & 1 deletion bin/upgrade-hobby
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ else
fi

[[ -f ".env" ]] && export $(cat .env | xargs) || ( echo "No .env file found. Please create it with SECRET_KEY and DOMAIN set." && exit 1)
export KARRIO_TAG="${KARRIO_TAG:-2024.6-rc20}"
export KARRIO_TAG="${KARRIO_TAG:-2024.6-rc21}"

# get karrio scripts
mkdir -p ./karrio
Expand Down
6 changes: 3 additions & 3 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
api:
container_name: karrio.api
image: karrio.docker.scarf.sh/karrio/server:2024.6-rc20
image: karrio.docker.scarf.sh/karrio/server:2024.6-rc21
restart: unless-stopped
ports:
- ${KARRIO_HTTP_PORT}:${KARRIO_HTTP_PORT}
Expand All @@ -24,7 +24,7 @@ services:

worker:
container_name: karrio.worker
image: karrio.docker.scarf.sh/karrio/server:2024.6-rc20
image: karrio.docker.scarf.sh/karrio/server:2024.6-rc21
restart: unless-stopped
depends_on:
- db
Expand All @@ -44,7 +44,7 @@ services:

dashboard:
container_name: karrio.dashboard
image: karrio.docker.scarf.sh/karrio/dashboard:2024.6-rc20
image: karrio.docker.scarf.sh/karrio/dashboard:2024.6-rc21
restart: unless-stopped
ports:
- ${DASHBOARD_PORT}:3000/tcp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ def shipment_request(
ShipmentDate=None,
Package=[
ups.PackageType(
Description=package.description,
Packaging=ups.LabelImageFormatType(
Code=(
mps_packaging
Expand All @@ -587,7 +588,7 @@ def shipment_request(
),
Description="Packaging Type",
),
Dimensions=(
Dimensions=lib.identity(
ups.DimensionsType(
UnitOfMeasurement=ups.LabelImageFormatType(
Code=package.dimension_unit.value,
Expand Down
2 changes: 1 addition & 1 deletion modules/connectors/ups/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="karrio.ups",
version="2024.6-rc9",
version="2024.6-rc21",
description="Karrio - UPS Shipping extension",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
2 changes: 2 additions & 0 deletions modules/connectors/ups/tests/ups/test_shipment.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ def test_parse_cancel_shipment_response(self):
"NumOfPiecesInShipment": "0",
"Package": [
{
"Description": "Description",
"Dimensions": {
"Height": "2.0",
"Length": "7.0",
Expand Down Expand Up @@ -309,6 +310,7 @@ def test_parse_cancel_shipment_response(self):
"NumOfPiecesInShipment": "0",
"Package": [
{
"Description": "Description",
"Dimensions": {
"Height": "11.0",
"Length": "3.0",
Expand Down
13 changes: 8 additions & 5 deletions packages/hooks/karrio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type ClientProviderProps = {
children?: React.ReactNode;
};
type APIClientsContextProps = KarrioClient & {
isAuthenticated?: boolean;
pageData?: {
orgId?: string;
user?: UserType;
Expand All @@ -35,17 +36,19 @@ export const ClientProvider: React.FC<ClientProviderProps> = ({
children,
...pageData
}) => {
const { getHost } = useAPIMetadata();
const { getHost, references } = useAPIMetadata();
const {
query: { data: session },
} = useSyncedSession();
const updateClient = (ref: any, session: any) => ({
...setupRestClient(getHost(), session),
isAuthenticated: !!session?.accessToken,
pageData,
});

if (!getHost || !getHost()) return <></>;

return (
<APIClientsContext.Provider
value={{ ...setupRestClient(getHost(), session), pageData }}
>
<APIClientsContext.Provider value={updateClient(references, session)}>
{children}
</APIClientsContext.Provider>
);
Expand Down
Loading

0 comments on commit 34e1764

Please sign in to comment.