Skip to content

Commit 0751546

Browse files
further changes
1 parent 587db4b commit 0751546

File tree

9 files changed

+200
-34
lines changed

9 files changed

+200
-34
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import React, { useState } from 'react';
2+
import { DatatypeTag } from './../uicomp/tag';
3+
4+
const SchemaProperty = ({ name, property }: {name: string, property: any}) => {
5+
const [isExpanded, setIsExpanded] = useState(false);
6+
7+
const toggleExpand = () => setIsExpanded(!isExpanded);
8+
9+
const getType = (property: any) => {
10+
if (property.type === 'array' && property.items) {
11+
return `array of ${property.items.type}s`;
12+
}
13+
return property.type;
14+
};
15+
16+
const renderProperty = () => {
17+
if (property.type === 'object' && property.properties) {
18+
return (
19+
<div className="ml-4">
20+
<p><DatatypeTag label={getType(property)} /></p>
21+
<p>{property.description}</p>
22+
<button
23+
className="border border-slate-600 rounded-md px-3 py-2 text-xs"
24+
onClick={toggleExpand}
25+
>
26+
{isExpanded ? 'Hide child attributes' : 'Show child attributes'}
27+
</button>
28+
{isExpanded && (
29+
<SchemaObject schema={property.properties} />
30+
)}
31+
</div>
32+
);
33+
} else if (property.type === 'array' && property.items.type === 'object') {
34+
return (
35+
<div className="ml-4">
36+
<p><DatatypeTag label={getType(property)} /></p>
37+
<p>{property.description}</p>
38+
<button
39+
className="border border-slate-600 rounded-md px-3 py-2 text-xs"
40+
onClick={toggleExpand}
41+
>
42+
{isExpanded ? 'Hide child attributes' : 'Show child attributes'}
43+
</button>
44+
{isExpanded && (
45+
<>
46+
<SchemaObject schema={property.items.properties} />
47+
</>
48+
)}
49+
</div>
50+
);
51+
} else {
52+
return (
53+
<div className="ml-4">
54+
<p><DatatypeTag label={getType(property)} /></p>
55+
<p>{property.description || ''}</p>
56+
</div>
57+
);
58+
}
59+
};
60+
61+
return (
62+
<tr>
63+
<td className="border px-4 py-2 font-bold">{name}</td>
64+
<td className="border px-4 py-2">{renderProperty()}</td>
65+
</tr>
66+
);
67+
};
68+
69+
// Component to render the schema object
70+
const SchemaObject = ({ schema }: {schema: any}) => {
71+
return (
72+
<table className="min-w-full border-collapse rounded-md block md:table">
73+
<thead className="block md:table-header-group">
74+
<tr className="border md:table-row">
75+
<th className="block md:table-cell border px-4 py-2">Attribute</th>
76+
<th className="block md:table-cell border px-4 py-2">Description</th>
77+
</tr>
78+
</thead>
79+
<tbody className="block md:table-row-group">
80+
{Object.keys(schema).map((key) => (
81+
<SchemaProperty key={key} name={key} property={schema[key]} />
82+
))}
83+
</tbody>
84+
</table>
85+
);
86+
};
87+
88+
// Main component to render the JSON schema
89+
export const JSONSchemaRenderer = ({ schema }: {schema: any}) => {
90+
return (
91+
<div className="py-4">
92+
<SchemaObject schema={schema.properties} />
93+
</div>
94+
);
95+
};

