Skip to content

Commit 5269b63

Browse files
zman81988GitHub Enterprise
authored and
GitHub Enterprise
committed
Merge pull request #16 from zradford/read-only-properties
Read only properties
2 parents c36b428 + 3462e70 commit 5269b63

File tree

5 files changed

+62
-12
lines changed

5 files changed

+62
-12
lines changed

prisma/schema.prisma

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ generator client {
88
}
99

1010
model Mapping {
11-
id Int @id @default(autoincrement())
12-
nativeName String @db.VarChar(255)
13-
hubspotName String? @db.VarChar(255)
14-
hubspotLabel String? @db.VarChar(255)
15-
object Objects
16-
customerId String @db.VarChar(255)
17-
direction Direction
11+
id Int @id @default(autoincrement())
12+
nativeName String @db.VarChar(255)
13+
hubspotName String? @db.VarChar(255)
14+
hubspotLabel String? @db.VarChar(255)
15+
object Objects
16+
customerId String @db.VarChar(255)
17+
direction Direction
18+
modificationMetadata Json
1819
1920
@@unique([nativeName, object, customerId])
2021
}
@@ -29,11 +30,12 @@ model Authorization {
2930
}
3031

3132
model Properties {
32-
name String @db.VarChar(255)
33-
label String? @db.VarChar(255)
34-
type PropertyType
35-
object Objects
36-
customerId String @db.VarChar(255)
33+
name String @db.VarChar(255)
34+
label String? @db.VarChar(255)
35+
type PropertyType
36+
object Objects
37+
customerId String @db.VarChar(255)
38+
modificationMetadata Json
3739
3840
@@unique([name, object, customerId])
3941
}

prisma/seed.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ async function main(): Promise {
1717
type: "String",
1818
object: "Contact",
1919
customerId: "1",
20+
modificationMetadata:{
21+
archivable: true,
22+
readOnlyDefinition: false,
23+
readOnlyValue: false,
24+
}
25+
2026
},
2127
});
2228
console.log(firstname);
@@ -36,6 +42,11 @@ async function main(): Promise {
3642
type: "String",
3743
object: "Contact",
3844
customerId: "1",
45+
modificationMetadata:{
46+
archivable: true,
47+
readOnlyDefinition: false,
48+
readOnlyValue: false,
49+
}
3950
},
4051
});
4152
console.log(lastname);
@@ -54,6 +65,11 @@ async function main(): Promise {
5465
type: "String",
5566
object: "Contact",
5667
customerId: "1",
68+
modificationMetadata:{
69+
archivable: true,
70+
readOnlyDefinition: false,
71+
readOnlyValue: false,
72+
}
5773
},
5874
});
5975
console.log(exampleCustom);
@@ -72,6 +88,11 @@ async function main(): Promise {
7288
type: "String",
7389
object: "Contact",
7490
customerId: "1",
91+
modificationMetadata:{
92+
archivable: true,
93+
readOnlyDefinition: false,
94+
readOnlyValue: true,
95+
}
7596
},
7697
});
7798
console.log(exampleRequired);
@@ -90,6 +111,11 @@ async function main(): Promise {
90111
type: "String",
91112
object: "Company",
92113
customerId: "1",
114+
modificationMetadata:{
115+
archivable: true,
116+
readOnlyDefinition: false,
117+
readOnlyValue: false,
118+
}
93119
},
94120
});
95121
console.log(customCompany);
@@ -108,6 +134,11 @@ async function main(): Promise {
108134
type: "String",
109135
object: "Company",
110136
customerId: "1",
137+
modificationMetadata:{
138+
archivable: true,
139+
readOnlyDefinition: false,
140+
readOnlyValue: false,
141+
}
111142
},
112143
});
113144
console.log(companyName);
@@ -126,6 +157,11 @@ async function main(): Promise {
126157
type: "String",
127158
object: "Company",
128159
customerId: "1",
160+
modificationMetadata:{
161+
archivable: true,
162+
readOnlyDefinition: false,
163+
readOnlyValue: false,
164+
}
129165
},
130166
});
131167
console.log(industry);
@@ -144,6 +180,11 @@ async function main(): Promise {
144180
type: "Number",
145181
object: "Company",
146182
customerId: "1",
183+
modificationMetadata:{
184+
archivable: true,
185+
readOnlyDefinition: false,
186+
readOnlyValue: false,
187+
}
147188
},
148189
});
149190
console.log(num_employees);

src/mappings.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const getMappings = async (customerId: string): Promise =
1212
object: true,
1313
direction: true,
1414
customerId: true,
15+
modificationMetadata:true,
1516
},
1617
where: {
1718
customerId,
@@ -47,6 +48,7 @@ const saveMapping = async (maybeMapping: Mapping): Promise
4748
const hubspotLabel = maybeMapping.hubspotLabel;
4849
const object = maybeMapping.object;
4950
const direction = maybeMapping.direction;
51+
const modificationMetadata = maybeMapping.modificationMetadata
5052
const customerId = getCustomerId();
5153
try {
5254
const mappingResult = await prisma.mapping.upsert({
@@ -69,6 +71,7 @@ const saveMapping = async (maybeMapping: Mapping): Promise
6971
object: object,
7072
customerId: customerId,
7173
direction: direction,
74+
modificationMetadata:modificationMetadata || {},
7275
},
7376
});
7477

src/properties.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ const getNativeProperties = async (customerId: string): Promise
115115
type: true,
116116
object: true,
117117
customerId: true,
118+
modificationMetadata:true,
118119
},
119120
where: {
120121
customerId,

types/common.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ declare module "default" {
44
label?: string | null;
55
type?: string;
66
object: Objects;
7+
modificationMetadata: ModificationMetadata;
78
}
89
// interface Mapping {
910
// nativeName: string;
@@ -17,6 +18,7 @@ declare module "default" {
1718
object: object;
1819
customerId: string;
1920
direction: Direction;
21+
modificationMetadata: ModificationMetadata;
2022
}
2123
interface PropertyWithMapping {
2224
property: Property;
@@ -45,6 +47,7 @@ declare module "default" {
4547
readOnlyValue: boolean;
4648
}
4749

50+
4851
//fix unused interface
4952
export interface HubSpotProperty {
5053
updatedAt: Date;

0 commit comments

Comments
 (0)