Skip to content

Commit 90c1232

Browse files
authored
Add Initial tagging functionality (#35)
1 parent c1cf2ec commit 90c1232

36 files changed

+471
-16
lines changed

extensions/flutter/actions/generate-models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ const flutterTypeMap: Record<InFieldType, string> = {
417417
FileField: "FileField",
418418
TimeField: "DateTime",
419419
CodeField: "String",
420+
ArrayField: "List<dynamic>",
420421
};
421422

422423
async function writeModelFile(

src/auth/entries/account/_account.type.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ export interface Account extends EntryBase {
5252
* @required true
5353
*/
5454
updatedAt: number;
55+
/**
56+
* **Tags** (ArrayField)
57+
* @description Tags associated with this Account
58+
* @type {Array<any>}
59+
*/
60+
in__tags?: Array<any>;
5561
/**
5662
* **Account Owner Title** (DataField)
5763
* @description The user's full name (automatically generated)

src/auth/entries/user-session/_user-session.type.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ export interface UserSession extends EntryBase {
4444
* @required true
4545
*/
4646
updatedAt: number;
47+
/**
48+
* **Tags** (ArrayField)
49+
* @description Tags associated with this User Session
50+
* @type {Array<any>}
51+
*/
52+
in__tags?: Array<any>;
4753
/**
4854
* **User Title** (DataField)
4955
* @description The user's full name (automatically generated)

src/auth/entries/user/_user.type.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ export interface User extends EntryBase {
120120
* @required true
121121
*/
122122
updatedAt: number;
123+
/**
124+
* **Tags** (ArrayField)
125+
* @description Tags associated with this User
126+
* @type {Array<any>}
127+
*/
128+
in__tags?: Array<any>;
123129
/**
124130
* **Profile Picture Title** (DataField)
125131
* @type {string}

src/email/entries/_email-account.type.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ export interface EmailAccount extends EntryBase {
113113
* @required true
114114
*/
115115
updatedAt: number;
116+
/**
117+
* **Tags** (ArrayField)
118+
* @description Tags associated with this Email Account
119+
* @type {Array<any>}
120+
*/
121+
in__tags?: Array<any>;
116122
isFieldModified(
117123
fieldKey: keyof {
118124
[K in keyof EmailAccount as K extends keyof EntryBase ? never : K]: K;

src/email/entries/_email-template.type.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ export interface EmailTemplate extends EntryBase {
3838
* @required true
3939
*/
4040
updatedAt: number;
41+
/**
42+
* **Tags** (ArrayField)
43+
* @description Tags associated with this Email Template
44+
* @type {Array<any>}
45+
*/
46+
in__tags?: Array<any>;
4147
isFieldModified(
4248
fieldKey: keyof {
4349
[K in keyof EmailTemplate as K extends keyof EntryBase ? never : K]: K;

src/email/entries/_email.type.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ export interface Email extends EntryBase {
101101
* @required true
102102
*/
103103
updatedAt: number;
104+
/**
105+
* **Tags** (ArrayField)
106+
* @description Tags associated with this Email
107+
* @type {Array<any>}
108+
*/
109+
in__tags?: Array<any>;
104110
/**
105111
* **From Title** (EmailField)
106112
* @description The email account to send emails from

src/extension/action-groups/dev-actions.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { CloudAPIGroup } from "@inspatial/cloud";
2+
import { raiseORMException } from "../../orm/mod.ts";
23

34
export const devActions = new CloudAPIGroup("dev", {
45
description: "Development actions",
@@ -13,7 +14,46 @@ devActions.addAction("generateConfig", {
1314
inCloud.generateConfigFile();
1415
},
1516
});
17+
devActions.addAction("run", {
18+
params: [{
19+
key: "code",
20+
type: "TextField",
21+
}],
1622

23+
async run({ inCloud, orm, params: { code } }) {
24+
if (inCloud.getExtensionConfigValue("core", "cloudMode") === "production") {
25+
raiseORMException(
26+
"The run action is not available in production mode",
27+
"Dev",
28+
403,
29+
);
30+
}
31+
const resultRows: Array<any> = [];
32+
const log = (...args: any[]) => {
33+
for (const arg of args) {
34+
resultRows.push(arg);
35+
}
36+
};
37+
const func = new Function(
38+
"inCloud",
39+
"orm",
40+
"log",
41+
`return (async () => { ${code} })()`,
42+
);
43+
try {
44+
const result = await func(inCloud, orm, log);
45+
return {
46+
result,
47+
log: resultRows,
48+
};
49+
} catch (error) {
50+
return {
51+
result: { error: (error as Error).message },
52+
log: resultRows,
53+
};
54+
}
55+
},
56+
});
1757
devActions.addAction("clearStaticCache", {
1858
description: "Clear the static files cache",
1959
params: [],

src/extension/core-extension.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import { Currencies } from "../orm/field/field-def-types.ts";
4545
import { inLiveLifecycle } from "../in-live/in-live-lifecycle.ts";
4646
import { publicFilesHandler } from "../files/public-files-handler.ts";
4747
import { emailTemplate } from "../email/entries/emailTemplate.ts";
48+
import { tagsGroup } from "../orm/api-actions/tags-group.ts";
4849
export const coreExtension = new CloudExtension("core", {
4950
description: "InSpatial Cloud Core Extension",
5051
label: "Core",
@@ -67,6 +68,7 @@ export const coreExtension = new CloudExtension("core", {
6768
devActions,
6869
filesGroup,
6970
emailGroup,
71+
tagsGroup,
7072
],
7173
settingsTypes: [
7274
systemSettings,

src/files/entries/_cloud-file.type.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,12 @@ export interface CloudFile extends EntryBase {
187187
* @required true
188188
*/
189189
updatedAt: number;
190+
/**
191+
* **Tags** (ArrayField)
192+
* @description Tags associated with this File
193+
* @type {Array<any>}
194+
*/
195+
in__tags?: Array<any>;
190196
isFieldModified(
191197
fieldKey: keyof {
192198
[K in keyof CloudFile as K extends keyof EntryBase ? never : K]: K;

0 commit comments

Comments
 (0)