Skip to content

Commit

Permalink
feat(server-actions): add bundle migration for server actions
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 8d01eddcf58a110e0ce9126f035282a6b346943a
  • Loading branch information
IcaroG authored and actions-user committed Dec 18, 2024
1 parent f1fe978 commit f22e49a
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const TYPES = `AnyType|Arena|ArenaChild|ArenaFrame|ArenaFrameCell|ArenaFrameGrid|ArenaFrameRow|Arg|ArgType|BindingStruct|BoolType|Choice|ClassNamePropType|CodeComponentHelper|CodeComponentMeta|CodeComponentVariantMeta|CodeLibrary|CollectionExpr|ColorPropType|ColumnsConfig|ColumnsSetting|Component|ComponentArena|ComponentDataQuery|ComponentInstance|ComponentSwapSplitContent|ComponentTemplateInfo|ComponentVariantGroup|ComponentVariantSplitContent|CompositeExpr|CustomCode|CustomFunction|DataSourceOpExpr|DataSourceTemplate|DateRangeStrings|DateString|DefaultStylesClassNamePropType|DefaultStylesPropType|EventHandler|Expr|ExprText|FigmaComponentMapping|FunctionArg|FunctionExpr|FunctionType|GenericEventHandler|GlobalVariantGroup|GlobalVariantGroupParam|GlobalVariantSplitContent|HostLessPackageInfo|HrefType|ImageAsset|ImageAssetRef|Img|Interaction|LabeledSelector|MapExpr|Marker|Mixin|NameArg|NamedState|NodeMarker|Num|ObjectPath|PageArena|PageHref|PageMeta|Param|PlumeInfo|PlumeInstance|PrimitiveType|ProjectDependency|PropParam|QueryData|QueryInvalidationExpr|QueryRef|RandomSplitSlice|RawText|RenderExpr|RenderFuncType|RenderableType|Rep|RichText|Rule|RuleSet|Scalar|SegmentSplitSlice|SelectorRuleSet|Site|SlotParam|Split|SplitContent|SplitSlice|State|StateChangeHandlerParam|StateParam|StrongFunctionArg|StyleExpr|StyleMarker|StyleNode|StylePropType|StyleScopeClassNamePropType|StyleToken|StyleTokenRef|TargetType|TemplatedString|Text|Theme|ThemeLayoutSettings|ThemeStyle|TplComponent|TplNode|TplRef|TplSlot|TplTag|Var|VarRef|Variant|VariantGroup|VariantGroupState|VariantSetting|VariantedRuleSet|VariantedValue|VariantsRef|VirtualRenderExpr`;
const TYPES = `AnyType|Arena|ArenaChild|ArenaFrame|ArenaFrameCell|ArenaFrameGrid|ArenaFrameRow|Arg|ArgType|BindingStruct|BoolType|Choice|ClassNamePropType|CodeComponentHelper|CodeComponentMeta|CodeComponentVariantMeta|CodeLibrary|CollectionExpr|ColorPropType|ColumnsConfig|ColumnsSetting|Component|ComponentArena|ComponentDataQuery|ComponentInstance|ComponentServerQuery|ComponentSwapSplitContent|ComponentTemplateInfo|ComponentVariantGroup|ComponentVariantSplitContent|CompositeExpr|CustomCode|CustomFunction|CustomFunctionExpr|DataSourceOpExpr|DataSourceTemplate|DateRangeStrings|DateString|DefaultStylesClassNamePropType|DefaultStylesPropType|EventHandler|Expr|ExprText|FigmaComponentMapping|FunctionArg|FunctionExpr|FunctionType|GenericEventHandler|GlobalVariantGroup|GlobalVariantGroupParam|GlobalVariantSplitContent|HostLessPackageInfo|HrefType|ImageAsset|ImageAssetRef|Img|Interaction|LabeledSelector|MapExpr|Marker|Mixin|NameArg|NamedState|NodeMarker|Num|ObjectPath|PageArena|PageHref|PageMeta|Param|PlumeInfo|PlumeInstance|PrimitiveType|ProjectDependency|PropParam|QueryData|QueryInvalidationExpr|QueryRef|RandomSplitSlice|RawText|RenderExpr|RenderFuncType|RenderableType|Rep|RichText|Rule|RuleSet|Scalar|SegmentSplitSlice|SelectorRuleSet|Site|SlotParam|Split|SplitContent|SplitSlice|State|StateChangeHandlerParam|StateParam|StrongFunctionArg|StyleExpr|StyleMarker|StyleNode|StylePropType|StyleScopeClassNamePropType|StyleToken|StyleTokenRef|TargetType|TemplatedString|Text|Theme|ThemeLayoutSettings|ThemeStyle|TplComponent|TplNode|TplRef|TplSlot|TplTag|Var|VarRef|Variant|VariantGroup|VariantGroupState|VariantSetting|VariantedRuleSet|VariantedValue|VariantsRef|VirtualRenderExpr`;