components/uicomp/tag.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const getColorClass = (color: TagColor) => {
99
case TagColor.amber: return "bg-amber-50 text-amber-600"
1010
case TagColor.rose: return "bg-rose-50 text-rose-600"
1111
case TagColor.violet: return "bg-violet-50 text-violet-600"
12+
case TagColor.slate: return "bg-slate-700 text-slate-100"
1213
default: return "bg-neutral-50 text-neutral-600"
1314
}
1415
}
@@ -19,7 +20,8 @@ export const Tag = ({ label = "", color = TagColor.neutral, size = "sm", round =
1920
getColorClass(color),
2021
{
2122
"rounded": !round,
22-
"rounded-full": round,
23+
"rounded-full": round && size !== "xs",
24+
"rounded-md": round && size === "xs",
2325
"text-xs": size === "xs",
2426
"text-sm": size === "sm",
2527
"px-1": !round,
@@ -30,4 +32,8 @@ export const Tag = ({ label = "", color = TagColor.neutral, size = "sm", round =
3032

3133
export const FileTag = ({ label= "" }) => {
3234
return <Tag label={label} color={TagColor.fuchsia} />
35+
}
36+
37+
export const DatatypeTag = ({ label ="" }) => {
38+
return <Tag label={label} color={TagColor.slate} round={true} size="xs" />
3339
}

markdoc.components.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import YouTube from '@components/components/youtube'
3030
import Loom from '@components/components/loom'
3131
import AtomTable from '@components/components/atomTable'
3232
import ClassnamesTable from '@components/components/classnamesTable'
33+
import { JSONSchemaRenderer } from '@components/components/schemaTable'
3334

3435
export default {
3536
BorderedPanel,
@@ -62,5 +63,6 @@ export default {
6263
WrappedImage,
6364
YouTube,
6465
AtomTable,
65-
ClassnamesTable
66+
ClassnamesTable,
67+
JSONSchemaRenderer
6668
}

markdoc.config.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,14 @@ const config = {
295295
classnamesTable : {
296296
render: 'ClassnamesTable',
297297
attributes: { atom: { type: String } },
298-
}
298+
},
299+
jsonSchemaRenderer: {
300+
render: 'JSONSchemaRenderer',
301+
description: 'JSON schema renderer',
302+
attributes: {
303+
schema: { type: Object },
304+
},
305+
},
299306
},
300307
nodes: {
301308
fence: {

pages/enterprise-features/api/api-reference.mdoc

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,26 @@ Please note that the V1 API will be officially deprecated starting January 2025.
2121
- **Performance Improvements**: V2 has been optimized for better performance and scalability.
2222
- **User friendly response objects**: In V2 we have focused heavily on improving the response object for a better User Experience.
2323
- **Enhanced Security**: V2 includes improved security measures to protect your data.
24-
- **New Features**: V2 introduces new functionalities that are not present in V1, allowing you more flexibility with Cal.com application and usage.
24+
25+
### Admin access
26+
27+
With V2 we're supporting System Wide Admin access and Organization Admin access.
28+
29+
#### Key points
30+
31+
- The system wide admin has access to all resources via regular endpoints.
32+
- The organization admin has dedicated endpoints allowing them organization wide resource access. These endpoints follow the general path of `/organizations/:orgId/<resource>`.
33+
- The API Key can be created (here)[https://app.cal.com/settings/developer/api-keys] and depending on the role of the user, their API access will be settled. That is,
34+
- for a non-admin user, the API key created here will give them access to their own resources.
35+
- for a system wide admin, the API key created here will give them access to all resources, system-wide.
36+
- for an organization owner or admin, the API key created here will give them access to all resources, organization-wide.
2537

2638
We are committed to supporting our community during this transition. If you have any questions or need assistance with migrating to the V2 API, please refer to our [migration guide](#) or contact our support team.
2739

28-
Thank you for your understanding and cooperation.
40+
Thank you for your understanding and cooperation.
41+
42+
{% pageLink
43+
href="/enterprise-features/api/api-reference/v1"
44+
heading="Proceed to V1 Endpoints Spec" %}
45+
V1 Endpoints
46+
{% /pageLink %}

pages/enterprise-features/api/api-reference/v1/index.mdoc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,56 +10,56 @@ Hence, this page shows you which API routes are most useful in order to prevent
1010

1111
You'll need only a few of the routes to be able to cover the basic functionality.
1212

13-
{% pageLink href="/enterprise-features/api/api-reference/bookings "%}Bookings{% /pageLink %}
13+
{% pageLink href="/enterprise-features/api/api-reference/v1/bookings "%}Bookings{% /pageLink %}
1414

15-
{% pageLink href="/enterprise-features/api/api-reference/event-types "%}Event types{% /pageLink %}
15+
{% pageLink href="/enterprise-features/api/api-reference/v1/event-types "%}Event types{% /pageLink %}
1616

1717
## Managing users
1818

1919
The user endpoints can only be used on self-hosted enterprise instances and not on our hosted platform.
2020

21-
{% pageLink href="/enterprise-features/api/api-reference/users "%}Users{% /pageLink %}
21+
{% pageLink href="/enterprise-features/api/api-reference/v1/users "%}Users{% /pageLink %}
2222

2323
## Managing teams
2424

2525
The teams endpoints allow you to programmatically CRUD team data.
2626

27-
{% pageLink href="/enterprise-features/api/api-reference/teams "%}Teams{% /pageLink %}
27+
{% pageLink href="/enterprise-features/api/api-reference/v1/teams "%}Teams{% /pageLink %}
2828

2929
## The other stuff
3030

3131
Attendees allows you to CRUD the data related to who is attending a particular booking. Useful if you want to create events where many people are invited.
3232

33-
{% pageLink href="/enterprise-features/api/api-reference/attendees "%}Attendees{% /pageLink %}
33+
{% pageLink href="/enterprise-features/api/api-reference/v1/attendees "%}Attendees{% /pageLink %}
3434

3535
Schedules allows you to set out time blocks when you want to show availability.
3636

37-
{% pageLink href="/enterprise-features/api/api-reference/schedules "%}Schedules{% /pageLink %}
37+
{% pageLink href="/enterprise-features/api/api-reference/v1/schedules "%}Schedules{% /pageLink %}
3838

3939
Availabilities allows you to map schedules to an event type.
4040

41-
{% pageLink href="/enterprise-features/api/api-reference/availabilities "%}Availabilities{% /pageLink %}
41+
{% pageLink href="/enterprise-features/api/api-reference/v1/availabilities "%}Availabilities{% /pageLink %}
4242

4343
Booking references map meeting details to bookings.
4444

45-
{% pageLink href="/enterprise-features/api/api-reference/booking-references "%}Booking References{% /pageLink %}
45+
{% pageLink href="/enterprise-features/api/api-reference/v1/booking-references "%}Booking References{% /pageLink %}
4646

4747
Custom inputs allow you to control which custom inputs are required for your event types.
4848

49-
{% pageLink href="/enterprise-features/api/api-reference/custom-inputs "%}Custom inputs{% /pageLink %}
49+
{% pageLink href="/enterprise-features/api/api-reference/v1/custom-inputs "%}Custom inputs{% /pageLink %}
5050

5151
Destination calendars map bookings for event types to particular calendars.
5252

53-
{% pageLink href="/enterprise-features/api/api-reference/destination-calendars "%}Destination calendars{% /pageLink %}
53+
{% pageLink href="/enterprise-features/api/api-reference/v1/destination-calendars "%}Destination calendars{% /pageLink %}
5454

5555
Memberships control mappings of users to particular roles within teams.
5656

57-
{% pageLink href="/enterprise-features/api/api-reference/memberships "%}Memberships{% /pageLink %}
57+
{% pageLink href="/enterprise-features/api/api-reference/v1/memberships "%}Memberships{% /pageLink %}
5858

5959
Payments track the charges that are required to book certain events.
6060

61-
{% pageLink href="/enterprise-features/api/api-reference/payments "%}Payments{% /pageLink %}
61+
{% pageLink href="/enterprise-features/api/api-reference/v1/payments "%}Payments{% /pageLink %}
6262

6363
Selected calendars keeps track of which calendars should be checked for conflicts.
6464

65-
{% pageLink href="/enterprise-features/api/api-reference/selected-calendars "%}Selected calendars{% /pageLink %}
65+
{% pageLink href="/enterprise-features/api/api-reference/v1/selected-calendars "%}Selected calendars{% /pageLink %}

pages/enterprise-features/api/api-reference/v1/payments.mdoc

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,43 @@
22
title: Payments
33
---
44

5+
## Payment Object
6+
7+
{% jsonSchemaRenderer schema={
8+
properties: {
9+
available: {
10+
type: "array",
11+
description: "Available funds that you can transfer or pay out automatically by Stripe or explicitly through the Transfers API or Payouts API. You can find the available balance for each currency and payment type in the source_types property.",
12+
items: {
13+
type: "object",
14+
properties: {
15+
amount: { type: "integer", description: "Balance amount." },
16+
currency: { type: "string", description: "Three-letter ISO currency code, in lowercase. Must be a supported currency."}
17+
}
18+
}
19+
},
20+
pending: {
21+
type: "array",
22+
description: "Funds that aren't available in the balance yet. You can find the pending balance for each currency and each payment type in the source_types property.",
23+
items: {
24+
type: "object",
25+
properties: {
26+
amount: { type: "integer", description: "Balance amount." },
27+
currency: { type: "string", description: "Three-letter ISO currency code, in lowercase. Must be a supported currency." },
28+
source_types: {
29+
type: "object",
30+
properties: {
31+
bank_account: { type: "integer", description: "Amount for bank account." },
32+
card: { type: "integer", description: "Amount for card." },
33+
fpx: { type: "integer", description: "Amount for FPX." }
34+
}
35+
}
36+
}
37+
}
38+
}
39+
}
40+
} /%}
41+
542
You can use the payments endpoint in Cal.com's API suite track the charges that are required to book certain events.
643

744
## Find all payments

project-config.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -392,67 +392,67 @@ export default {
392392
pages: [
393393
{
394394
title: "Attendees",
395-
href: "/enterprise-features/api/api-reference/attendees",
395+
href: "/enterprise-features/api/api-reference/v1/attendees",
396396
},
397397
{
398398
title: "Availabilities",
399-
href: "/enterprise-features/api/api-reference/availabilities",
399+
href: "/enterprise-features/api/api-reference/v1/availabilities",
400400
},
401401
{
402402
title: "Availability",
403-
href: "/enterprise-features/api/api-reference/availability",
403+
href: "/enterprise-features/api/api-reference/v1/availability",
404404
},
405405
{
406406
title: "Booking References",
407-
href: "/enterprise-features/api/api-reference/booking-references",
407+
href: "/enterprise-features/api/api-reference/v1/booking-references",
408408
},
409409
{
410410
title: "Bookings",
411-
href: "/enterprise-features/api/api-reference/bookings",
411+
href: "/enterprise-features/api/api-reference/v1/bookings",
412412
},
413413
{
414414
title: "Destination calendars",
415-
href: "/enterprise-features/api/api-reference/destination-calendars",
415+
href: "/enterprise-features/api/api-reference/v1/destination-calendars",
416416
},
417417
{
418418
title: "Event types",
419-
href: "/enterprise-features/api/api-reference/event-types",
419+
href: "/enterprise-features/api/api-reference/v1/event-types",
420420
},
421421
{
422422
title: "Me",
423-
href: "/enterprise-features/api/api-reference/me",
423+
href: "/enterprise-features/api/api-reference/v1/me",
424424
},
425425
{
426426
title: "Memberships",
427-
href: "/enterprise-features/api/api-reference/memberships",
427+
href: "/enterprise-features/api/api-reference/v1/memberships",
428428
},
429429
{
430430
title: "Payments",
431-
href: "/enterprise-features/api/api-reference/payments",
431+
href: "/enterprise-features/api/api-reference/v1/payments",
432432
},
433433
{
434434
title: "Schedules",
435-
href: "/enterprise-features/api/api-reference/schedules",
435+
href: "/enterprise-features/api/api-reference/v1/schedules",
436436
},
437437
{
438438
title: "Selected calendars",
439-
href: "/enterprise-features/api/api-reference/selected-calendars",
439+
href: "/enterprise-features/api/api-reference/v1/selected-calendars",
440440
},
441441
{
442442
title: "Slots",
443-
href: "/enterprise-features/api/api-reference/slots",
443+
href: "/enterprise-features/api/api-reference/v1/slots",
444444
},
445445
{
446446
title: "Teams",
447-
href: "/enterprise-features/api/api-reference/teams",
447+
href: "/enterprise-features/api/api-reference/v1/teams",
448448
},
449449
{
450450
title: "Users",
451-
href: "/enterprise-features/api/api-reference/users",
451+
href: "/enterprise-features/api/api-reference/v1/users",
452452
},
453453
{
454454
title: "Webhooks",
455-
href: "/enterprise-features/api/api-reference/webhooks",
455+
href: "/enterprise-features/api/api-reference/v1/webhooks",
456456
}
457457
],
458458
},

utils/colors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ export enum TagColor {
66
rose = "rose",
77
violet = "violet",
88
neutral = "neutral",
9+
slate = "slate",
910
}

0 commit comments

Comments
 (0)