Skip to content

Commit

Permalink
feat: add types to custom attributes (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
ffMathy authored Aug 13, 2024
1 parent 1f45bb3 commit 1d2a046
Show file tree
Hide file tree
Showing 3 changed files with 210 additions and 17 deletions.
61 changes: 61 additions & 0 deletions source/__snapshots__/default-highway-test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1424,8 +1424,63 @@ export interface TypedContextSubtypeMap {
export type TypedContextSubtype = keyof TypedContextSubtypeMap;
export function getAttributeConfigurations() {
return [
{
name: "somedynamicenumerator",
type: "dynamic enumerator",
label: "Some Dynamic Enumerator",
entityType: "show",
default: [],
objectType: undefined,
isHierarchical: true,
},
{
name: "somedate",
type: "date",
label: "Some Date",
entityType: "show",
default: "2024-06-22T00:00:00.000Z",
objectType: undefined,
isHierarchical: true,
},
{
name: "sometext",
type: "text",
label: "Some Text",
entityType: "show",
default: "",
objectType: undefined,
isHierarchical: true,
},
{
name: "someurl",
type: "url",
label: "Some URL",
entityType: "asset",
default: null,
objectType: undefined,
isHierarchical: false,
},
{
name: "someenumerator",
type: "enumerator",
label: "Some Enumerator",
entityType: "show",
default: ["value1"],
objectType: undefined,
isHierarchical: true,
},
{
name: "someboolean",
type: "boolean",
label: "Some Boolean",
entityType: "show",
default: false,
objectType: undefined,
isHierarchical: true,
},
{
name: "fend",
type: "number",
label: "Frame end",
entityType: "task",
default: 1,
Expand All @@ -1434,6 +1489,7 @@ export function getAttributeConfigurations() {
},
{
name: "handles",
type: "number",
label: "Frame handles",
entityType: "task",
default: 0,
Expand All @@ -1442,6 +1498,7 @@ export function getAttributeConfigurations() {
},
{
name: "duration",
type: "expression",
label: "Frame duration",
entityType: "task",
default: "{self.fend - self.fstart + 1}",
Expand All @@ -1450,6 +1507,7 @@ export function getAttributeConfigurations() {
},
{
name: "fstart",
type: "number",
label: "Frame start",
entityType: "task",
default: 1,
Expand All @@ -1458,6 +1516,7 @@ export function getAttributeConfigurations() {
},
{
name: "fps",
type: "number",
label: "fps",
entityType: "show",
default: 24,
Expand All @@ -1466,6 +1525,7 @@ export function getAttributeConfigurations() {
},
{
name: "fps",
type: "number",
label: "fps",
entityType: "task",
default: 25,
Expand All @@ -1474,6 +1534,7 @@ export function getAttributeConfigurations() {
},
{
name: "fps",
type: "number",
label: "fps",
entityType: "task",
default: 25,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,102 @@
[
{
"__entity_type__": "CustomAttributeConfiguration",
"id": "1d995c42-c8b8-4879-88ce-996c4c991727",
"object_type": null,
"key": "somedynamicenumerator",
"entity_type": "show",
"label": "Some Dynamic Enumerator",
"project_id": null,
"type": {
"__entity_type__": "CustomAttributeType",
"id": "882e4aee-fae6-11e3-b623-20c9d0831e59",
"name": "dynamic enumerator"
},
"default": [],
"is_hierarchical": true
},
{
"__entity_type__": "CustomAttributeConfiguration",
"id": "2c835780-c006-41c5-b831-01c90a59ec20",
"object_type": null,
"key": "somedate",
"entity_type": "show",
"label": "Some Date",
"project_id": null,
"type": {
"__entity_type__": "CustomAttributeType",
"id": "79968e9e-381c-11e0-acff-0019bb49847a",
"name": "date"
},
"default": "2024-06-22T00:00:00.000Z",
"is_hierarchical": true
},
{
"__entity_type__": "CustomAttributeConfiguration",
"id": "404d70bb-c6d6-4588-9e1b-8fadedf0b153",
"object_type": null,
"key": "sometext",
"entity_type": "show",
"label": "Some Text",
"project_id": null,
"type": {
"__entity_type__": "CustomAttributeType",
"id": "6268aef0-381c-11e0-acff-0019bb49847a",
"name": "text"
},
"default": "",
"is_hierarchical": true
},
{
"__entity_type__": "CustomAttributeConfiguration",
"id": "84c3d4ac-747d-421e-9201-5c165c02f4ca",
"object_type": null,
"key": "someurl",
"entity_type": "asset",
"label": "Some URL",
"project_id": null,
"type": {
"__entity_type__": "CustomAttributeType",
"id": "ec616dcd-56e2-4147-99f8-7e4a4f040cf9",
"name": "url"
},
"default": null,
"is_hierarchical": false
},
{
"__entity_type__": "CustomAttributeConfiguration",
"id": "e5b221ae-e7cb-4a4f-82c0-d7afc8d5fdb1",
"object_type": null,
"key": "someenumerator",
"entity_type": "show",
"label": "Some Enumerator",
"project_id": null,
"type": {
"__entity_type__": "CustomAttributeType",
"id": "6ff9c812-ead3-11e2-846c-f23c91dfaa16",
"name": "enumerator"
},
"default": [
"value1"
],
"is_hierarchical": true
},
{
"__entity_type__": "CustomAttributeConfiguration",
"id": "f8f51553-b0a1-408e-82c7-508dd87de8ce",
"object_type": null,
"key": "someboolean",
"entity_type": "show",
"label": "Some Boolean",
"project_id": null,
"type": {
"__entity_type__": "CustomAttributeType",
"id": "ad1034d8-15e2-11e1-b21a-0019bb4983d8",
"name": "boolean"
},
"default": false,
"is_hierarchical": true
},
{
"__entity_type__": "CustomAttributeConfiguration",
"id": "432bc746-4087-11e2-8250-0019bb4983d8",
Expand All @@ -11,9 +109,13 @@
"entity_type": "task",
"label": "Frame end",
"project_id": null,
"type": {
"__entity_type__": "CustomAttributeType",
"id": "92009b00-381c-11e0-acff-0019bb49847a",
"name": "number"
},
"default": 1,
"is_hierarchical": false,
"values": []
"is_hierarchical": false
},
{
"__entity_type__": "CustomAttributeConfiguration",
Expand All @@ -27,9 +129,13 @@
"entity_type": "task",
"label": "Frame handles",
"project_id": null,
"type": {
"__entity_type__": "CustomAttributeType",
"id": "92009b00-381c-11e0-acff-0019bb49847a",
"name": "number"
},
"default": 0,
"is_hierarchical": false,
"values": []
"is_hierarchical": false
},
{
"__entity_type__": "CustomAttributeConfiguration",
Expand All @@ -43,9 +149,13 @@
"entity_type": "task",
"label": "Frame duration",
"project_id": null,
"type": {
"__entity_type__": "CustomAttributeType",
"id": "d2e6a530-357f-11e2-bd73-0019bb4985b8",
"name": "expression"
},
"default": "{self.fend - self.fstart + 1}",
"is_hierarchical": false,
"values": []
"is_hierarchical": false
},
{
"__entity_type__": "CustomAttributeConfiguration",
Expand All @@ -59,9 +169,13 @@
"entity_type": "task",
"label": "Frame start",
"project_id": null,
"type": {
"__entity_type__": "CustomAttributeType",
"id": "92009b00-381c-11e0-acff-0019bb49847a",
"name": "number"
},
"default": 1,
"is_hierarchical": false,
"values": []
"is_hierarchical": false
},
{
"__entity_type__": "CustomAttributeConfiguration",
Expand All @@ -71,9 +185,13 @@
"entity_type": "show",
"label": "fps",
"project_id": null,
"type": {
"__entity_type__": "CustomAttributeType",
"id": "92009b00-381c-11e0-acff-0019bb49847a",
"name": "number"
},
"default": 24,
"is_hierarchical": false,
"values": []
"is_hierarchical": false
},
{
"__entity_type__": "CustomAttributeConfiguration",
Expand All @@ -87,9 +205,13 @@
"entity_type": "task",
"label": "fps",
"project_id": null,
"type": {
"__entity_type__": "CustomAttributeType",
"id": "92009b00-381c-11e0-acff-0019bb49847a",
"name": "number"
},
"default": 25,
"is_hierarchical": false,
"values": []
"is_hierarchical": false
},
{
"__entity_type__": "CustomAttributeConfiguration",
Expand All @@ -103,8 +225,12 @@
"entity_type": "task",
"label": "fps",
"project_id": null,
"type": {
"__entity_type__": "CustomAttributeType",
"id": "92009b00-381c-11e0-acff-0019bb49847a",
"name": "number"
},
"default": 25,
"is_hierarchical": false,
"values": []
"is_hierarchical": false
}
]
]
10 changes: 8 additions & 2 deletions source/emit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,18 @@ export type CustomAttributeConfiguration = {
id: string;
name: string;
};
default: unknown;
default: boolean | string[] | string | number;
key: string;
entity_type: string;
label: string;
project_id: string | null;
is_hierarchical: boolean;
values: [];
type: {
__entity_type__: "CustomAttributeType";
id: string;
name: string;
}
};

export async function emitToString(
Expand Down Expand Up @@ -239,6 +244,7 @@ export async function emitToString(
${customAttributes.map(
(x) => `{
name: "${x.key}",
type: ${JSON.stringify(x.type?.name)},
label: "${x.label}",
entityType: "${x.entity_type}",
default: ${JSON.stringify(x.default)},
Expand Down Expand Up @@ -318,7 +324,7 @@ export async function emitToString(

async function getCustomAttributes(session: Session) {
const customAttributes = await session.query<CustomAttributeConfiguration>(
"select default, label, key, project_id, entity_type, is_hierarchical, object_type.name from CustomAttributeConfiguration order by sort"
"select default, label, key, project_id, entity_type, is_hierarchical, object_type.name, type.name from CustomAttributeConfiguration order by sort"
);
return customAttributes.data;
}
Expand Down

0 comments on commit 1d2a046

Please sign in to comment.