const clientFiles = [
"platform/wab/src/wab/main.tsx",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { BundleMigrationType } from "@/wab/server/db/bundle-migration-utils";
import { BundledMigrationFn } from "@/wab/server/db/BundleMigrator";

export const migrate: BundledMigrationFn = async (bundle) => {
for (const inst of Object.values(bundle.map)) {
if (inst["__type"] === "CustomFunction") {
inst["params"] = [];
} else if (inst["__type"] === "Component") {
inst["serverQueries"] = [];
}
}
};

export const MIGRATION_TYPE: BundleMigrationType = "bundled";
3 changes: 2 additions & 1 deletion platform/wab/src/wab/server/db/migrations-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,5 @@ platform/wab/src/wab/server/bundle-migrations/234-variant-selectors-no-display-n
platform/wab/src/wab/server/bundle-migrations/235-variant-selectors-no-display-name-corrected.ts
platform/wab/src/wab/server/bundle-migrations/236-rename-duplicated-components.ts
platform/wab/src/wab/server/bundle-migrations/237-code-component-variants-add-fields.ts
platform/wab/src/wab/server/bundle-migrations/238-code-component-variants-update-fields.ts
platform/wab/src/wab/server/bundle-migrations/238-code-component-variants-update-fields.ts
platform/wab/src/wab/server/bundle-migrations/239-add-server-queries.ts
9 changes: 9 additions & 0 deletions platform/wab/src/wab/shared/model/model-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ CustomFunction
importName: String
defaultExport: Bool
namespace: String?
params: [ArgType]
CodeLibrary
name: String
Expand Down Expand Up @@ -346,6 +347,10 @@ ComponentDataQuery
@Const uuid: String
name: String
op: DataSourceOpExpr?
ComponentServerQuery
@Const uuid: String
name: String
op: CustomFunctionExpr?
CodeComponentHelper
importPath: String
importName: String
Expand Down Expand Up @@ -398,6 +403,7 @@ Component
templateInfo: ComponentTemplateInfo?
metadata: Map[String, String]
dataQueries: [ComponentDataQuery]
serverQueries: [ComponentServerQuery]
figmaMappings: [FigmaComponentMapping]
alwaysAutoName: Bool
trapsFocus: Bool
Expand Down Expand Up @@ -563,6 +569,9 @@ Expr
queryInvalidation: QueryInvalidationExpr?
# Minimum role necessary to execute this operation
roleId: String?
CustomFunctionExpr
@WeakRef func: CustomFunction
args: [FunctionArg]
VarRef
@WeakRef variable: Var
TplRef
Expand Down
28 changes: 28 additions & 0 deletions platform/wab/src/wab/shared/site-diffs/model-conflicts-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,16 @@ export const modelConflictsMeta: ModelConflictsMeta = {
importName: "generic",
importPath: "generic",
namespace: "generic",
params: {
arrayType: "ordered",
conflictType: "merge",
mergeKey: "argName",
contents: true,
handleUpdatedValues: (params, parent, bundler) =>
shallowCloneArrayValuesAndAddToBundle(params, parent, bundler, [
classes.ArgType,
]),
},
},
CodeLibrary: {
importType: "generic",
Expand Down Expand Up @@ -646,6 +656,11 @@ export const modelConflictsMeta: ModelConflictsMeta = {
name: "generic",
op: "generic",
},
ComponentServerQuery: {
uuid: "unexpected",
name: "generic",
op: "generic",
},
CodeComponentHelper: {
importName: "generic",
importPath: "generic",
Expand Down Expand Up @@ -740,6 +755,11 @@ export const modelConflictsMeta: ModelConflictsMeta = {
conflictType: "rename",
nameKey: `name`,
},
serverQueries: {
arrayType: "ordered",
conflictType: "rename",
nameKey: `name`,
},
figmaMappings: {
arrayType: "unordered",
conflictType: `merge`,
Expand Down Expand Up @@ -1060,6 +1080,14 @@ export const modelConflictsMeta: ModelConflictsMeta = {
mergeKeyIsIdentity: true,
},
},
CustomFunctionExpr: {
func: "generic",
args: {
arrayType: "ordered",
conflictType: "merge",
mergeKeyIsIdentity: true,
},
},
MapExpr: {
mapExpr: "contents",
},
Expand Down

0 comments on commit f22e49a

Please sign in to comment.