sovrium 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3497 -0
- package/LICENSE.md +147 -0
- package/LICENSE_EE.md +297 -0
- package/README.md +321 -0
- package/drizzle/0000_melted_kabuki.sql +163 -0
- package/drizzle/meta/0000_snapshot.json +1216 -0
- package/drizzle/meta/_journal.json +13 -0
- package/package.json +167 -0
- package/schemas/0.0.1/app.openapi.json +70 -0
- package/schemas/0.0.1/app.schema.json +7961 -0
- package/schemas/0.0.2/app.openapi.json +80 -0
- package/schemas/0.0.2/app.schema.json +8829 -0
- package/schemas/development/app.openapi.json +70 -0
- package/schemas/development/app.schema.json +7456 -0
- package/src/application/errors/app-validation-error.ts +14 -0
- package/src/application/errors/static-generation-error.ts +16 -0
- package/src/application/metadata/favicon-transformer.ts +127 -0
- package/src/application/models/server.ts +27 -0
- package/src/application/ports/models/user-metadata.ts +36 -0
- package/src/application/ports/models/user-session.ts +34 -0
- package/src/application/ports/repositories/activity-log-repository.ts +68 -0
- package/src/application/ports/repositories/activity-repository.ts +49 -0
- package/src/application/ports/repositories/analytics-repository.ts +164 -0
- package/src/application/ports/repositories/auth-repository.ts +33 -0
- package/src/application/ports/repositories/batch-repository.ts +86 -0
- package/src/application/ports/repositories/comment-repository.ts +150 -0
- package/src/application/ports/repositories/index.ts +41 -0
- package/src/application/ports/repositories/table-repository.ts +139 -0
- package/src/application/ports/services/css-compiler.ts +55 -0
- package/src/application/ports/services/index.ts +16 -0
- package/src/application/ports/services/page-renderer.ts +79 -0
- package/src/application/ports/services/server-factory.ts +80 -0
- package/src/application/ports/services/static-site-generator.ts +82 -0
- package/src/application/use-cases/activity/programs.ts +66 -0
- package/src/application/use-cases/analytics/collect-page-view.ts +114 -0
- package/src/application/use-cases/analytics/purge-old-data.ts +40 -0
- package/src/application/use-cases/analytics/query-campaigns.ts +43 -0
- package/src/application/use-cases/analytics/query-devices.ts +36 -0
- package/src/application/use-cases/analytics/query-overview.ts +50 -0
- package/src/application/use-cases/analytics/query-pages.ts +40 -0
- package/src/application/use-cases/analytics/query-referrers.ts +43 -0
- package/src/application/use-cases/analytics/ua-parser.ts +89 -0
- package/src/application/use-cases/analytics/visitor-hash.ts +77 -0
- package/src/application/use-cases/auth/bootstrap-admin.ts +270 -0
- package/src/application/use-cases/list-activity-logs.ts +123 -0
- package/src/application/use-cases/server/generate-static-helpers.ts +374 -0
- package/src/application/use-cases/server/generate-static.ts +287 -0
- package/src/application/use-cases/server/start-server.ts +118 -0
- package/src/application/use-cases/server/startup-error-handler.ts +69 -0
- package/src/application/use-cases/server/static-content-generators.ts +182 -0
- package/src/application/use-cases/server/static-language-generators.ts +181 -0
- package/src/application/use-cases/server/static-url-rewriter.ts +237 -0
- package/src/application/use-cases/server/translation-replacer.ts +164 -0
- package/src/application/use-cases/tables/activity-programs.ts +93 -0
- package/src/application/use-cases/tables/batch-operations.ts +156 -0
- package/src/application/use-cases/tables/comment-programs.ts +436 -0
- package/src/application/use-cases/tables/permissions/permissions.ts +25 -0
- package/src/application/use-cases/tables/programs.ts +435 -0
- package/src/application/use-cases/tables/table-operations.ts +412 -0
- package/src/application/use-cases/tables/user-role.ts +52 -0
- package/src/application/use-cases/tables/utils/display-formatter.ts +471 -0
- package/src/application/use-cases/tables/utils/field-read-filter.ts +189 -0
- package/src/application/use-cases/tables/utils/list-helpers.ts +122 -0
- package/src/application/use-cases/tables/utils/record-transformer.ts +319 -0
- package/src/cli.ts +370 -0
- package/src/domain/errors/create-tagged-error.ts +36 -0
- package/src/domain/errors/index.ts +78 -0
- package/src/domain/models/api/analytics.ts +179 -0
- package/src/domain/models/api/auth.ts +231 -0
- package/src/domain/models/api/common.ts +60 -0
- package/src/domain/models/api/error.ts +89 -0
- package/src/domain/models/api/health.ts +38 -0
- package/src/domain/models/api/index.ts +42 -0
- package/src/domain/models/api/request.ts +132 -0
- package/src/domain/models/api/tables.ts +444 -0
- package/src/domain/models/app/analytics/index.ts +129 -0
- package/src/domain/models/app/auth/config.ts +116 -0
- package/src/domain/models/app/auth/index.ts +230 -0
- package/src/domain/models/app/auth/methods/email-and-password.ts +67 -0
- package/src/domain/models/app/auth/methods/index.ts +11 -0
- package/src/domain/models/app/auth/methods/magic-link.ts +54 -0
- package/src/domain/models/app/auth/oauth/index.ts +8 -0
- package/src/domain/models/app/auth/oauth/providers.ts +105 -0
- package/src/domain/models/app/auth/plugins/admin.ts +130 -0
- package/src/domain/models/app/auth/plugins/index.ts +74 -0
- package/src/domain/models/app/auth/plugins/two-factor.ts +63 -0
- package/src/domain/models/app/auth/roles.ts +179 -0
- package/src/domain/models/app/auth/strategies.ts +191 -0
- package/src/domain/models/app/auth/validation.ts +127 -0
- package/src/domain/models/app/common/branded-ids.ts +200 -0
- package/src/domain/models/app/common/definitions.ts +187 -0
- package/src/domain/models/app/component/common/component-children.ts +119 -0
- package/src/domain/models/app/component/common/component-props.ts +89 -0
- package/src/domain/models/app/component/common/component-reference.ts +170 -0
- package/src/domain/models/app/component/component.ts +81 -0
- package/src/domain/models/app/components.ts +65 -0
- package/src/domain/models/app/description.ts +83 -0
- package/src/domain/models/app/index.ts +258 -0
- package/src/domain/models/app/language/language-config.ts +200 -0
- package/src/domain/models/app/languages.ts +205 -0
- package/src/domain/models/app/name.ts +66 -0
- package/src/domain/models/app/page/common/interactions/click-interaction.ts +116 -0
- package/src/domain/models/app/page/common/interactions/entrance-animation.ts +84 -0
- package/src/domain/models/app/page/common/interactions/hover-interaction.ts +144 -0
- package/src/domain/models/app/page/common/interactions/interactions.ts +64 -0
- package/src/domain/models/app/page/common/interactions/scroll-interaction.ts +93 -0
- package/src/domain/models/app/page/common/responsive.ts +114 -0
- package/src/domain/models/app/page/common/url.ts +35 -0
- package/src/domain/models/app/page/common/variable-reference.ts +53 -0
- package/src/domain/models/app/page/id.ts +44 -0
- package/src/domain/models/app/page/index.ts +270 -0
- package/src/domain/models/app/page/meta/analytics.ts +248 -0
- package/src/domain/models/app/page/meta/custom-elements.ts +180 -0
- package/src/domain/models/app/page/meta/dns-prefetch.ts +77 -0
- package/src/domain/models/app/page/meta/favicon-set.ts +203 -0
- package/src/domain/models/app/page/meta/favicon.ts +50 -0
- package/src/domain/models/app/page/meta/favicons-config.ts +73 -0
- package/src/domain/models/app/page/meta/index.ts +278 -0
- package/src/domain/models/app/page/meta/open-graph.ts +166 -0
- package/src/domain/models/app/page/meta/preload.ts +190 -0
- package/src/domain/models/app/page/meta/structured-data/article.ts +211 -0
- package/src/domain/models/app/page/meta/structured-data/breadcrumb.ts +115 -0
- package/src/domain/models/app/page/meta/structured-data/common-fields.ts +201 -0
- package/src/domain/models/app/page/meta/structured-data/education-event.ts +256 -0
- package/src/domain/models/app/page/meta/structured-data/faq-page.ts +127 -0
- package/src/domain/models/app/page/meta/structured-data/index.ts +95 -0
- package/src/domain/models/app/page/meta/structured-data/local-business.ts +247 -0
- package/src/domain/models/app/page/meta/structured-data/organization.ts +171 -0
- package/src/domain/models/app/page/meta/structured-data/person.ts +138 -0
- package/src/domain/models/app/page/meta/structured-data/postal-address.ts +106 -0
- package/src/domain/models/app/page/meta/structured-data/product.ts +214 -0
- package/src/domain/models/app/page/meta/twitter-card.ts +217 -0
- package/src/domain/models/app/page/name.ts +38 -0
- package/src/domain/models/app/page/path.ts +21 -0
- package/src/domain/models/app/page/scripts/external-scripts.ts +163 -0
- package/src/domain/models/app/page/scripts/features.ts +135 -0
- package/src/domain/models/app/page/scripts/inline-scripts.ts +114 -0
- package/src/domain/models/app/page/scripts/scripts.ts +102 -0
- package/src/domain/models/app/page/sections.ts +298 -0
- package/src/domain/models/app/pages.ts +61 -0
- package/src/domain/models/app/permissions/index.ts +61 -0
- package/src/domain/models/app/permissions/resource-action.ts +114 -0
- package/src/domain/models/app/permissions/roles.ts +120 -0
- package/src/domain/models/app/table/check-constraints.ts +105 -0
- package/src/domain/models/app/table/cycle-detection.ts +124 -0
- package/src/domain/models/app/table/database-identifier.ts +153 -0
- package/src/domain/models/app/table/field-name.ts +36 -0
- package/src/domain/models/app/table/field-types/advanced/array-field.ts +33 -0
- package/src/domain/models/app/table/field-types/advanced/autonumber-field.ts +54 -0
- package/src/domain/models/app/table/field-types/advanced/button-field.ts +56 -0
- package/src/domain/models/app/table/field-types/advanced/color-field.ts +57 -0
- package/src/domain/models/app/table/field-types/advanced/count-field.ts +54 -0
- package/src/domain/models/app/table/field-types/advanced/formula-field.ts +58 -0
- package/src/domain/models/app/table/field-types/advanced/geolocation-field.ts +49 -0
- package/src/domain/models/app/table/field-types/advanced/index.ts +16 -0
- package/src/domain/models/app/table/field-types/advanced/json-field.ts +25 -0
- package/src/domain/models/app/table/field-types/advanced/unknown-field.ts +85 -0
- package/src/domain/models/app/table/field-types/base-field.ts +42 -0
- package/src/domain/models/app/table/field-types/date-time/created-at-field.ts +49 -0
- package/src/domain/models/app/table/field-types/date-time/date-field.ts +95 -0
- package/src/domain/models/app/table/field-types/date-time/deleted-at-field.ts +56 -0
- package/src/domain/models/app/table/field-types/date-time/duration-field.ts +73 -0
- package/src/domain/models/app/table/field-types/date-time/index.ts +12 -0
- package/src/domain/models/app/table/field-types/date-time/updated-at-field.ts +50 -0
- package/src/domain/models/app/table/field-types/index.ts +19 -0
- package/src/domain/models/app/table/field-types/media/barcode-field.ts +58 -0
- package/src/domain/models/app/table/field-types/media/index.ts +10 -0
- package/src/domain/models/app/table/field-types/media/multiple-attachments-field.ts +80 -0
- package/src/domain/models/app/table/field-types/media/single-attachment-field.ts +81 -0
- package/src/domain/models/app/table/field-types/numeric/currency-field.ts +144 -0
- package/src/domain/models/app/table/field-types/numeric/decimal-field.ts +113 -0
- package/src/domain/models/app/table/field-types/numeric/index.ts +13 -0
- package/src/domain/models/app/table/field-types/numeric/integer-field.ts +98 -0
- package/src/domain/models/app/table/field-types/numeric/percentage-field.ts +115 -0
- package/src/domain/models/app/table/field-types/numeric/progress-field.ts +71 -0
- package/src/domain/models/app/table/field-types/numeric/rating-field.ts +74 -0
- package/src/domain/models/app/table/field-types/relational/index.ts +10 -0
- package/src/domain/models/app/table/field-types/relational/lookup-field.ts +46 -0
- package/src/domain/models/app/table/field-types/relational/relationship-field.ts +112 -0
- package/src/domain/models/app/table/field-types/relational/rollup-field.ts +58 -0
- package/src/domain/models/app/table/field-types/selection/checkbox-field.ts +51 -0
- package/src/domain/models/app/table/field-types/selection/index.ts +11 -0
- package/src/domain/models/app/table/field-types/selection/multi-select-field.ts +68 -0
- package/src/domain/models/app/table/field-types/selection/single-select-field.ts +54 -0
- package/src/domain/models/app/table/field-types/selection/status-field.ts +37 -0
- package/src/domain/models/app/table/field-types/text/email-field.ts +80 -0
- package/src/domain/models/app/table/field-types/text/index.ts +13 -0
- package/src/domain/models/app/table/field-types/text/long-text-field.ts +77 -0
- package/src/domain/models/app/table/field-types/text/phone-number-field.ts +82 -0
- package/src/domain/models/app/table/field-types/text/rich-text-field.ts +66 -0
- package/src/domain/models/app/table/field-types/text/single-line-text-field.ts +79 -0
- package/src/domain/models/app/table/field-types/text/url-field.ts +81 -0
- package/src/domain/models/app/table/field-types/user/created-by-field.ts +50 -0
- package/src/domain/models/app/table/field-types/user/deleted-by-field.ts +57 -0
- package/src/domain/models/app/table/field-types/user/index.ts +11 -0
- package/src/domain/models/app/table/field-types/user/updated-by-field.ts +51 -0
- package/src/domain/models/app/table/field-types/user/user-field.ts +52 -0
- package/src/domain/models/app/table/field-types/validation-utils.ts +166 -0
- package/src/domain/models/app/table/fields.ts +216 -0
- package/src/domain/models/app/table/foreign-keys.ts +111 -0
- package/src/domain/models/app/table/formula-keywords.ts +326 -0
- package/src/domain/models/app/table/id.ts +31 -0
- package/src/domain/models/app/table/index.ts +290 -0
- package/src/domain/models/app/table/indexes.ts +80 -0
- package/src/domain/models/app/table/name.ts +37 -0
- package/src/domain/models/app/table/permissions/field-permission.ts +83 -0
- package/src/domain/models/app/table/permissions/index.ts +167 -0
- package/src/domain/models/app/table/permissions/permission-evaluator.ts +372 -0
- package/src/domain/models/app/table/permissions/permission.ts +49 -0
- package/src/domain/models/app/table/primary-key.ts +62 -0
- package/src/domain/models/app/table/table-formula-validation.ts +168 -0
- package/src/domain/models/app/table/table-indexes-validation.ts +38 -0
- package/src/domain/models/app/table/table-permissions-validation.ts +77 -0
- package/src/domain/models/app/table/table-primary-key-validation.ts +49 -0
- package/src/domain/models/app/table/table-views-validation.ts +408 -0
- package/src/domain/models/app/table/unique-constraints.ts +79 -0
- package/src/domain/models/app/table/views/fields.ts +28 -0
- package/src/domain/models/app/table/views/filters.ts +162 -0
- package/src/domain/models/app/table/views/group-by.ts +32 -0
- package/src/domain/models/app/table/views/id.ts +50 -0
- package/src/domain/models/app/table/views/index.ts +177 -0
- package/src/domain/models/app/table/views/name.ts +32 -0
- package/src/domain/models/app/table/views/permissions.ts +98 -0
- package/src/domain/models/app/table/views/sorts.ts +31 -0
- package/src/domain/models/app/tables.ts +695 -0
- package/src/domain/models/app/theme/animations.ts +208 -0
- package/src/domain/models/app/theme/border-radius.ts +58 -0
- package/src/domain/models/app/theme/breakpoints.ts +62 -0
- package/src/domain/models/app/theme/colors.ts +110 -0
- package/src/domain/models/app/theme/fonts.ts +164 -0
- package/src/domain/models/app/theme/shadows.ts +61 -0
- package/src/domain/models/app/theme/spacing.ts +115 -0
- package/src/domain/models/app/theme.ts +66 -0
- package/src/domain/models/app/version.ts +87 -0
- package/src/domain/models/record-comment.ts +91 -0
- package/src/domain/utils/content-parsing.ts +49 -0
- package/src/domain/utils/format-detection.ts +69 -0
- package/src/domain/utils/index.ts +9 -0
- package/src/domain/utils/route-matcher.ts +184 -0
- package/src/domain/utils/translation-resolver.ts +170 -0
- package/src/index.ts +208 -0
- package/src/infrastructure/analytics/tracking-script.ts +48 -0
- package/src/infrastructure/auth/better-auth/auth.ts +216 -0
- package/src/infrastructure/auth/better-auth/email-handlers.ts +162 -0
- package/src/infrastructure/auth/better-auth/index.ts +16 -0
- package/src/infrastructure/auth/better-auth/layer.ts +97 -0
- package/src/infrastructure/auth/better-auth/plugins/admin.ts +56 -0
- package/src/infrastructure/auth/better-auth/plugins/magic-link.ts +31 -0
- package/src/infrastructure/auth/better-auth/plugins/two-factor.ts +19 -0
- package/src/infrastructure/auth/better-auth/schema.ts +152 -0
- package/src/infrastructure/auth/index.ts +27 -0
- package/src/infrastructure/css/cache/css-cache-service.ts +130 -0
- package/src/infrastructure/css/compiler.ts +210 -0
- package/src/infrastructure/css/css-compiler-live.ts +20 -0
- package/src/infrastructure/css/index.ts +25 -0
- package/src/infrastructure/css/styles/animation-styles-generator.ts +177 -0
- package/src/infrastructure/css/styles/click-animations.ts +147 -0
- package/src/infrastructure/css/styles/component-layer-generators.ts +147 -0
- package/src/infrastructure/css/theme/theme-generators.ts +130 -0
- package/src/infrastructure/css/theme/theme-layer-generators.ts +219 -0
- package/src/infrastructure/css/theme/theme-token-resolver.ts +76 -0
- package/src/infrastructure/database/activity-queries.ts +111 -0
- package/src/infrastructure/database/auth/auth-validation.ts +101 -0
- package/src/infrastructure/database/drizzle/db-bun.ts +17 -0
- package/src/infrastructure/database/drizzle/db.ts +17 -0
- package/src/infrastructure/database/drizzle/index.ts +16 -0
- package/src/infrastructure/database/drizzle/layer.ts +34 -0
- package/src/infrastructure/database/drizzle/migrate.ts +77 -0
- package/src/infrastructure/database/drizzle/schema/activity-log.ts +111 -0
- package/src/infrastructure/database/drizzle/schema/analytics-page-views.ts +116 -0
- package/src/infrastructure/database/drizzle/schema/migration-audit.ts +68 -0
- package/src/infrastructure/database/drizzle/schema/record-comments.ts +79 -0
- package/src/infrastructure/database/drizzle/schema.ts +12 -0
- package/src/infrastructure/database/field-utils.ts +87 -0
- package/src/infrastructure/database/filter-operators.ts +136 -0
- package/src/infrastructure/database/formula/formula-trigger-generators.ts +114 -0
- package/src/infrastructure/database/formula/formula-utils.ts +440 -0
- package/src/infrastructure/database/generators/index-generators.ts +152 -0
- package/src/infrastructure/database/generators/trigger-generators.ts +154 -0
- package/src/infrastructure/database/index.ts +35 -0
- package/src/infrastructure/database/lookup/lookup-expression-generators.ts +356 -0
- package/src/infrastructure/database/lookup/lookup-expressions.ts +116 -0
- package/src/infrastructure/database/lookup/lookup-view-generators.ts +403 -0
- package/src/infrastructure/database/lookup/lookup-view-helpers.ts +65 -0
- package/src/infrastructure/database/lookup/lookup-view-triggers.ts +121 -0
- package/src/infrastructure/database/migration-audit-trail.ts +375 -0
- package/src/infrastructure/database/repositories/activity-log-repository-live.ts +99 -0
- package/src/infrastructure/database/repositories/activity-repository-live.ts +21 -0
- package/src/infrastructure/database/repositories/analytics-repository-live.ts +316 -0
- package/src/infrastructure/database/repositories/auth-repository-live.ts +42 -0
- package/src/infrastructure/database/repositories/batch-repository-live.ts +29 -0
- package/src/infrastructure/database/repositories/comment-repository-live.ts +39 -0
- package/src/infrastructure/database/repositories/table-repository-live.ts +38 -0
- package/src/infrastructure/database/schema/schema-dependency-sorting.ts +142 -0
- package/src/infrastructure/database/schema/schema-initializer.ts +598 -0
- package/src/infrastructure/database/schema-migration/column-detection.ts +286 -0
- package/src/infrastructure/database/schema-migration/constants.ts +31 -0
- package/src/infrastructure/database/schema-migration/constraint-sync.ts +288 -0
- package/src/infrastructure/database/schema-migration/index-sync.ts +108 -0
- package/src/infrastructure/database/schema-migration/index.ts +66 -0
- package/src/infrastructure/database/schema-migration/migration-statements.ts +106 -0
- package/src/infrastructure/database/schema-migration/rename-detection.ts +87 -0
- package/src/infrastructure/database/schema-migration/table-operations.ts +65 -0
- package/src/infrastructure/database/schema-migration/type-utils.ts +98 -0
- package/src/infrastructure/database/schema-migration/types.ts +14 -0
- package/src/infrastructure/database/schema-migration-helpers.ts +53 -0
- package/src/infrastructure/database/session-context.ts +20 -0
- package/src/infrastructure/database/sql/sql-check-constraints.ts +252 -0
- package/src/infrastructure/database/sql/sql-column-generators.ts +174 -0
- package/src/infrastructure/database/sql/sql-execution.ts +245 -0
- package/src/infrastructure/database/sql/sql-field-predicates.ts +81 -0
- package/src/infrastructure/database/sql/sql-generators.ts +91 -0
- package/src/infrastructure/database/sql/sql-junction-tables.ts +79 -0
- package/src/infrastructure/database/sql/sql-key-constraints.ts +210 -0
- package/src/infrastructure/database/sql/sql-type-mappings.ts +106 -0
- package/src/infrastructure/database/sql/sql-utils.ts +53 -0
- package/src/infrastructure/database/table-live-layers.ts +30 -0
- package/src/infrastructure/database/table-operations/column-generators.ts +82 -0
- package/src/infrastructure/database/table-operations/create-table-sql.ts +81 -0
- package/src/infrastructure/database/table-operations/index.ts +55 -0
- package/src/infrastructure/database/table-operations/migration-utils.ts +157 -0
- package/src/infrastructure/database/table-operations/table-effects.ts +234 -0
- package/src/infrastructure/database/table-operations/table-features.ts +96 -0
- package/src/infrastructure/database/table-operations/type-compatibility.ts +58 -0
- package/src/infrastructure/database/table-operations.ts +47 -0
- package/src/infrastructure/database/table-queries/batch/batch-create.ts +80 -0
- package/src/infrastructure/database/table-queries/batch/batch-delete.ts +212 -0
- package/src/infrastructure/database/table-queries/batch/batch-helpers.ts +124 -0
- package/src/infrastructure/database/table-queries/batch/batch-restore.ts +161 -0
- package/src/infrastructure/database/table-queries/batch/batch-update.ts +146 -0
- package/src/infrastructure/database/table-queries/batch/batch-upsert.ts +357 -0
- package/src/infrastructure/database/table-queries/batch/batch.ts +14 -0
- package/src/infrastructure/database/table-queries/crud/crud-read.ts +351 -0
- package/src/infrastructure/database/table-queries/crud/crud-write.ts +399 -0
- package/src/infrastructure/database/table-queries/crud/crud.ts +16 -0
- package/src/infrastructure/database/table-queries/index.ts +11 -0
- package/src/infrastructure/database/table-queries/mutation-helpers/authorship-helpers.ts +152 -0
- package/src/infrastructure/database/table-queries/mutation-helpers/create-record-helpers.ts +90 -0
- package/src/infrastructure/database/table-queries/mutation-helpers/delete-helpers.ts +163 -0
- package/src/infrastructure/database/table-queries/mutation-helpers/record-fetch-helpers.ts +79 -0
- package/src/infrastructure/database/table-queries/mutation-helpers/update-helpers.ts +74 -0
- package/src/infrastructure/database/table-queries/query-helpers/activity-log-helpers.ts +53 -0
- package/src/infrastructure/database/table-queries/query-helpers/activity-queries.ts +106 -0
- package/src/infrastructure/database/table-queries/query-helpers/aggregation-helpers.ts +314 -0
- package/src/infrastructure/database/table-queries/query-helpers/comment-queries.ts +414 -0
- package/src/infrastructure/database/table-queries/query-helpers/record-validation-queries.ts +126 -0
- package/src/infrastructure/database/table-queries/query-helpers/trash-helpers.ts +58 -0
- package/src/infrastructure/database/table-queries/shared/error-handling.ts +47 -0
- package/src/infrastructure/database/table-queries/shared/typed-execute.ts +27 -0
- package/src/infrastructure/database/table-queries/shared/user-join-helpers.ts +38 -0
- package/src/infrastructure/database/table-queries/shared/validation.ts +39 -0
- package/src/infrastructure/database/views/view-generators.ts +258 -0
- package/src/infrastructure/devtools/devtools-layer.ts +43 -0
- package/src/infrastructure/devtools/index.ts +8 -0
- package/src/infrastructure/email/email-config.ts +103 -0
- package/src/infrastructure/email/email-service.ts +152 -0
- package/src/infrastructure/email/index.ts +107 -0
- package/src/infrastructure/email/nodemailer.ts +125 -0
- package/src/infrastructure/email/templates.ts +244 -0
- package/src/infrastructure/errors/auth-config-required-error.ts +21 -0
- package/src/infrastructure/errors/auth-error.ts +16 -0
- package/src/infrastructure/errors/css-compilation-error.ts +14 -0
- package/src/infrastructure/errors/index.ts +26 -0
- package/src/infrastructure/errors/schema-initialization-error.ts +19 -0
- package/src/infrastructure/errors/server-creation-error.ts +14 -0
- package/src/infrastructure/filesystem/copy-directory.ts +136 -0
- package/src/infrastructure/layers/app-layer.ts +61 -0
- package/src/infrastructure/layers/page-renderer-layer.ts +41 -0
- package/src/infrastructure/logging/index.ts +8 -0
- package/src/infrastructure/logging/logger.ts +204 -0
- package/src/infrastructure/schema/file-loader.ts +53 -0
- package/src/infrastructure/schema/index.ts +15 -0
- package/src/infrastructure/schema/remote-loader.ts +48 -0
- package/src/infrastructure/server/index.ts +26 -0
- package/src/infrastructure/server/language-detection.ts +87 -0
- package/src/infrastructure/server/lifecycle.ts +67 -0
- package/src/infrastructure/server/route-setup/api-routes.ts +310 -0
- package/src/infrastructure/server/route-setup/auth-route-utils.ts +399 -0
- package/src/infrastructure/server/route-setup/auth-routes.ts +245 -0
- package/src/infrastructure/server/route-setup/openapi-routes.ts +45 -0
- package/src/infrastructure/server/route-setup/openapi-schema.ts +120 -0
- package/src/infrastructure/server/route-setup/page-routes.ts +219 -0
- package/src/infrastructure/server/route-setup/static-assets.ts +191 -0
- package/src/infrastructure/server/server-factory-live.ts +45 -0
- package/src/infrastructure/server/server.ts +275 -0
- package/src/infrastructure/server/ssg-adapter.ts +196 -0
- package/src/infrastructure/server/static-site-generator-live.ts +20 -0
- package/src/infrastructure/utils/accept-language-parser.ts +106 -0
- package/src/infrastructure/utils/glob-matcher.ts +50 -0
- package/src/presentation/api/client.ts +114 -0
- package/src/presentation/api/middleware/auth.ts +233 -0
- package/src/presentation/api/middleware/table.ts +155 -0
- package/src/presentation/api/middleware/validation.ts +88 -0
- package/src/presentation/api/routes/activity/get-activity-by-id-handler.ts +77 -0
- package/src/presentation/api/routes/activity/index.ts +28 -0
- package/src/presentation/api/routes/activity.ts +339 -0
- package/src/presentation/api/routes/analytics.ts +328 -0
- package/src/presentation/api/routes/auth.ts +169 -0
- package/src/presentation/api/routes/index.ts +11 -0
- package/src/presentation/api/routes/tables/activity-handlers.ts +57 -0
- package/src/presentation/api/routes/tables/batch-permission-helpers.ts +163 -0
- package/src/presentation/api/routes/tables/batch-routes.ts +355 -0
- package/src/presentation/api/routes/tables/comment-handlers.ts +377 -0
- package/src/presentation/api/routes/tables/create-record-helpers.ts +179 -0
- package/src/presentation/api/routes/tables/effect-runner.ts +58 -0
- package/src/presentation/api/routes/tables/error-handlers.ts +53 -0
- package/src/presentation/api/routes/tables/field-permission-validation.ts +167 -0
- package/src/presentation/api/routes/tables/filter-parser.ts +75 -0
- package/src/presentation/api/routes/tables/formula-parser.ts +118 -0
- package/src/presentation/api/routes/tables/index.ts +113 -0
- package/src/presentation/api/routes/tables/list-records-filter.ts +54 -0
- package/src/presentation/api/routes/tables/param-parsers.ts +59 -0
- package/src/presentation/api/routes/tables/record-handlers.ts +484 -0
- package/src/presentation/api/routes/tables/record-routes.ts +53 -0
- package/src/presentation/api/routes/tables/record-update-handler.ts +200 -0
- package/src/presentation/api/routes/tables/sort-validation.ts +85 -0
- package/src/presentation/api/routes/tables/table-routes.ts +76 -0
- package/src/presentation/api/routes/tables/timezone-validation.ts +41 -0
- package/src/presentation/api/routes/tables/upsert-helpers.ts +471 -0
- package/src/presentation/api/routes/tables/utils.ts +159 -0
- package/src/presentation/api/routes/tables/view-routes.ts +51 -0
- package/src/presentation/api/routes/tables.ts +9 -0
- package/src/presentation/api/utils/context-helpers.ts +43 -0
- package/src/presentation/api/utils/error-sanitizer.ts +235 -0
- package/src/presentation/api/utils/field-permission-validator.ts +53 -0
- package/src/presentation/api/utils/filter-field-validator.ts +90 -0
- package/src/presentation/api/utils/index.ts +13 -0
- package/src/presentation/api/utils/run-effect.ts +94 -0
- package/src/presentation/api/utils/validate-request.ts +89 -0
- package/src/presentation/api/validation/index.ts +29 -0
- package/src/presentation/api/validation/rules/field-rules.ts +158 -0
- package/src/presentation/api/validation/rules/record-rules.ts +73 -0
- package/src/presentation/cli/index.ts +19 -0
- package/src/presentation/cli/schema-loader.ts +172 -0
- package/src/presentation/hooks/use-breakpoint.ts +155 -0
- package/src/presentation/rendering/render-error-pages.tsx +60 -0
- package/src/presentation/rendering/render-homepage.tsx +137 -0
- package/src/presentation/scripts/script-renderers.ts +112 -0
- package/src/presentation/styling/animation-composer.ts +117 -0
- package/src/presentation/styling/index.ts +13 -0
- package/src/presentation/styling/parse-style.ts +243 -0
- package/src/presentation/styling/style-utils.ts +50 -0
- package/src/presentation/styling/theme-colors.ts +53 -0
- package/src/presentation/translations/component-utils.ts +54 -0
- package/src/presentation/translations/index.ts +16 -0
- package/src/presentation/translations/translation-resolver.ts +22 -0
- package/src/presentation/ui/languages/language-switcher.tsx +119 -0
- package/src/presentation/ui/metadata/analytics-builders.tsx +174 -0
- package/src/presentation/ui/metadata/analytics-head.tsx +39 -0
- package/src/presentation/ui/metadata/custom-elements-builders.tsx +157 -0
- package/src/presentation/ui/metadata/extract-component-meta.ts +108 -0
- package/src/presentation/ui/metadata/head-elements.tsx +164 -0
- package/src/presentation/ui/metadata/index.tsx +35 -0
- package/src/presentation/ui/metadata/meta-utils.tsx +42 -0
- package/src/presentation/ui/metadata/open-graph-meta.tsx +57 -0
- package/src/presentation/ui/metadata/structured-data-from-component.tsx +134 -0
- package/src/presentation/ui/metadata/structured-data.tsx +88 -0
- package/src/presentation/ui/metadata/twitter-card-meta.tsx +80 -0
- package/src/presentation/ui/pages/DefaultHomePage.tsx +43 -0
- package/src/presentation/ui/pages/DefaultPageConfigs.ts +220 -0
- package/src/presentation/ui/pages/DynamicPage.tsx +307 -0
- package/src/presentation/ui/pages/ErrorPage.tsx +25 -0
- package/src/presentation/ui/pages/NotFoundPage.tsx +25 -0
- package/src/presentation/ui/pages/PageBodyScripts.tsx +242 -0
- package/src/presentation/ui/pages/PageBodyStyles.ts +52 -0
- package/src/presentation/ui/pages/PageHead.tsx +380 -0
- package/src/presentation/ui/pages/PageLangResolver.ts +58 -0
- package/src/presentation/ui/pages/PageMain.tsx +58 -0
- package/src/presentation/ui/pages/PageMetadata.ts +168 -0
- package/src/presentation/ui/pages/PageMetadataI18n.ts +169 -0
- package/src/presentation/ui/pages/PageScripts.ts +78 -0
- package/src/presentation/ui/pages/SectionRenderer.tsx +67 -0
- package/src/presentation/ui/pages/SectionSpacing.tsx +131 -0
- package/src/presentation/ui/sections/component-renderer.tsx +426 -0
- package/src/presentation/ui/sections/component-renderer.types.ts +33 -0
- package/src/presentation/ui/sections/components/component-reference-handler.tsx +74 -0
- package/src/presentation/ui/sections/components/component-resolution.ts +65 -0
- package/src/presentation/ui/sections/components/index.ts +9 -0
- package/src/presentation/ui/sections/hero.tsx +394 -0
- package/src/presentation/ui/sections/props/component-builder.ts +183 -0
- package/src/presentation/ui/sections/props/element-props.ts +179 -0
- package/src/presentation/ui/sections/props/index.ts +9 -0
- package/src/presentation/ui/sections/props/prop-conversion.ts +171 -0
- package/src/presentation/ui/sections/props/props-builder-config.ts +42 -0
- package/src/presentation/ui/sections/props/props-builder.ts +296 -0
- package/src/presentation/ui/sections/renderers/element-renderers/html-element-renderer.tsx +124 -0
- package/src/presentation/ui/sections/renderers/element-renderers/index.ts +59 -0
- package/src/presentation/ui/sections/renderers/element-renderers/interactive-renderers.tsx +231 -0
- package/src/presentation/ui/sections/renderers/element-renderers/media-renderers.tsx +102 -0
- package/src/presentation/ui/sections/renderers/element-renderers/text-content-renderers.tsx +42 -0
- package/src/presentation/ui/sections/renderers/element-renderers.ts +53 -0
- package/src/presentation/ui/sections/renderers/html-element-helpers.ts +100 -0
- package/src/presentation/ui/sections/renderers/specialized-renderers.tsx +212 -0
- package/src/presentation/ui/sections/rendering/component-dispatch-config.ts +31 -0
- package/src/presentation/ui/sections/rendering/component-registry/index.ts +39 -0
- package/src/presentation/ui/sections/rendering/component-registry/interactive-components.ts +54 -0
- package/src/presentation/ui/sections/rendering/component-registry/media-components.ts +36 -0
- package/src/presentation/ui/sections/rendering/component-registry/special-components.tsx +153 -0
- package/src/presentation/ui/sections/rendering/component-registry/structural-components.ts +215 -0
- package/src/presentation/ui/sections/rendering/component-registry/text-components.ts +57 -0
- package/src/presentation/ui/sections/rendering/component-registry-helpers.tsx +29 -0
- package/src/presentation/ui/sections/rendering/component-registry.tsx +21 -0
- package/src/presentation/ui/sections/rendering/component-type-dispatcher.tsx +33 -0
- package/src/presentation/ui/sections/rendering/index.ts +9 -0
- package/src/presentation/ui/sections/responsive/responsive-children-builder.tsx +96 -0
- package/src/presentation/ui/sections/responsive/responsive-content-builder.tsx +95 -0
- package/src/presentation/ui/sections/responsive/responsive-props-merger.ts +195 -0
- package/src/presentation/ui/sections/responsive/responsive-resolver.ts +213 -0
- package/src/presentation/ui/sections/styling/animation-composer-wrapper.ts +65 -0
- package/src/presentation/ui/sections/styling/class-builders.ts +45 -0
- package/src/presentation/ui/sections/styling/color-resolver.ts +43 -0
- package/src/presentation/ui/sections/styling/hover-interaction-handler.ts +107 -0
- package/src/presentation/ui/sections/styling/index.ts +9 -0
- package/src/presentation/ui/sections/styling/interaction-props-builder.ts +55 -0
- package/src/presentation/ui/sections/styling/shadow-resolver.ts +83 -0
- package/src/presentation/ui/sections/styling/spacing-resolver.ts +104 -0
- package/src/presentation/ui/sections/styling/style-processor.ts +170 -0
- package/src/presentation/ui/sections/styling/theme-tokens.ts +184 -0
- package/src/presentation/ui/sections/translations/i18n-content-resolver.ts +198 -0
- package/src/presentation/ui/sections/translations/index.ts +9 -0
- package/src/presentation/ui/sections/translations/translation-handler.ts +143 -0
- package/src/presentation/ui/sections/translations/variable-substitution.ts +225 -0
- package/src/presentation/ui/sections/utils/time-parser.ts +82 -0
- package/src/presentation/utils/link-attributes.ts +50 -0
- package/src/presentation/utils/string-utils.ts +58 -0
- package/src/presentation/utils/styles.ts +50 -0
- package/tsconfig.json +46 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 ESSENTIAL SERVICES
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Business Source License 1.1
|
|
5
|
+
* found in the LICENSE.md file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { Schema } from 'effect'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Base numeric ID schema with common validation
|
|
12
|
+
*
|
|
13
|
+
* All numeric IDs share these constraints:
|
|
14
|
+
* - Must be positive integers (>= 1)
|
|
15
|
+
* - Must be within JavaScript safe integer range
|
|
16
|
+
* - Are system-generated and immutable
|
|
17
|
+
*/
|
|
18
|
+
const BaseNumericIdSchema = Schema.Int.pipe(
|
|
19
|
+
Schema.greaterThanOrEqualTo(1),
|
|
20
|
+
Schema.lessThanOrEqualTo(9_007_199_254_740_991)
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Table ID - Identifier for tables (numeric or string)
|
|
25
|
+
*
|
|
26
|
+
* Unique identifier for tables within an application.
|
|
27
|
+
* Accepts positive integers, UUID strings, or simple string identifiers.
|
|
28
|
+
* If omitted, an ID will be auto-generated during validation.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* // Numeric ID
|
|
33
|
+
* const table1 = { id: 1, name: 'users', fields: [] }
|
|
34
|
+
*
|
|
35
|
+
* // UUID string ID
|
|
36
|
+
* const table2 = { id: '550e8400-e29b-41d4-a716-446655440000', name: 'orders', fields: [] }
|
|
37
|
+
*
|
|
38
|
+
* // Simple string ID
|
|
39
|
+
* const table3 = { id: 'products', name: 'products', fields: [] }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export const TableIdSchema = Schema.Union(
|
|
43
|
+
BaseNumericIdSchema,
|
|
44
|
+
Schema.String.pipe(Schema.minLength(1))
|
|
45
|
+
).pipe(
|
|
46
|
+
Schema.annotations({
|
|
47
|
+
identifier: 'TableId',
|
|
48
|
+
title: 'Table ID',
|
|
49
|
+
description:
|
|
50
|
+
'Unique identifier for a table. Accepts positive integers, UUID strings, or simple string identifiers. Examples: 1, 2, 100, "550e8400-e29b-41d4-a716-446655440000", "products"',
|
|
51
|
+
})
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
export type TableId = Schema.Schema.Type<typeof TableIdSchema>
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Field ID - Numeric identifier for fields
|
|
58
|
+
*
|
|
59
|
+
* Unique identifier for fields within a table.
|
|
60
|
+
* Field IDs are unique within their parent table, not globally.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const field = { id: 1, name: 'email', type: 'email' }
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export const FieldIdSchema = BaseNumericIdSchema.pipe(
|
|
68
|
+
Schema.annotations({
|
|
69
|
+
identifier: 'FieldId',
|
|
70
|
+
title: 'Field ID',
|
|
71
|
+
description: 'Unique identifier for a field within a table. Examples: 1, 2, 3, 100',
|
|
72
|
+
})
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
export type FieldId = Schema.Schema.Type<typeof FieldIdSchema>
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Record ID - Numeric identifier for records
|
|
79
|
+
*
|
|
80
|
+
* Unique identifier for records within a table.
|
|
81
|
+
* Record IDs are unique within their parent table.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const record = { id: 1, data: { ... } }
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export const RecordIdSchema = BaseNumericIdSchema.pipe(
|
|
89
|
+
Schema.annotations({
|
|
90
|
+
identifier: 'RecordId',
|
|
91
|
+
title: 'Record ID',
|
|
92
|
+
description: 'Unique identifier for a record within a table. Examples: 1, 2, 3, 1000',
|
|
93
|
+
})
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
export type RecordId = Schema.Schema.Type<typeof RecordIdSchema>
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* User ID - Branded type for user identifiers
|
|
100
|
+
*
|
|
101
|
+
* Unique identifier for users in the authentication system.
|
|
102
|
+
* User IDs are globally unique across the application.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const userId: UserId = 'usr_123abc' as UserId
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
export const UserIdSchema = Schema.String.pipe(
|
|
110
|
+
Schema.minLength(1),
|
|
111
|
+
Schema.brand('UserId'),
|
|
112
|
+
Schema.annotations({
|
|
113
|
+
identifier: 'UserId',
|
|
114
|
+
title: 'User ID',
|
|
115
|
+
description:
|
|
116
|
+
'Unique identifier for a user (branded type). Examples: usr_123abc, user-456, 550e8400-e29b-41d4-a716-446655440000',
|
|
117
|
+
})
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
export type UserId = Schema.Schema.Type<typeof UserIdSchema>
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Workspace ID - Branded type for workspace identifiers
|
|
124
|
+
*
|
|
125
|
+
* Unique identifier for workspaces.
|
|
126
|
+
* Workspaces provide logical separation of data.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* const workspaceId: WorkspaceId = 'ws_marketing' as WorkspaceId
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
export const WorkspaceIdSchema = Schema.String.pipe(
|
|
134
|
+
Schema.minLength(1),
|
|
135
|
+
Schema.brand('WorkspaceId'),
|
|
136
|
+
Schema.annotations({
|
|
137
|
+
identifier: 'WorkspaceId',
|
|
138
|
+
title: 'Workspace ID',
|
|
139
|
+
description:
|
|
140
|
+
'Unique identifier for a workspace (branded type). Examples: ws_marketing, workspace-dev, default',
|
|
141
|
+
})
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
export type WorkspaceId = Schema.Schema.Type<typeof WorkspaceIdSchema>
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Component Template ID - Branded type for component template identifiers
|
|
148
|
+
*
|
|
149
|
+
* Unique identifier for reusable component templates.
|
|
150
|
+
* Component templates are referenced in page sections via $ref.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* const componentId: ComponentTemplateId = 'hero-section' as ComponentTemplateId
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
export const ComponentTemplateIdSchema = Schema.String.pipe(
|
|
158
|
+
Schema.minLength(1),
|
|
159
|
+
Schema.pattern(/^[a-z][a-z0-9-]*$/, {
|
|
160
|
+
message: () =>
|
|
161
|
+
'Component template ID must start with a letter and contain only lowercase letters, numbers, and hyphens',
|
|
162
|
+
}),
|
|
163
|
+
Schema.brand('ComponentTemplateId'),
|
|
164
|
+
Schema.annotations({
|
|
165
|
+
identifier: 'ComponentTemplateId',
|
|
166
|
+
title: 'Component Template ID',
|
|
167
|
+
description:
|
|
168
|
+
'Unique identifier for a reusable component template (branded type). Examples: hero-section, feature-grid, cta-banner',
|
|
169
|
+
})
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
export type ComponentTemplateId = Schema.Schema.Type<typeof ComponentTemplateIdSchema>
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* View ID - Branded type for view identifiers
|
|
176
|
+
*
|
|
177
|
+
* Unique identifier for table views.
|
|
178
|
+
* Views define filtered/sorted/grouped perspectives on table data.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* const viewId: ViewId = 'active_tasks' as ViewId
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
export const BrandedViewIdSchema = Schema.String.pipe(
|
|
186
|
+
Schema.minLength(1),
|
|
187
|
+
Schema.pattern(/^[a-z][a-z0-9_]*$/, {
|
|
188
|
+
message: () =>
|
|
189
|
+
'View ID must start with a letter and contain only lowercase letters, numbers, and underscores',
|
|
190
|
+
}),
|
|
191
|
+
Schema.brand('ViewId'),
|
|
192
|
+
Schema.annotations({
|
|
193
|
+
identifier: 'ViewId',
|
|
194
|
+
title: 'View ID',
|
|
195
|
+
description:
|
|
196
|
+
'Unique identifier for a table view (branded type). Examples: active_tasks, by_department, recent_first',
|
|
197
|
+
})
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
export type BrandedViewId = Schema.Schema.Type<typeof BrandedViewIdSchema>
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 ESSENTIAL SERVICES
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Business Source License 1.1
|
|
5
|
+
* found in the LICENSE.md file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { Schema } from 'effect'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Unique positive integer identifier for entities
|
|
12
|
+
*
|
|
13
|
+
* IDs are system-generated, auto-incrementing, and immutable.
|
|
14
|
+
* Must be unique within the parent collection (e.g., field IDs unique within a table).
|
|
15
|
+
* IDs are read-only and assigned automatically when entities are created.
|
|
16
|
+
*
|
|
17
|
+
* Range: 1 to 9,007,199,254,740,991 (JavaScript MAX_SAFE_INTEGER)
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const id = 1
|
|
22
|
+
* const tableId = 100
|
|
23
|
+
* const fieldId = 1000
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @see specs/app/common/definitions.schema.json#/definitions/id
|
|
27
|
+
*/
|
|
28
|
+
export const IdSchema = Schema.Int.pipe(
|
|
29
|
+
Schema.greaterThanOrEqualTo(1),
|
|
30
|
+
Schema.lessThanOrEqualTo(9_007_199_254_740_991),
|
|
31
|
+
Schema.annotations({
|
|
32
|
+
title: 'ID',
|
|
33
|
+
description: 'Unique positive integer identifier for entities',
|
|
34
|
+
examples: [1, 2, 3, 100, 1000],
|
|
35
|
+
readOnly: true,
|
|
36
|
+
})
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Internal identifier name used for database tables, columns, and programmatic references
|
|
41
|
+
*
|
|
42
|
+
* Must follow database naming conventions:
|
|
43
|
+
* - Start with a letter
|
|
44
|
+
* - Contain only lowercase letters, numbers, and underscores
|
|
45
|
+
* - Maximum 63 characters (PostgreSQL limit)
|
|
46
|
+
*
|
|
47
|
+
* Used in SQL queries, API endpoints, and code generation.
|
|
48
|
+
* Choose descriptive names that clearly indicate the purpose.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const name1 = 'user'
|
|
53
|
+
* const name2 = 'email_address'
|
|
54
|
+
* const name3 = 'created_at'
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @see specs/app/common/definitions.schema.json#/definitions/name
|
|
58
|
+
*/
|
|
59
|
+
export const NameSchema = Schema.String.pipe(
|
|
60
|
+
Schema.minLength(1),
|
|
61
|
+
Schema.maxLength(63),
|
|
62
|
+
Schema.pattern(/^[a-z][a-z0-9_]*$/, {
|
|
63
|
+
message: () =>
|
|
64
|
+
'Name must start with a lowercase letter and contain only lowercase letters, numbers, and underscores (snake_case)',
|
|
65
|
+
}),
|
|
66
|
+
Schema.annotations({
|
|
67
|
+
title: 'Name',
|
|
68
|
+
description:
|
|
69
|
+
'Internal identifier name for database tables, columns, and programmatic references',
|
|
70
|
+
examples: ['user', 'product', 'order_item', 'customer_email', 'shipping_address', 'created_at'],
|
|
71
|
+
})
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* URL path for routing and navigation
|
|
76
|
+
*
|
|
77
|
+
* Must:
|
|
78
|
+
* - Start with forward slash (/)
|
|
79
|
+
* - Contain only lowercase letters, numbers, hyphens, colons, and forward slashes
|
|
80
|
+
* - Be descriptive and hierarchical
|
|
81
|
+
* - Support dynamic route parameters with colon prefix (e.g., :id, :slug)
|
|
82
|
+
*
|
|
83
|
+
* Used for page routing, API endpoints, and navigation links.
|
|
84
|
+
* Nested paths and dynamic parameters are supported for flexible routing.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const root = '/'
|
|
89
|
+
* const simple = '/about'
|
|
90
|
+
* const nested = '/products/inventory'
|
|
91
|
+
* const kebabCase = '/our-team'
|
|
92
|
+
* const dynamic = '/blog/:slug'
|
|
93
|
+
* const multiParam = '/users/:userId/posts/:postId'
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* @see specs/app/common/definitions.schema.json#/definitions/path
|
|
97
|
+
*/
|
|
98
|
+
export const PathSchema = Schema.String.pipe(
|
|
99
|
+
Schema.minLength(1),
|
|
100
|
+
Schema.pattern(/^\/[a-z0-9-_/:]*$/, {
|
|
101
|
+
message: () =>
|
|
102
|
+
'Path must start with / and contain only lowercase letters, numbers, hyphens, underscores, colons, and forward slashes',
|
|
103
|
+
}),
|
|
104
|
+
Schema.annotations({
|
|
105
|
+
title: 'Path',
|
|
106
|
+
description: 'URL path for routing and navigation (supports dynamic parameters with :param)',
|
|
107
|
+
examples: [
|
|
108
|
+
'/home',
|
|
109
|
+
'/customers',
|
|
110
|
+
'/products/inventory',
|
|
111
|
+
'/admin/settings',
|
|
112
|
+
'/reports/sales',
|
|
113
|
+
'/blog/:slug',
|
|
114
|
+
'/products/:id',
|
|
115
|
+
'/users/:userId/posts/:postId',
|
|
116
|
+
],
|
|
117
|
+
})
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Relative file path for local assets
|
|
122
|
+
*
|
|
123
|
+
* Must:
|
|
124
|
+
* - Start with ./ or ../
|
|
125
|
+
* - Be relative to current file or parent directory
|
|
126
|
+
*
|
|
127
|
+
* Used for referencing local assets like images, fonts, and stylesheets.
|
|
128
|
+
* Relative paths are resolved at build time and work across different environments.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* const logo = './public/logo.svg'
|
|
133
|
+
* const image = '../images/hero.jpg'
|
|
134
|
+
* const icon = './assets/icon.png'
|
|
135
|
+
* ```
|
|
136
|
+
*
|
|
137
|
+
* @see specs/app/pages/common/definitions.schema.json#/definitions/relativePath
|
|
138
|
+
*/
|
|
139
|
+
export const RelativePathSchema = Schema.String.pipe(
|
|
140
|
+
Schema.pattern(/^\.{1,2}\//, {
|
|
141
|
+
message: () => 'Relative path must start with ./ or ../',
|
|
142
|
+
}),
|
|
143
|
+
Schema.annotations({
|
|
144
|
+
title: 'Relative Path',
|
|
145
|
+
description: 'Relative file path for local assets',
|
|
146
|
+
examples: ['./public/logo.svg', '../images/hero.jpg', './assets/icon.png'],
|
|
147
|
+
})
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Hex color code (6-digit format)
|
|
152
|
+
*
|
|
153
|
+
* Validates hex color format: #RRGGBB
|
|
154
|
+
* - Starts with #
|
|
155
|
+
* - Followed by exactly 6 hex digits (0-9, A-F, case-insensitive)
|
|
156
|
+
*
|
|
157
|
+
* Used for:
|
|
158
|
+
* - Banner background/text colors
|
|
159
|
+
* - Safari mask-icon color attribute
|
|
160
|
+
* - Theme color customization
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* const primary = '#007BFF'
|
|
165
|
+
* const success = '#28A745'
|
|
166
|
+
* const danger = '#DC3545'
|
|
167
|
+
* const safariMask = '#5BBAD5'
|
|
168
|
+
* ```
|
|
169
|
+
*
|
|
170
|
+
* @see specs/app/common/definitions.schema.json#/definitions/hexColor
|
|
171
|
+
*/
|
|
172
|
+
export const HexColorSchema = Schema.String.pipe(
|
|
173
|
+
Schema.pattern(/^#[0-9A-Fa-f]{6}$/, {
|
|
174
|
+
message: () => 'Color must be a 6-digit hex code (e.g., #007BFF, #5BBAD5)',
|
|
175
|
+
}),
|
|
176
|
+
Schema.annotations({
|
|
177
|
+
title: 'Hex Color',
|
|
178
|
+
description: 'Hex color code in #RRGGBB format',
|
|
179
|
+
examples: ['#007BFF', '#28A745', '#DC3545', '#5BBAD5'],
|
|
180
|
+
})
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
export type Id = Schema.Schema.Type<typeof IdSchema>
|
|
184
|
+
export type Name = Schema.Schema.Type<typeof NameSchema>
|
|
185
|
+
export type Path = Schema.Schema.Type<typeof PathSchema>
|
|
186
|
+
export type RelativePath = Schema.Schema.Type<typeof RelativePathSchema>
|
|
187
|
+
export type HexColor = Schema.Schema.Type<typeof HexColorSchema>
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 ESSENTIAL SERVICES
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Business Source License 1.1
|
|
5
|
+
* found in the LICENSE.md file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { Schema } from 'effect'
|
|
9
|
+
import { ComponentPropsSchema } from './component-props'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Component Child Element (component in a component template)
|
|
13
|
+
*
|
|
14
|
+
* Represents a single component element with:
|
|
15
|
+
* - type: Component type (required)
|
|
16
|
+
* - props: Component properties (optional)
|
|
17
|
+
* - children: Nested child elements (optional, recursive)
|
|
18
|
+
* - content: Text content with $variable support (optional)
|
|
19
|
+
*
|
|
20
|
+
* Note: This schema is recursive - children can contain more ComponentChildElement objects.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const iconChild = {
|
|
25
|
+
* type: 'icon',
|
|
26
|
+
* props: {
|
|
27
|
+
* name: '$icon',
|
|
28
|
+
* color: '$color',
|
|
29
|
+
* },
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* const textChild = {
|
|
33
|
+
* type: 'text',
|
|
34
|
+
* content: '$label',
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* const containerChild = {
|
|
38
|
+
* type: 'div',
|
|
39
|
+
* props: { className: 'flex gap-2' },
|
|
40
|
+
* children: [iconChild, textChild],
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @see specs/app/components/common/component-children.schema.json#/items
|
|
45
|
+
*/
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Recursive schema with suspended children requires any for circular reference resolution
|
|
47
|
+
export const ComponentChildElementSchema: Schema.Schema<any, any, never> = Schema.Struct({
|
|
48
|
+
type: Schema.String.pipe(
|
|
49
|
+
Schema.annotations({
|
|
50
|
+
title: 'Component Type',
|
|
51
|
+
description: 'Component type identifier',
|
|
52
|
+
examples: ['icon', 'text', 'div', 'button'],
|
|
53
|
+
})
|
|
54
|
+
),
|
|
55
|
+
props: Schema.optional(ComponentPropsSchema),
|
|
56
|
+
children: Schema.optional(
|
|
57
|
+
Schema.suspend(() => ComponentChildrenSchema).pipe(
|
|
58
|
+
Schema.annotations({
|
|
59
|
+
identifier: 'ComponentChildren',
|
|
60
|
+
})
|
|
61
|
+
)
|
|
62
|
+
),
|
|
63
|
+
content: Schema.optional(
|
|
64
|
+
Schema.String.pipe(
|
|
65
|
+
Schema.annotations({
|
|
66
|
+
title: 'Text Content',
|
|
67
|
+
description: 'Text content (may contain $variable)',
|
|
68
|
+
examples: ['$label', '$title', 'Static text'],
|
|
69
|
+
})
|
|
70
|
+
)
|
|
71
|
+
),
|
|
72
|
+
}).pipe(
|
|
73
|
+
Schema.annotations({
|
|
74
|
+
title: 'Component Child Element',
|
|
75
|
+
description: 'Component element in a component template',
|
|
76
|
+
})
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Component Children (child elements array for component templates)
|
|
81
|
+
*
|
|
82
|
+
* Array of component elements or strings that can be nested recursively.
|
|
83
|
+
* Each child can be:
|
|
84
|
+
* - ComponentChildElement: Component with type, optional props, optional nested children, and optional content
|
|
85
|
+
* - String: Direct text content or variable placeholder (e.g., '$title', 'Static text')
|
|
86
|
+
*
|
|
87
|
+
* This enables building complex component hierarchies with variable substitution.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* const children = [
|
|
92
|
+
* {
|
|
93
|
+
* type: 'icon',
|
|
94
|
+
* props: {
|
|
95
|
+
* name: '$icon',
|
|
96
|
+
* color: '$color',
|
|
97
|
+
* },
|
|
98
|
+
* },
|
|
99
|
+
* {
|
|
100
|
+
* type: 'text',
|
|
101
|
+
* content: '$label',
|
|
102
|
+
* },
|
|
103
|
+
* '$title', // Direct string (can be variable or static text)
|
|
104
|
+
* ]
|
|
105
|
+
* ```
|
|
106
|
+
*
|
|
107
|
+
* @see specs/app/components/common/component-children.schema.json
|
|
108
|
+
*/
|
|
109
|
+
export const ComponentChildrenSchema = Schema.Array(
|
|
110
|
+
Schema.Union(ComponentChildElementSchema, Schema.String)
|
|
111
|
+
).pipe(
|
|
112
|
+
Schema.annotations({
|
|
113
|
+
title: 'Component Children',
|
|
114
|
+
description: 'Child elements array for component templates (components or strings)',
|
|
115
|
+
})
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
export type ComponentChildElement = Schema.Schema.Type<typeof ComponentChildElementSchema>
|
|
119
|
+
export type ComponentChildren = Schema.Schema.Type<typeof ComponentChildrenSchema>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 ESSENTIAL SERVICES
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Business Source License 1.1
|
|
5
|
+
* found in the LICENSE.md file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { Schema } from 'effect'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Component property value (string, number, boolean, object, or array)
|
|
12
|
+
*
|
|
13
|
+
* Flexible property values supporting:
|
|
14
|
+
* - String: May contain $variable references for template substitution
|
|
15
|
+
* - Number: Numeric values
|
|
16
|
+
* - Boolean: True/false flags
|
|
17
|
+
* - Object: Nested property objects
|
|
18
|
+
* - Array: Lists of values
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const stringProp = 'text-$color bg-$bgColor'
|
|
23
|
+
* const numberProp = 100
|
|
24
|
+
* const booleanProp = true
|
|
25
|
+
* const objectProp = { nested: 'value' }
|
|
26
|
+
* const arrayProp = [1, 2, 3]
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @see specs/app/components/common/component-props.schema.json#/patternProperties/.../oneOf
|
|
30
|
+
*/
|
|
31
|
+
export const ComponentPropValueSchema: Schema.Schema<
|
|
32
|
+
string | number | boolean | Record<string, unknown> | readonly unknown[]
|
|
33
|
+
> = Schema.Union(
|
|
34
|
+
Schema.String,
|
|
35
|
+
Schema.Number,
|
|
36
|
+
Schema.Boolean,
|
|
37
|
+
Schema.Record({ key: Schema.String, value: Schema.Unknown }),
|
|
38
|
+
Schema.Array(Schema.Unknown)
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Component Props (properties for component templates with variable references)
|
|
43
|
+
*
|
|
44
|
+
* Dynamic object supporting:
|
|
45
|
+
* - JavaScript property names (camelCase): className, maxWidth, isEnabled
|
|
46
|
+
* - HTML data-* attributes (kebab-case): data-testid, data-user-id
|
|
47
|
+
* - HTML aria-* attributes (kebab-case): aria-label, aria-describedby
|
|
48
|
+
*
|
|
49
|
+
* Properties can be strings (with $variable), numbers, booleans, objects, or arrays.
|
|
50
|
+
* Used for template customization and variable substitution.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const props = {
|
|
55
|
+
* className: 'text-$color bg-$bgColor',
|
|
56
|
+
* size: '$size',
|
|
57
|
+
* enabled: true,
|
|
58
|
+
* maxWidth: 'max-w-$width',
|
|
59
|
+
* count: 10,
|
|
60
|
+
* 'data-testid': 'my-component',
|
|
61
|
+
* 'aria-label': 'Interactive button',
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @see specs/app/components/common/component-props.schema.json
|
|
66
|
+
*/
|
|
67
|
+
export const ComponentPropsSchema = Schema.Record({
|
|
68
|
+
key: Schema.String.pipe(
|
|
69
|
+
Schema.pattern(/^([a-zA-Z][a-zA-Z0-9]*|data-[a-z]+(-[a-z]+)*|aria-[a-z]+(-[a-z]+)*)$/, {
|
|
70
|
+
message: () =>
|
|
71
|
+
'Property key must be camelCase (e.g., className, maxWidth) or kebab-case with data-/aria- prefix (e.g., data-testid, aria-label)',
|
|
72
|
+
}),
|
|
73
|
+
Schema.annotations({
|
|
74
|
+
title: 'Component Prop Key',
|
|
75
|
+
description:
|
|
76
|
+
'Valid JavaScript property name (camelCase) or HTML data-*/aria-* attribute (kebab-case)',
|
|
77
|
+
examples: ['className', 'size', 'enabled', 'maxWidth', 'data-testid', 'aria-label'],
|
|
78
|
+
})
|
|
79
|
+
),
|
|
80
|
+
value: ComponentPropValueSchema,
|
|
81
|
+
}).pipe(
|
|
82
|
+
Schema.annotations({
|
|
83
|
+
title: 'Component Props',
|
|
84
|
+
description: 'Properties for component templates, supporting variable references',
|
|
85
|
+
})
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
export type ComponentPropValue = Schema.Schema.Type<typeof ComponentPropValueSchema>
|
|
89
|
+
export type ComponentProps = Schema.Schema.Type<typeof ComponentPropsSchema>
|