@ynput/ayon-addon-planner 0.0.0-stage → 0.1.0
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/LICENSE +105 -0
- package/README.md +134 -2
- package/components.d.ts +9 -0
- package/components.js +14 -0
- package/examples/BookingEventFormHeaderItem.js +17 -0
- package/examples/TimelineEventBadge.js +23 -0
- package/examples/TimelineEventEndItem.js +22 -0
- package/examples/shared.js +14 -0
- package/index.d.ts +273 -0
- package/index.js +74 -0
- package/package.json +79 -4
- package/previews.d.ts +65 -0
- package/previews.js +11688 -0
- package/slots.d.ts +4 -0
- package/slots.js +78 -0
package/index.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { slots } from "./slots.js";
|
|
2
|
+
|
|
3
|
+
export { slots };
|
|
4
|
+
|
|
5
|
+
// each helper stamps the version its slot is declared with in slots.js, so it is written once
|
|
6
|
+
const helper = (name) => {
|
|
7
|
+
const declaration = slots.find((slot) => slot.name === name);
|
|
8
|
+
if (!declaration) throw new Error(`@ynput/ayon-addon-planner: no slot ${name} in slots.js`);
|
|
9
|
+
return (item) => ({ ...item, slot: name, slotVersion: declaration.version });
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const plannerTaskEventMenuItem = helper("planner.taskEventMenuItem");
|
|
13
|
+
|
|
14
|
+
export const plannerBookingEventMenuItem = helper("planner.bookingEventMenuItem");
|
|
15
|
+
|
|
16
|
+
export const plannerBookingEventFormHeaderItem = helper("planner.bookingEventFormHeaderItem");
|
|
17
|
+
|
|
18
|
+
export const plannerTimelineEventBadge = helper("planner.timelineEventBadge");
|
|
19
|
+
|
|
20
|
+
export const plannerTimelineEventEndItem = helper("planner.timelineEventEndItem");
|
|
21
|
+
|
|
22
|
+
// --- the slots' contexts ----------------------------------------------------------------------
|
|
23
|
+
// The planner builds its contexts with these, and so do the previews: a context only has the
|
|
24
|
+
// fields index.d.ts declares, and a field the event doesn't have is left out, not undefined.
|
|
25
|
+
|
|
26
|
+
const defined = (object) =>
|
|
27
|
+
Object.fromEntries(Object.entries(object).filter(([, value]) => value !== undefined && value !== null));
|
|
28
|
+
|
|
29
|
+
export const toBookingEventResource = (resource) =>
|
|
30
|
+
defined({
|
|
31
|
+
id: resource.id,
|
|
32
|
+
label: resource.label || resource.id,
|
|
33
|
+
resourceType: resource.resourceType,
|
|
34
|
+
isPool: resource.isPool,
|
|
35
|
+
unitCount: resource.unitCount,
|
|
36
|
+
userName: resource.userName,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export const toBookingEventRef = (event) => ({
|
|
40
|
+
...defined({
|
|
41
|
+
id: event.id,
|
|
42
|
+
eventType: event.eventType,
|
|
43
|
+
label: event.label,
|
|
44
|
+
startTime: event.startTime,
|
|
45
|
+
endTime: event.endTime,
|
|
46
|
+
netDuration: event.netDuration,
|
|
47
|
+
status: event.status || undefined,
|
|
48
|
+
attrib: event.attrib,
|
|
49
|
+
resources: event.resources?.map(toBookingEventResource),
|
|
50
|
+
}),
|
|
51
|
+
projectName: event.projectName || null,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export const toTaskEventRef = (event, projectName) =>
|
|
55
|
+
defined({
|
|
56
|
+
id: event.id,
|
|
57
|
+
eventType: "task",
|
|
58
|
+
label: event.label,
|
|
59
|
+
projectName,
|
|
60
|
+
taskId: event.task?.id,
|
|
61
|
+
startTime: event.startTime,
|
|
62
|
+
endTime: event.endTime,
|
|
63
|
+
people: event.people,
|
|
64
|
+
tags: event.tags,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export const toTaskRef = (task, projectName) =>
|
|
68
|
+
defined({
|
|
69
|
+
id: task.id,
|
|
70
|
+
entityType: "task",
|
|
71
|
+
projectName,
|
|
72
|
+
name: task.name,
|
|
73
|
+
label: task.label,
|
|
74
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,81 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ynput/ayon-addon-planner",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Contract for addons extending the AYON planner: slot types and declarations, and previews of its slots for the AYON dev shell",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/ynput/ayon-server-production-planner.git",
|
|
8
|
+
"directory": "frontend/contract"
|
|
9
|
+
},
|
|
10
|
+
"license": "FSL-1.1-ALv2",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"module": "./index.js",
|
|
13
|
+
"types": "./index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./index.d.ts",
|
|
17
|
+
"import": "./index.js"
|
|
18
|
+
},
|
|
19
|
+
"./slots": {
|
|
20
|
+
"types": "./slots.d.ts",
|
|
21
|
+
"import": "./slots.js"
|
|
22
|
+
},
|
|
23
|
+
"./components": {
|
|
24
|
+
"types": "./components.d.ts",
|
|
25
|
+
"import": "./components.js"
|
|
26
|
+
},
|
|
27
|
+
"./previews": {
|
|
28
|
+
"types": "./previews.d.ts",
|
|
29
|
+
"import": "./previews.js"
|
|
30
|
+
},
|
|
31
|
+
"./package.json": "./package.json"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"index.js",
|
|
35
|
+
"index.d.ts",
|
|
36
|
+
"slots.js",
|
|
37
|
+
"slots.d.ts",
|
|
38
|
+
"components.js",
|
|
39
|
+
"components.d.ts",
|
|
40
|
+
"previews.js",
|
|
41
|
+
"previews.d.ts",
|
|
42
|
+
"examples",
|
|
43
|
+
"README.md",
|
|
44
|
+
"LICENSE"
|
|
45
|
+
],
|
|
46
|
+
"ayonAddon": {
|
|
47
|
+
"slots": "./slots.js",
|
|
48
|
+
"previews": "./previews.js"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"prepack": "cd .. && yarn build:contract"
|
|
52
|
+
},
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"@ynput/ayon-addon": ">=0.7.0-next.0",
|
|
58
|
+
"@ynput/ayon-frontend-shared": ">=0.8.0",
|
|
59
|
+
"@ynput/ayon-react-components": ">=1.26.0",
|
|
60
|
+
"react": ">=18",
|
|
61
|
+
"react-dom": ">=18",
|
|
62
|
+
"styled-components": ">=6"
|
|
63
|
+
},
|
|
64
|
+
"peerDependenciesMeta": {
|
|
65
|
+
"@ynput/ayon-frontend-shared": {
|
|
66
|
+
"optional": true
|
|
67
|
+
},
|
|
68
|
+
"@ynput/ayon-react-components": {
|
|
69
|
+
"optional": true
|
|
70
|
+
},
|
|
71
|
+
"react": {
|
|
72
|
+
"optional": true
|
|
73
|
+
},
|
|
74
|
+
"react-dom": {
|
|
75
|
+
"optional": true
|
|
76
|
+
},
|
|
77
|
+
"styled-components": {
|
|
78
|
+
"optional": true
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
package/previews.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { ComponentType } from "react";
|
|
2
|
+
// adds the planner's slots to `SlotMap`
|
|
3
|
+
import "./index.js";
|
|
4
|
+
|
|
5
|
+
/** The planner's slots. */
|
|
6
|
+
export type PlannerSlotName =
|
|
7
|
+
| "planner.taskEventMenuItem"
|
|
8
|
+
| "planner.bookingEventMenuItem"
|
|
9
|
+
| "planner.bookingEventFormHeaderItem"
|
|
10
|
+
| "planner.timelineEventBadge"
|
|
11
|
+
| "planner.timelineEventEndItem";
|
|
12
|
+
|
|
13
|
+
/** What a `pick` field can ask the server, through the dev shell. */
|
|
14
|
+
export interface PreviewApi {
|
|
15
|
+
fetch(path: string, init?: RequestInit): Promise<Response>;
|
|
16
|
+
/** `/api/addons/<name>/<version>` of an installed addon, or null */
|
|
17
|
+
addonUrl(name: string): string | null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** A field of a scene's context, which the dev shell shows as a form. */
|
|
21
|
+
export type PreviewField = { key: string; label: string; hint?: string } & (
|
|
22
|
+
| { type: "text"; default?: string }
|
|
23
|
+
| { type: "number"; default?: number }
|
|
24
|
+
| { type: "boolean"; default?: boolean }
|
|
25
|
+
| { type: "select"; options: { value: string; label: string }[]; default?: string }
|
|
26
|
+
| { type: "multiselect"; options: { value: string; label: string }[]; default?: string[] }
|
|
27
|
+
| { type: "json"; default?: unknown }
|
|
28
|
+
/** one of the server's projects; `optional` adds "No project" (null) */
|
|
29
|
+
| { type: "project"; optional?: boolean; default?: string | null }
|
|
30
|
+
/** a real entity from the server, in the project of the field `project` names */
|
|
31
|
+
| {
|
|
32
|
+
type: "entity";
|
|
33
|
+
entityType: "task" | "folder" | "product" | "version";
|
|
34
|
+
project: string;
|
|
35
|
+
}
|
|
36
|
+
/** a choice loaded from the server; choosing one patches the values */
|
|
37
|
+
| {
|
|
38
|
+
type: "pick";
|
|
39
|
+
load: (
|
|
40
|
+
api: PreviewApi,
|
|
41
|
+
values: Record<string, any>,
|
|
42
|
+
) => Promise<{ value: string; label: string; values: Record<string, any> }[]>;
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
/** A piece of the planner's UI that renders some of its slots, with a context built from `values`. */
|
|
47
|
+
export interface PreviewScene {
|
|
48
|
+
id: string;
|
|
49
|
+
label: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
/** the planner's slots the scene renders */
|
|
52
|
+
slots: PlannerSlotName[];
|
|
53
|
+
fields: PreviewField[];
|
|
54
|
+
component: ComponentType<{
|
|
55
|
+
values: Record<string, any>;
|
|
56
|
+
setValues: (patch: Record<string, any>) => void;
|
|
57
|
+
}>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The planner's scenes for the AYON dev shell (`ayonAddon.previews` in package.json): a booking
|
|
62
|
+
* event on the Plan page (`bookingEvent`) and a task event on the Schedule page (`taskEvent`),
|
|
63
|
+
* drawn by the planner's own components.
|
|
64
|
+
*/
|
|
65
|
+
export declare const previews: PreviewScene[];
|