diff --git a/docs/docs/deeper/data-management-in-fireback.mdx b/docs/docs/deeper/data-management-in-fireback.mdx index 4b62559fa..b6c40fb55 100644 --- a/docs/docs/deeper/data-management-in-fireback.mdx +++ b/docs/docs/deeper/data-management-in-fireback.mdx @@ -135,7 +135,7 @@ in the database. Make this more professional please: -## Decide between 'one', 'object', and 'embed' types. +## Decide between 'one', 'object' types. Fireback is generating some code, that developer had to write if he wanted to avoid half-measure. It does not bring new ideas, just gathers them and make it easier to use. diff --git a/docs/docs/fields.md b/docs/docs/fields.md index 5df3ff317..c359ba716 100644 --- a/docs/docs/fields.md +++ b/docs/docs/fields.md @@ -85,19 +85,6 @@ For example from license module: You see that `permissions` is an array. **Important** It's important that, every array field to end in plural english form. Some code might end up in mismatch for singular fields as a bug until 1.1.27. - -## Type: object - -Type on is also a nested field, which you can define `fields` very similarly in an array. -The difference is, there will be a one-2-one relation created on this type of data, besides -there will be an Addtional *Id field which would link them by a unique string id. At the moment, -Fireback is creating `id` auto incremental numeric for each table, as well as `uniqueId` as a unique -string identifier. `id` is intended to be used internally only for Fireback, and any external relationship -between data, needs to use `uniqueId` field instead (`unique_id` on database level). This might change, -as in large projects it causes large indexing tables. - -For example, see array example, and instead of `type: array` use `type: object`. Other details are exactly the same. - ## Type: one The type one, is a specific type to Fireback. It means, you are targeting another table as a `one-to-one` relationship. The different with `object` is, in this type managing the data, deleting it is not depending diff --git a/e2e/react-bed/src/sdk/modules/abac/UserEntity.ts b/e2e/react-bed/src/sdk/modules/abac/UserEntity.ts index 4c6b3c74d..8db14a38d 100644 --- a/e2e/react-bed/src/sdk/modules/abac/UserEntity.ts +++ b/e2e/react-bed/src/sdk/modules/abac/UserEntity.ts @@ -177,7 +177,7 @@ export class UserEntity extends BaseEntity { { "name": "primaryAddress", "description": "User primary address location. Can be useful for simple projects that a user is associated with a single address.", - "type": "embed", + "type": "object", "computedType": "UserPrimaryAddress", "gormMap": {}, "-": "UserPrimaryAddress", diff --git a/e2e/samples/fireback-data-types/modules/product/ProductModule3.yml b/e2e/samples/fireback-data-types/modules/product/ProductModule3.yml index d8d6f1249..c1b3f508f 100644 --- a/e2e/samples/fireback-data-types/modules/product/ProductModule3.yml +++ b/e2e/samples/fireback-data-types/modules/product/ProductModule3.yml @@ -97,7 +97,7 @@ entities: # name: barcode # description: "Product barcode" # - name: meta - # type: embed + # type: object # fields: # - type: bool # name: isEcoFriendly @@ -111,7 +111,7 @@ entities: # - type: bool # name: isPreOrder # description: "Marks if the product is available for pre-order" - # - type: embed + # - type: object # name: more # fields: # - type: bool @@ -132,6 +132,3 @@ entities: # - type: bool # name: isHandmade # description: "Indicates if the product is handmade or artisan-crafted" - - - \ No newline at end of file diff --git a/modules/abac/AbacModule3.yml b/modules/abac/AbacModule3.yml index 6b94500a8..8e9acd865 100644 --- a/modules/abac/AbacModule3.yml +++ b/modules/abac/AbacModule3.yml @@ -1162,7 +1162,7 @@ entities: type: string description: User last connecting ip address - name: primaryAddress - type: embed + type: object description: User primary address location. Can be useful for simple projects that a user is associated with a single address. diff --git a/modules/abac/UserEntity.dyno.go b/modules/abac/UserEntity.dyno.go index 378f70aec..579f80d70 100644 --- a/modules/abac/UserEntity.dyno.go +++ b/modules/abac/UserEntity.dyno.go @@ -68,7 +68,7 @@ type UserEntityQs struct { StateOrProvince fireback.QueriableField `cli:"primary-address.state-or-province" table:"user" typeof:"string?" column:"state_or_province" qs:"stateOrProvince"` PostalCode fireback.QueriableField `cli:"primary-address.postal-code" table:"user" typeof:"string?" column:"postal_code" qs:"postalCode"` CountryCode fireback.QueriableField `cli:"primary-address.country-code" table:"user" typeof:"string?" column:"country_code" qs:"countryCode"` - } `cli:"primary-address" table:"user" column:"primary_address" typeof:"embed" qs:"primaryAddress" preload:"PrimaryAddress"` + } `cli:"primary-address" table:"user" column:"primary_address" typeof:"object" qs:"primaryAddress" preload:"PrimaryAddress"` } func (x *UserEntityQs) GetQuery() string { @@ -443,7 +443,7 @@ Title: (type: string) Description: BirthDate: (type: date) Description: Avatar: (type: string) Description: LastIpAddress: (type: string) Description: User last connecting ip address -PrimaryAddress: (type: embed) Description: User primary address location. Can be useful for simple projects that a user is associated with a single address. +PrimaryAddress: (type: object) Description: User primary address location. Can be useful for simple projects that a user is associated with a single address. And here is the actual object signature: ` + v.Seeder() + ` ` diff --git a/modules/fireback/cli-actions.go b/modules/fireback/cli-actions.go index c1e8e1070..281a8f8f1 100644 --- a/modules/fireback/cli-actions.go +++ b/modules/fireback/cli-actions.go @@ -533,7 +533,7 @@ func DatabaseColumnsResolver( } // Nested struct - if typeof == "one" || typeof == "object" || typeof == "array" || typeof == "collection" { + if typeof == "one" || typeof == "array" || typeof == "collection" { if slices.Contains(requestedFields, qs) { if preload != "" { value.Preloads = append(value.Preloads, preload) @@ -541,7 +541,7 @@ func DatabaseColumnsResolver( } value = DatabaseColumnsResolver(fieldValue, fullName+".", requestedFields, value, false) - } else if typeof == "embed" { + } else if typeof == FIELD_TYPE_OBJECT { if slices.Contains(requestedFields, qs) { value = DatabaseColumnsResolver(fieldValue, fullName+".", requestedFields, value, true) } diff --git a/modules/fireback/codegen.go b/modules/fireback/codegen.go index 230a9b5e9..3820cbaf1 100644 --- a/modules/fireback/codegen.go +++ b/modules/fireback/codegen.go @@ -45,7 +45,6 @@ var FIELD_TYPE_ONE string = "one" var FIELD_TYPE_DATE string = "date" var FIELD_TYPE_COLLECTION string = "collection" var FIELD_TYPE_OBJECT string = "object" -var FIELD_TYPE_EMBED string = "embed" var FIELD_TYPE_MONEY string = "money?" var FIELD_TYPE_XFILE string = "xfile?" var FIELD_TYPE_ENUM string = "enum" @@ -317,11 +316,11 @@ func (x *Module3Field) ComputedGormTag() string { return "many2many:" + x.BelongingEntityName + "_" + x.PrivateName() + ";foreignKey:UniqueId;references:UniqueId" } - if x.Type == FIELD_TYPE_EMBED || x.Type == FIELD_TYPE_MONEY { + if x.Type == FIELD_TYPE_OBJECT || x.Type == FIELD_TYPE_MONEY { return "embedded" } - if x.Type == FIELD_TYPE_ARRAY || x.Type == FIELD_TYPE_OBJECT { + if x.Type == FIELD_TYPE_ARRAY { return "foreignKey:LinkerId;references:UniqueId;constraint:OnDelete:CASCADE" } @@ -362,7 +361,7 @@ func CalcAllPolyglotEntities(m []*Module3Field) []string { items = append(items, item.Name) } - if item.Type == FIELD_TYPE_OBJECT || item.Type == FIELD_TYPE_ARRAY { + if item.Type == FIELD_TYPE_ARRAY { items = append(items, CalcAllPolyglotEntities(item.Fields)...) } } @@ -1375,7 +1374,7 @@ func ComputeComplexGormField(entity *Module3Entity, fields []*Module3Field) { for _, field := range fields { field.BelongingEntityName = entity.Name - if field.Type == FIELD_TYPE_OBJECT || field.Type == FIELD_TYPE_EMBED || field.Type == FIELD_TYPE_ARRAY { + if field.Type == FIELD_TYPE_OBJECT || field.Type == FIELD_TYPE_ARRAY { ComputeComplexGormField(entity, field.Fields) } } @@ -1390,7 +1389,7 @@ func ComputeFieldTypes(fields []*Module3Field, isWorkspace bool, fn func(field * for _, field := range fields { field.ComputedType = fn(field, isWorkspace) - if field.Type == FIELD_TYPE_OBJECT || field.Type == FIELD_TYPE_EMBED || field.Type == FIELD_TYPE_ARRAY { + if field.Type == FIELD_TYPE_OBJECT || field.Type == FIELD_TYPE_ARRAY { ComputeFieldTypes(field.Fields, isWorkspace, fn) } } @@ -1406,7 +1405,7 @@ func ComputeFieldTypesAbsolute(fields []*Module3Field, isWorkspace bool, fn func for _, field := range fields { field.ComputedType = strings.ReplaceAll(fn(field, isWorkspace), "*", "") - if field.Type == FIELD_TYPE_OBJECT || field.Type == FIELD_TYPE_EMBED || field.Type == FIELD_TYPE_ARRAY { + if field.Type == FIELD_TYPE_OBJECT || field.Type == FIELD_TYPE_ARRAY { ComputeFieldTypesAbsolute(field.Fields, isWorkspace, fn) } } @@ -2410,11 +2409,11 @@ func GetArrayOrObjectFieldsFlatten(depth int, parentType string, depthName strin } for _, item := range fields { - if item.Type == FIELD_TYPE_EMBED { + if item.Type == FIELD_TYPE_OBJECT { item.IsVirtualObject = true } - if item.Type != FIELD_TYPE_OBJECT && item.Type != FIELD_TYPE_ARRAY && item.Type != FIELD_TYPE_EMBED { + if item.Type != FIELD_TYPE_ARRAY && item.Type != FIELD_TYPE_OBJECT { item.ComputedType = ctx.Catalog.ComputeField(item, isWorkspace) continue } else { @@ -2591,7 +2590,7 @@ func ImportDependecies(fields []*Module3Field) []ImportDependencyStrategy { } } - if field.Type == FIELD_TYPE_ARRAY || field.Type == FIELD_TYPE_OBJECT || field.Type == FIELD_TYPE_EMBED { + if field.Type == FIELD_TYPE_ARRAY || field.Type == FIELD_TYPE_OBJECT { items = append(items, ImportDependecies(field.Fields)...) } @@ -2691,7 +2690,7 @@ func ImportGoDependencies(fields []*Module3Field, importGroupPrefix string) []Im // }) // } - if field.Type == FIELD_TYPE_ARRAY || field.Type == FIELD_TYPE_OBJECT || field.Type == FIELD_TYPE_EMBED { + if field.Type == FIELD_TYPE_ARRAY || field.Type == FIELD_TYPE_OBJECT { items = append(items, ImportGoDependencies(field.Fields, actualPrefix)...) } @@ -3446,9 +3445,7 @@ func (x *Module3Entity) GetSqlFields() []string { "template_entities.created_at", } for _, field := range x.Fields { - if field.Type == "object" { - continue - } + if field.Type == "one" { items = append(items, "template_entities."+ToSnakeCase(field.Name)+"_id") } else { @@ -3463,9 +3460,6 @@ func (x *Module3Entity) GetSqlFields() []string { func (x *Module3Entity) GetSqlFieldNames() []string { items := []string{"parent_id", "visibility", "updated_at", "created_at"} for _, field := range x.Fields { - if field.Type == "object" { - continue - } if field.Type == "one" { items = append(items, ToSnakeCase(field.Name)+"_id") @@ -3486,9 +3480,6 @@ func (x *Module3Entity) GetSqlFieldNamesAfter() []string { "template_entities_cte.created_at", } for _, field := range x.Fields { - if field.Type == "object" { - continue - } if field.Type == "one" { items = append(items, "template_entities_cte."+ToSnakeCase(field.Name)+"_id\n") diff --git a/modules/fireback/codegen/firebackgo/GoModuleDyno.tpl b/modules/fireback/codegen/firebackgo/GoModuleDyno.tpl index bb6d25ccb..ea5b60acd 100644 --- a/modules/fireback/codegen/firebackgo/GoModuleDyno.tpl +++ b/modules/fireback/codegen/firebackgo/GoModuleDyno.tpl @@ -453,10 +453,6 @@ func {{ upper .Name }}Query(query {{ $.wsprefix}}QueryDSL) ([]*{{ template "quer {{ if or (eq .Type "int32") }} {{ upper $prefix }}{{ upper .Name }} int32 `envconfig:"{{- if .Env -}}{{ .Env }}{{else}}{{ snakeUpper .Name }}{{end}}" description:"{{ escape .Description}}"` {{ end }} - {{ if or (eq .Type "object")}} - {{ $newPrefix := print $prefix .Name }} - {{ template "configFields" (arr .Fields $newPrefix)}} - {{ end }} {{ end }} {{ end }} diff --git a/modules/fireback/codegen/firebackgo/SharedSnippets.tpl b/modules/fireback/codegen/firebackgo/SharedSnippets.tpl index f803e217e..2ba9b0cef 100644 --- a/modules/fireback/codegen/firebackgo/SharedSnippets.tpl +++ b/modules/fireback/codegen/firebackgo/SharedSnippets.tpl @@ -10,7 +10,7 @@ import "{{ $key}}" {{ end }} -{{ define "golangtype" }}{{ if or (eq .Type "array") (eq .Type "collection") }} []* {{ end }}{{ if or (eq .Type "embed") (eq .Type "object") (eq .Type "one") }} * {{ end }}{{ end }} +{{ define "golangtype" }}{{ if or (eq .Type "array") (eq .Type "collection") }} []* {{ end }}{{ if or (eq .Type "object") (eq .Type "one") }} * {{ end }}{{ end }} {{ define "validaterow" }}{{ if and (.Validate) (ne .Type "one") }} validate:"{{ .Validate }}" {{ end }}{{ end }} @@ -202,7 +202,7 @@ import "{{ $key}}" {{/* Array or object operations */}} {{ define "entitychildactions" }} {{ range .e.CompleteFields }} - {{ if or (eq .Type "object") (eq .Type "array")}} + {{ if or (eq .Type "array")}} func {{ $.e.Upper }}{{ .PublicName }}ActionCreate( dto *{{ $.e.Upper }}{{ .PublicName }} , @@ -413,14 +413,10 @@ func {{ .e.Upper }}ActionSeederInitFn() *{{ .e.EntityName }} { {{ range .e.CompleteFields }} - {{ if eq .Type "embed" }} - {{ .PublicName }}: &{{ $.e.Upper}}{{ .PublicName }}{}, - {{ end }} - {{ if eq .Type "object" }} {{ .PublicName }}: &{{ $.e.Upper}}{{ .PublicName }}{}, {{ end }} - + {{ if eq .Type "array" }} {{ .UpperPlural }}: []*{{ $.e.Upper}}{{ .PublicName }}{{"{{}}"}}, {{ end }} @@ -704,11 +700,7 @@ func {{ .e.Upper }}EntityPreSanitize(dto *{{ .e.EntityName }}, query {{ .wsprefi } } {{ end }} - {{ if eq .Type "object" }} - if dto.{{ $fx }}{{ .PublicName }} != nil { - dto.{{ $fx }}{{ .PublicName }}.UniqueId = {{ $wsprefix }}UUID() - } - {{ end }} + {{ end }} {{ end }} @@ -1157,39 +1149,6 @@ func {{ .e.Upper}}DeleteEntireChildren(query {{ .wsprefix }}QueryDSL, dto *{{.e. return nil, ero } - - {{ range .e.CompleteFields }} - {{ if or (eq .Type "object") }} - - if fields.{{ .PublicName }} != nil { - - linkerId := uniqueId - - q := dbref. - Model(&item.{{ .PublicName }}). - Where(&{{ $.e.Upper }}{{ .PublicName }}{LinkerId: {{ $.wsprefix }}NewString(linkerId) }). - UpdateColumns(fields.{{ .PublicName }}) - - err := q.Error - if err != nil { - return &item, {{ $.wsprefix }}GormErrorToIError(err) - } - - if q.RowsAffected == 0 { - fields.{{ .PublicName }}.UniqueId = {{ $.wsprefix }}UUID() - fields.{{ .PublicName }}.LinkerId = {{ $.wsprefix }}NewString(linkerId) - err := dbref. - Model(&item.{{ .PublicName }}).Create(fields.{{ .PublicName }}).Error - - if err != nil { - return &item, {{ $.wsprefix }}GormErrorToIError(err) - } - } - } - - {{ end }} - {{ end }} - // @meta(update has many) {{ range .e.CompleteFields }} @@ -1242,18 +1201,7 @@ func {{ .e.Upper}}DeleteEntireChildren(query {{ .wsprefix }}QueryDSL, dto *{{.e. for _, item := range items { - - {{ range .Fields }} - {{ if or (eq .Type "object") }} - - if item3.<%- toUpper(c) %> != nil { - item3.<%- toUpper(c) %>.UniqueId = {{ .wsprefix }}UUID() - } - - - {{ end }} - {{ end }} - + dbref. Where(&{{ $entityName }}{{ $m }}{{ .PublicName }} {LinkerId: {{ $.wsprefix }}NewString(item.UniqueId)}). Delete(&{{ $entityName }}{{ $m }}{{ .PublicName }} {}) @@ -1268,15 +1216,6 @@ func {{ .e.Upper}}DeleteEntireChildren(query {{ .wsprefix }}QueryDSL, dto *{{.e. Delete(&{{ $entityName }}{{ .PublicName }} {}) for _, newItem := range fields.{{ .PublicName }} { - - {{ range .Fields }} - {{ if or (eq .Type "object") }} - if newItem.{{ .PublicName }} != nil { - newItem.{{ .PublicName }}.UniqueId = {{ $.wsprefix }}UUID() - } - {{ end }} - {{ end }} - newItem.UniqueId = {{ $.wsprefix }}UUID() newItem.LinkerId = {{ $.wsprefix }}NewString(linkerId) dbref.Create(&newItem) @@ -1357,7 +1296,7 @@ func {{ .e.Upper }}ActionWipeClean(query {{ .wsprefix }}QueryDSL) (int64, error) var count int64 = 0; {{ range .e.CompleteFields }} - {{ if or (eq .Type "object") (eq .Type "array")}} + {{ if or (eq .Type "array")}} { subCount, subErr := {{ $.wsprefix }}WipeCleanEntity[{{ $.e.Upper }}{{ .PublicName }}]() if (subErr != nil) { @@ -1605,7 +1544,7 @@ func {{ .e.Upper }}ActionImport( {{ $prefix := index . 1}} {{ range $fields }} - {{ if or (eq .Type "object") (eq .Type "embed")}} + {{ if or (eq .Type "object")}} {{ $newPrefix := print $prefix .Name "-" }} {{ template "entityCommonCliFlag" (arr .Fields $newPrefix)}} {{ end }} @@ -2762,7 +2701,7 @@ var {{.e.AllUpper}}_ACTION_DISTINCT_GET_ONE = {{ .wsprefix }}Module3Action{ {{ end }} {{ range .e.CompleteFields }} - {{ if or (eq .Type "object") (eq .Type "array")}} + {{ if or (eq .Type "array")}} var {{ $.e.AllUpper }}_{{ .AllUpper }}_ACTION_PATCH = {{ $.wsprefix }}Module3Action{ Method: "PATCH", Url: "/{{ $.e.Template }}/:linkerId/{{ .DashedName }}/:uniqueId", @@ -2897,7 +2836,7 @@ var {{.e.AllUpper}}_ACTION_DISTINCT_GET_ONE = {{ .wsprefix }}Module3Action{ {{ end }} {{ range .e.CompleteFields }} - {{ if or (eq .Type "object") (eq .Type "array")}} + {{ if or (eq .Type "array")}} {{ $.e.AllUpper }}_{{ .AllUpper }}_ACTION_PATCH, {{ $.e.AllUpper }}_{{ .AllUpper }}_ACTION_GET, {{ $.e.AllUpper }}_{{ .AllUpper }}_ACTION_POST, @@ -3705,7 +3644,7 @@ var {{ $entity.Upper }}ClickHouseActions = {{ $entity.Name }}ClickHouseSig{ {{ $wsprefix := index . 2}} {{ $table := index . 3}} {{ range $fields }} - {{ if or (eq .Type "object") (eq .Type "embed")}} + {{ if or (eq .Type "object")}} {{ .PublicName }} struct { {{ $newPrefix := print $prefix .ComputedCliName "." }} {{ template "qsFields" (arr .Fields $newPrefix $wsprefix $table)}} @@ -3724,7 +3663,7 @@ var {{ $entity.Upper }}ClickHouseActions = {{ $entity.Name }}ClickHouseSig{ {{ range $fields }} - {{ if or (eq .Type "object") (eq .Type "embed")}} + {{ if or (eq .Type "object")}} {{ $newPrefix := print $prefix .ComputedCliName "-" }} {{ template "qsFlags" (arr .Fields $newPrefix )}} {{ else }} diff --git a/modules/fireback/codegen/react-new/src/apps/designer/FieldsEditor.tsx b/modules/fireback/codegen/react-new/src/apps/designer/FieldsEditor.tsx index 2d7bff120..e32fe4ee6 100644 --- a/modules/fireback/codegen/react-new/src/apps/designer/FieldsEditor.tsx +++ b/modules/fireback/codegen/react-new/src/apps/designer/FieldsEditor.tsx @@ -82,7 +82,6 @@ export function FieldsEditor({ fields, onChange }: FieldsEditorProps) { - diff --git a/modules/fireback/codegen/react-new/src/modules/fireback/sdk/modules/abac/UserEntity.ts b/modules/fireback/codegen/react-new/src/modules/fireback/sdk/modules/abac/UserEntity.ts index 4c6b3c74d..8db14a38d 100644 --- a/modules/fireback/codegen/react-new/src/modules/fireback/sdk/modules/abac/UserEntity.ts +++ b/modules/fireback/codegen/react-new/src/modules/fireback/sdk/modules/abac/UserEntity.ts @@ -177,7 +177,7 @@ export class UserEntity extends BaseEntity { { "name": "primaryAddress", "description": "User primary address location. Can be useful for simple projects that a user is associated with a single address.", - "type": "embed", + "type": "object", "computedType": "UserPrimaryAddress", "gormMap": {}, "-": "UserPrimaryAddress", diff --git a/modules/fireback/codegen/react-ui/TemplateColumns.tpl b/modules/fireback/codegen/react-ui/TemplateColumns.tpl index 83353175c..1566f502a 100644 --- a/modules/fireback/codegen/react-ui/TemplateColumns.tpl +++ b/modules/fireback/codegen/react-ui/TemplateColumns.tpl @@ -11,7 +11,7 @@ export const columns = (t: typeof strings) => [ {{ range .e.CompleteFields }} - {{ if or (eq .Type "object") (eq .Type "array") (eq .Type "collection") (eq .Type "one") }} + {{ if or (eq .Type "array") (eq .Type "collection") (eq .Type "one") }} { name: {{ $.Template }}Entity.Fields.{{ .Name }}$, title: t.{{ $.templates}}.{{ .Name }}, diff --git a/modules/fireback/codegen/typescript/SharedSnippets.tpl b/modules/fireback/codegen/typescript/SharedSnippets.tpl index 9228d5ee4..950227574 100644 --- a/modules/fireback/codegen/typescript/SharedSnippets.tpl +++ b/modules/fireback/codegen/typescript/SharedSnippets.tpl @@ -102,7 +102,7 @@ {{ template "stringfield" (arr . $root $newPrefix) }} }; }, - {{ else if or (eq .Type "object") (eq .Type "embed") }} + {{ else if or (eq .Type "object") }} {{ .PrivateName }}$: '{{ $prefix}}{{ .PrivateName }}', {{ .PrivateName }}: { {{ template "stringfield" (arr . $root $newPrefix) }} @@ -171,7 +171,7 @@ {{ range .e.CompleteFields }} - {{ if or (eq .Type "array") (eq .Type "object") (eq .Type "embed") }} + {{ if or (eq .Type "array") (eq .Type "object") }} r{{ .PublicName}}Create: "{{ $.e.DashedName }}/:linkerId/{{ .DashedName}}/new", r{{ .PublicName}}Edit: "{{ $.e.DashedName }}/:linkerId/{{ .DashedName}}/edit/:uniqueId", @@ -200,7 +200,7 @@ public static Fields = { {{ define "actionStringFields" }} {{ range . }} - {{ if or (eq .Type "array") (eq .Type "object") (eq .Type "embed") }} + {{ if or (eq .Type "array") (eq .Type "object") }} {{ .PrivateName }}$: '{{ .PrivateName }}', {{ .PrivateName }}: { {{ template "actionStringFields" .Fields }} diff --git a/modules/fireback/firebackgogen.go b/modules/fireback/firebackgogen.go index 4a142195b..952774c86 100644 --- a/modules/fireback/firebackgogen.go +++ b/modules/fireback/firebackgogen.go @@ -55,7 +55,7 @@ func GolangComputedField(field *Module3Field, isWorkspace bool) string { return "*bool" case "double": return "*float64" - case "object", "embed": + case FIELD_TYPE_OBJECT: return field.PublicName() case "json": return "JSON" diff --git a/modules/fireback/module3-json-schema.json b/modules/fireback/module3-json-schema.json index 39037d976..39aa42dbe 100644 --- a/modules/fireback/module3-json-schema.json +++ b/modules/fireback/module3-json-schema.json @@ -1055,7 +1055,6 @@ "int", "datetime", "json", - "embed", "datenano", "html", "text", diff --git a/modules/fireback/module3/m3js/js-common-object.go b/modules/fireback/module3/m3js/js-common-object.go index 2c1f4862b..33f674437 100644 --- a/modules/fireback/module3/m3js/js-common-object.go +++ b/modules/fireback/module3/m3js/js-common-object.go @@ -34,7 +34,7 @@ type jsRenderedField struct { // need to have the correct generated class to be assigned to them. func jsFieldTypeOnNestedClasses(field *mcore.Module3Field, parentChain string) string { - if field.Type == mcore.FIELD_TYPE_ARRAY || field.Type == mcore.FIELD_TYPE_OBJECT { + if field.Type == mcore.FIELD_TYPE_ARRAY { return mcore.ToUpper(parentChain) + "." + mcore.ToUpper(field.Name) } @@ -99,7 +99,7 @@ func jsRenderDataClasses(fields []*mcore.Module3Field, className string, treeLoc // then descend into object/array fields for _, field := range fields { - if field.Type == mcore.FIELD_TYPE_OBJECT || field.Type == mcore.FIELD_TYPE_ARRAY { + if field.Type == mcore.FIELD_TYPE_ARRAY { childName := mcore.ToUpper(field.Name) currentClass.SubClasses = append(currentClass.SubClasses, jsRenderDataClasses(field.Fields, mcore.ToUpper(childName), treeLocation+"."+mcore.ToUpper(childName), false)...) } @@ -251,7 +251,7 @@ func TsComputedField(field *mcore.Module3Field, isWorkspace bool) string { return "Date" case "double": return "number" - case "object", "embed": + case mcore.FIELD_TYPE_OBJECT: return field.PublicName() case "money?": return "{amount: number, currency: string, formatted?: string}" diff --git a/modules/fireback/module3/mcore/module3.go b/modules/fireback/module3/mcore/module3.go index 418cd0f77..7bef47055 100644 --- a/modules/fireback/module3/mcore/module3.go +++ b/modules/fireback/module3/mcore/module3.go @@ -23,7 +23,6 @@ var FIELD_TYPE_ONE string = "one" var FIELD_TYPE_DATE string = "date" var FIELD_TYPE_COLLECTION string = "collection" var FIELD_TYPE_OBJECT string = "object" -var FIELD_TYPE_EMBED string = "embed" var FIELD_TYPE_MONEY string = "money?" var FIELD_TYPE_XFILE string = "xfile?" var FIELD_TYPE_ENUM string = "enum" @@ -706,7 +705,7 @@ type Module3Field struct { Description string `yaml:"description,omitempty" json:"description,omitempty" jsonschema:"description=Description about the field for developers and generated documents."` // Type of the field based on Fireback types. - Type string `yaml:"type,omitempty" json:"type,omitempty" jsonschema:"enum=string?,enum=int?,enum=float64?,enum=money?,enum=xfile?,enum=float32?,enum=bool?,enum=int32?,enum=int64?,enum=int,enum=datetime,enum=json,enum=embed,enum=datenano,enum=html,enum=text,enum=date,enum=daterange,enum=collection,enum=slice,enum=enum,enum=bool,enum=one,enum=int64,enum=float64,enum=duration?,enum=object,enum=array,enum=string,description=Type of the field based on Fireback types."` + Type string `yaml:"type,omitempty" json:"type,omitempty" jsonschema:"enum=string?,enum=int?,enum=float64?,enum=money?,enum=xfile?,enum=float32?,enum=bool?,enum=int32?,enum=int64?,enum=int,enum=datetime,enum=json,enum=datenano,enum=html,enum=text,enum=date,enum=daterange,enum=collection,enum=slice,enum=enum,enum=bool,enum=one,enum=int64,enum=float64,enum=duration?,enum=object,enum=array,enum=string,description=Type of the field based on Fireback types."` // Primitive type in golang when type: slice is set Primitive string `yaml:"primitive,omitempty" json:"primitive,omitempty" jsonschema:"description=Primitive type in golang when type: slice is set"` diff --git a/modules/fireback/open-api-tools.go b/modules/fireback/open-api-tools.go index 7b5f584ca..6ac9341c5 100644 --- a/modules/fireback/open-api-tools.go +++ b/modules/fireback/open-api-tools.go @@ -75,8 +75,6 @@ func OpenApiTypeToFirebackType(fieldName string, t *openapi3.Schema) Module3Fiel field.Type = "float64" case "boolean": field.Type = "bool" - // case "object": - // fmt.Println("Object!") case "array": field.Type = "array" diff --git a/modules/fireback/typescriptcodegen.go b/modules/fireback/typescriptcodegen.go index c9f2741ce..a2dcdc796 100644 --- a/modules/fireback/typescriptcodegen.go +++ b/modules/fireback/typescriptcodegen.go @@ -84,7 +84,7 @@ func TsComputedField(field *Module3Field, isWorkspace bool) string { return "Date" case "double": return "number" - case "object", "embed": + case FIELD_TYPE_OBJECT: return field.PublicName() case "money?": return "{amount: number, currency: string, formatted?: string}" diff --git a/modules/fireback/vField.go b/modules/fireback/vField.go index d4a2f73e3..f90c951d9 100644 --- a/modules/fireback/vField.go +++ b/modules/fireback/vField.go @@ -16,7 +16,7 @@ type Module3Field struct { Description string `yaml:"description,omitempty" json:"description,omitempty" jsonschema:"description=Description about the field for developers and generated documents."` // Type of the field based on Fireback types. - Type string `yaml:"type,omitempty" json:"type,omitempty" jsonschema:"enum=string?,enum=int?,enum=float64?,enum=money?,enum=xfile?,enum=float32?,enum=bool?,enum=int32?,enum=int64?,enum=int,enum=datetime,enum=json,enum=embed,enum=datenano,enum=html,enum=text,enum=date,enum=daterange,enum=collection,enum=slice,enum=enum,enum=bool,enum=one,enum=int64,enum=float64,enum=duration?,enum=object,enum=array,enum=string,description=Type of the field based on Fireback types."` + Type string `yaml:"type,omitempty" json:"type,omitempty" jsonschema:"enum=string?,enum=int?,enum=float64?,enum=money?,enum=xfile?,enum=float32?,enum=bool?,enum=int32?,enum=int64?,enum=int,enum=datetime,enum=json,enum=datenano,enum=html,enum=text,enum=date,enum=daterange,enum=collection,enum=slice,enum=enum,enum=bool,enum=one,enum=int64,enum=float64,enum=duration?,enum=object,enum=array,enum=string,description=Type of the field based on Fireback types."` // Primitive type in golang when type: slice is set Primitive string `yaml:"primitive,omitempty" json:"primitive,omitempty" jsonschema:"description=Primitive type in golang when type: slice is set"` diff --git a/modules/fireback/validator.go b/modules/fireback/validator.go index b96b321e1..2984f9574 100644 --- a/modules/fireback/validator.go +++ b/modules/fireback/validator.go @@ -12,7 +12,6 @@ var AVAILABLE_FIREBACK_DATA_TYPES = []string{ FIELD_TYPE_DATE, FIELD_TYPE_COLLECTION, FIELD_TYPE_OBJECT, - FIELD_TYPE_EMBED, FIELD_TYPE_ENUM, FIELD_TYPE_COMPUTED, FIELD_TYPE_TEXT, diff --git a/modules/payment/PaymentCustomActions.dyno.go b/modules/payment/PaymentCustomActions.dyno.go index 3bb86fd68..b0ebde4d6 100644 --- a/modules/payment/PaymentCustomActions.dyno.go +++ b/modules/payment/PaymentCustomActions.dyno.go @@ -202,7 +202,7 @@ var PayInvoiceSecurityModel *fireback.SecurityModel = nil type PayInvoiceQuery struct { // Created invoice to be payed via strip InvoiceId string `json:"invoiceId" xml:"invoiceId" yaml:"invoiceId" validate:"required" url:"invoiceId" ` - PathParams *PayInvoiceQueryPathParams `json:"pathParams" xml:"pathParams" yaml:"pathParams" gorm:"foreignKey:LinkerId;references:UniqueId;constraint:OnDelete:CASCADE" url:"pathParams" ` + PathParams *PayInvoiceQueryPathParams `json:"pathParams" xml:"pathParams" yaml:"pathParams" gorm:"embedded" url:"pathParams" ` } type payInvoiceActionImpSig func( q fireback.QueryDSL) (string, diff --git a/modules/payment/PaymentModule.dyno.go b/modules/payment/PaymentModule.dyno.go index b4ccc3080..000ff3351 100644 --- a/modules/payment/PaymentModule.dyno.go +++ b/modules/payment/PaymentModule.dyno.go @@ -159,7 +159,7 @@ func (x *paymentRemoteContext) ProductInventoryAvailability( /// VerifyTransaction type VerifyTransactionRemoteResponse struct { - Data *VerifyTransactionResData `json:"data" xml:"data" yaml:"data" gorm:"foreignKey:LinkerId;references:UniqueId;constraint:OnDelete:CASCADE" ` + Data *VerifyTransactionResData `json:"data" xml:"data" yaml:"data" gorm:"embedded" ` Error string `json:"error" xml:"error" yaml:"error" ` } type VerifyTransactionRemoteBody struct { @@ -216,7 +216,7 @@ func (x *paymentRemoteContext) VerifyTransaction( /// RegisterTransaction type RegisterTransactionRemoteResponse struct { - Data *RegisterTransactionResData `json:"data" xml:"data" yaml:"data" gorm:"foreignKey:LinkerId;references:UniqueId;constraint:OnDelete:CASCADE" ` + Data *RegisterTransactionResData `json:"data" xml:"data" yaml:"data" gorm:"embedded" ` Error string `json:"error" xml:"error" yaml:"error" ` } type RegisterTransactionRemoteBody struct { diff --git a/modules/payment/RegisterTransactionAction.go b/modules/payment/RegisterTransactionAction.go index 2cbd40b69..bd57187c1 100644 --- a/modules/payment/RegisterTransactionAction.go +++ b/modules/payment/RegisterTransactionAction.go @@ -3,7 +3,6 @@ package payment import ( "net/http" "strconv" - "strings" "github.com/torabian/fireback/modules/fireback" ) @@ -65,9 +64,11 @@ func RegisterTransactionAction(req *RegisterTransactionActionReqDto, q fireback. if err != nil || res.Error != "" { return "", err } else { - if res != nil && res.Data != nil && res.Data.Token != "" { - return strings.ReplaceAll(config.PaymentPageUrl, "{TOKEN}", res.Data.Token), nil - } + + // Make sure you will uncomments this after adding remotes features + // if res != nil && res.Data != nil && res.Data.Token != "" { + // return strings.ReplaceAll(config.PaymentPageUrl, "{TOKEN}", res.Data.Token), nil + // } return "", nil } }