@turbofy-ai/app-runtime 0.0.4 → 0.0.5
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/dist/src/dsl.d.ts +64 -1
- package/dist/src/dsl.js +100 -3
- package/dist/src/generated/auth-config.d.ts +5 -0
- package/dist/src/lib/auth.d.ts +21 -0
- package/package.json +1 -1
package/dist/src/dsl.d.ts
CHANGED
|
@@ -87,11 +87,15 @@ declare enum PipelineStepEnum {
|
|
|
87
87
|
}
|
|
88
88
|
declare enum RuntimeEnum {
|
|
89
89
|
NODEJS_22_X = "NODEJS_22_X",
|
|
90
|
+
NODEJS_24_X = "NODEJS_24_X",
|
|
90
91
|
NODEJS_18_X = "NODEJS_18_X",
|
|
92
|
+
PYTHON_3_12 = "PYTHON_3_12",
|
|
93
|
+
PYTHON_3_11 = "PYTHON_3_11",
|
|
91
94
|
PYTHON_3_10 = "PYTHON_3_10",
|
|
92
95
|
GO_1_X = "GO_1_X",
|
|
93
|
-
|
|
96
|
+
RUBY_3_3 = "RUBY_3_3",
|
|
94
97
|
RUBY_3_2 = "RUBY_3_2",
|
|
98
|
+
RUBY_2_7 = "RUBY_2_7",
|
|
95
99
|
DOCKER = "DOCKER"
|
|
96
100
|
}
|
|
97
101
|
declare const objectTypeDeclarationSchema: z.ZodObject<{
|
|
@@ -750,6 +754,33 @@ export type LocalizationDictionary = Record<string, LocalizationValue>;
|
|
|
750
754
|
* CMS Localization record by the workspace push pipeline.
|
|
751
755
|
*/
|
|
752
756
|
export type ILocalizationsByLocale = Record<string, LocalizationDictionary>;
|
|
757
|
+
/**
|
|
758
|
+
* SEO metadata for a page, stored under the reserved `meta` key of the page's
|
|
759
|
+
* localization dictionary (`{lang}_page_{pageId}`) and rendered as `<meta>`
|
|
760
|
+
* tags by the publishing stack. String values may contain `{{key}}`
|
|
761
|
+
* placeholders that resolve against the page dictionary at render time. On
|
|
762
|
+
* dynamic pages, `{{paramName.fieldPath}}` placeholders resolve against the
|
|
763
|
+
* param's entity record (e.g. `"Turbofy - {{showcase.title}}"`).
|
|
764
|
+
*/
|
|
765
|
+
export interface IPageMetaDictionary {
|
|
766
|
+
title?: string;
|
|
767
|
+
description?: string;
|
|
768
|
+
keywords?: string;
|
|
769
|
+
robots?: string;
|
|
770
|
+
"og:title"?: string;
|
|
771
|
+
"og:description"?: string;
|
|
772
|
+
"og:image"?: string;
|
|
773
|
+
"og:type"?: string;
|
|
774
|
+
"og:url"?: string;
|
|
775
|
+
"twitter:card"?: string;
|
|
776
|
+
"twitter:site"?: string;
|
|
777
|
+
"twitter:creator"?: string;
|
|
778
|
+
"twitter:title"?: string;
|
|
779
|
+
"twitter:description"?: string;
|
|
780
|
+
"twitter:image"?: string;
|
|
781
|
+
"twitter:url"?: string;
|
|
782
|
+
[key: string]: LocalizationValue | undefined;
|
|
783
|
+
}
|
|
753
784
|
export type II18nSettings = {
|
|
754
785
|
locales: string[];
|
|
755
786
|
default: string;
|
|
@@ -759,6 +790,26 @@ export type IAppSlugConfig = {
|
|
|
759
790
|
pattern: string;
|
|
760
791
|
};
|
|
761
792
|
};
|
|
793
|
+
export declare const PAGE_VISIBILITY: readonly [
|
|
794
|
+
"public",
|
|
795
|
+
"authenticated",
|
|
796
|
+
"group",
|
|
797
|
+
"user"
|
|
798
|
+
];
|
|
799
|
+
export type PageVisibility = (typeof PAGE_VISIBILITY)[number];
|
|
800
|
+
export type IAppAuthSignupField = {
|
|
801
|
+
name: string;
|
|
802
|
+
label?: string;
|
|
803
|
+
type?: "text" | "number" | "email";
|
|
804
|
+
required?: boolean;
|
|
805
|
+
};
|
|
806
|
+
export type IAppAuthSettings = {
|
|
807
|
+
enabled?: boolean;
|
|
808
|
+
allowSignup?: boolean;
|
|
809
|
+
signupFields?: IAppAuthSignupField[];
|
|
810
|
+
redirectPageId?: string;
|
|
811
|
+
loginPageId?: string;
|
|
812
|
+
};
|
|
762
813
|
export type SemVer = `${number}.${number}.${number}`;
|
|
763
814
|
export interface IDependencyInfo {
|
|
764
815
|
version: SemVer;
|
|
@@ -877,8 +928,16 @@ export interface IPageOptions {
|
|
|
877
928
|
param?: IPageParamConfig;
|
|
878
929
|
/** Default English localization dictionary for this page. */
|
|
879
930
|
defaultLocalization?: LocalizationDictionary;
|
|
931
|
+
/** SEO metadata (title, description, og:* and twitter:* tags) rendered as `<meta>` tags */
|
|
932
|
+
meta?: IPageMetaDictionary;
|
|
880
933
|
/** Localized config (e.g. canonicalPath, notFound). Preserved through pull/push. */
|
|
881
934
|
localizedConfig?: string;
|
|
935
|
+
/**
|
|
936
|
+
* Access level for the published page. Absent ⇒ "public".
|
|
937
|
+
* Anything other than "public" requires a valid end-user session; the
|
|
938
|
+
* user/group distinction is enforced at the data layer via PBAC.
|
|
939
|
+
*/
|
|
940
|
+
visibility?: PageVisibility;
|
|
882
941
|
/** Building block instances on this page. */
|
|
883
942
|
blocks?: IBlockDefinition[];
|
|
884
943
|
}
|
|
@@ -890,6 +949,7 @@ export interface IPageDefinition {
|
|
|
890
949
|
params: Record<string, IPageParamConfig>;
|
|
891
950
|
defaultLocalization?: LocalizationDictionary;
|
|
892
951
|
localizedConfig?: string;
|
|
952
|
+
visibility?: PageVisibility;
|
|
893
953
|
blocks: IBlockDefinition[];
|
|
894
954
|
}
|
|
895
955
|
export interface IPageSlugConfig {
|
|
@@ -930,6 +990,8 @@ export interface IAppOptions {
|
|
|
930
990
|
slugConfig?: IAppSlugConfig;
|
|
931
991
|
/** Internationalization settings persisted to `app.settings.i18n`. */
|
|
932
992
|
i18n?: II18nSettings;
|
|
993
|
+
/** End-user authentication settings persisted to `app.settings.auth`. */
|
|
994
|
+
auth?: IAppAuthSettings;
|
|
933
995
|
/** @deprecated Use `i18n.locales` instead. */
|
|
934
996
|
locale?: string;
|
|
935
997
|
/** @deprecated Use `i18n.locales` instead. */
|
|
@@ -941,6 +1003,7 @@ export interface IAppOutput {
|
|
|
941
1003
|
blockTypes: IBlockTypeOutput[];
|
|
942
1004
|
slugConfig?: IAppSlugConfig;
|
|
943
1005
|
i18n?: II18nSettings;
|
|
1006
|
+
auth?: IAppAuthSettings;
|
|
944
1007
|
}
|
|
945
1008
|
declare function buildApp(opts: IAppOptions): IAppOutput;
|
|
946
1009
|
|
package/dist/src/dsl.js
CHANGED
|
@@ -429,6 +429,7 @@ function pageLocalizedConfigCode() {
|
|
|
429
429
|
const paramsCollectionMap = slugConfig?.paramsCollectionMap ?? {};
|
|
430
430
|
let notFound = false;
|
|
431
431
|
const params = {};
|
|
432
|
+
const resolvedParamEntities = [];
|
|
432
433
|
|
|
433
434
|
const resolveIdFromSlug = (ofType, slug) => {
|
|
434
435
|
const t = ofType.toLowerCase();
|
|
@@ -477,6 +478,7 @@ function pageLocalizedConfigCode() {
|
|
|
477
478
|
const activeSlugForEntity = resolveSlugFromId(ofType, entityId);
|
|
478
479
|
canonicalPathArray[paramIndex + 1] = activeSlugForEntity ?? paramValue;
|
|
479
480
|
params[param] = entityId;
|
|
481
|
+
resolvedParamEntities.push({ index: paramIndex, id: entityId, param, record });
|
|
480
482
|
} else {
|
|
481
483
|
const id = paramValue.split('_')[0];
|
|
482
484
|
const record = $$std.getRecord(ofType, id, { dynamicArgs: $$args });
|
|
@@ -494,13 +496,81 @@ function pageLocalizedConfigCode() {
|
|
|
494
496
|
canonicalPathArray[paramIndex + 1] = paramValue;
|
|
495
497
|
}
|
|
496
498
|
params[param] = id;
|
|
499
|
+
resolvedParamEntities.push({ index: paramIndex, id, param, record });
|
|
497
500
|
}
|
|
498
501
|
}
|
|
499
502
|
|
|
503
|
+
const fetchLocalizationDictionary = (locale, suffix) => {
|
|
504
|
+
const record = $$std.getRecord('cmslocalization', locale + '_page_' + $$self.id + suffix);
|
|
505
|
+
if (!record || typeof record !== 'object') return null;
|
|
506
|
+
const dictionary = $$std.get(record, 'dictionary');
|
|
507
|
+
return dictionary && typeof dictionary === 'object' ? dictionary : null;
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
const buildMeta = () => {
|
|
511
|
+
const entitySuffixes = resolvedParamEntities
|
|
512
|
+
.sort((a, b) => a.index - b.index)
|
|
513
|
+
.map((entity) => '#' + entity.id);
|
|
514
|
+
const suffixes = [''].concat(entitySuffixes);
|
|
515
|
+
|
|
516
|
+
const layers = [];
|
|
517
|
+
for (const suffix of suffixes) {
|
|
518
|
+
if (lang !== 'en') {
|
|
519
|
+
const fallbackLayer = fetchLocalizationDictionary('en', suffix);
|
|
520
|
+
if (fallbackLayer) layers.push(fallbackLayer);
|
|
521
|
+
}
|
|
522
|
+
const activeLayer = fetchLocalizationDictionary(lang, suffix);
|
|
523
|
+
if (activeLayer) layers.push(activeLayer);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
const dictionary = {};
|
|
527
|
+
const rawMeta = {};
|
|
528
|
+
let hasMeta = false;
|
|
529
|
+
for (const layer of layers) {
|
|
530
|
+
Object.assign(dictionary, layer);
|
|
531
|
+
if (layer.meta && typeof layer.meta === 'object') {
|
|
532
|
+
Object.assign(rawMeta, layer.meta);
|
|
533
|
+
hasMeta = true;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
if (!hasMeta) return null;
|
|
537
|
+
|
|
538
|
+
const paramRecords = {};
|
|
539
|
+
for (const entity of resolvedParamEntities) {
|
|
540
|
+
if (entity.record) paramRecords[entity.param] = entity.record;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
const resolvePlaceholders = (value, visited) => {
|
|
544
|
+
if (typeof value !== 'string') return value;
|
|
545
|
+
return value.replace(/\\{\\{\\s*([^{}]+?)\\s*\\}\\}/g, (match, key) => {
|
|
546
|
+
if (visited[key]) return '';
|
|
547
|
+
let raw = dictionary[key] !== undefined && key !== 'meta' ? dictionary[key] : rawMeta[key];
|
|
548
|
+
if (raw === undefined) {
|
|
549
|
+
const dotIndex = key.indexOf('.');
|
|
550
|
+
const paramRecord = dotIndex > 0 ? paramRecords[key.slice(0, dotIndex)] : undefined;
|
|
551
|
+
if (paramRecord) raw = $$std.get(paramRecord, key.slice(dotIndex + 1));
|
|
552
|
+
}
|
|
553
|
+
const resolved = resolvePlaceholders(raw, { ...visited, [key]: true });
|
|
554
|
+
return resolved == null || typeof resolved === 'object' ? '' : String(resolved);
|
|
555
|
+
});
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
const meta = {};
|
|
559
|
+
for (const key in rawMeta) {
|
|
560
|
+
const value = resolvePlaceholders(rawMeta[key], {});
|
|
561
|
+
if (value == null || value === '') continue;
|
|
562
|
+
meta[key] = value;
|
|
563
|
+
}
|
|
564
|
+
return Object.keys(meta).length > 0 ? meta : null;
|
|
565
|
+
};
|
|
566
|
+
|
|
567
|
+
const meta = buildMeta();
|
|
568
|
+
|
|
500
569
|
return {
|
|
501
570
|
canonicalPath: '/' + canonicalPathArray.join('/'),
|
|
502
571
|
params,
|
|
503
572
|
notFound,
|
|
573
|
+
...(meta ? { meta } : {}),
|
|
504
574
|
};
|
|
505
575
|
})()`.trim();
|
|
506
576
|
}
|
|
@@ -15160,11 +15230,15 @@ var PipelineStepEnum = /* @__PURE__ */ ((PipelineStepEnum2) => {
|
|
|
15160
15230
|
})(PipelineStepEnum || {});
|
|
15161
15231
|
var RuntimeEnum = /* @__PURE__ */ ((RuntimeEnum2) => {
|
|
15162
15232
|
RuntimeEnum2["NODEJS_22_X"] = "NODEJS_22_X";
|
|
15233
|
+
RuntimeEnum2["NODEJS_24_X"] = "NODEJS_24_X";
|
|
15163
15234
|
RuntimeEnum2["NODEJS_18_X"] = "NODEJS_18_X";
|
|
15235
|
+
RuntimeEnum2["PYTHON_3_12"] = "PYTHON_3_12";
|
|
15236
|
+
RuntimeEnum2["PYTHON_3_11"] = "PYTHON_3_11";
|
|
15164
15237
|
RuntimeEnum2["PYTHON_3_10"] = "PYTHON_3_10";
|
|
15165
15238
|
RuntimeEnum2["GO_1_X"] = "GO_1_X";
|
|
15166
|
-
RuntimeEnum2["
|
|
15239
|
+
RuntimeEnum2["RUBY_3_3"] = "RUBY_3_3";
|
|
15167
15240
|
RuntimeEnum2["RUBY_3_2"] = "RUBY_3_2";
|
|
15241
|
+
RuntimeEnum2["RUBY_2_7"] = "RUBY_2_7";
|
|
15168
15242
|
RuntimeEnum2["DOCKER"] = "DOCKER";
|
|
15169
15243
|
return RuntimeEnum2;
|
|
15170
15244
|
})(RuntimeEnum || {});
|
|
@@ -21520,6 +21594,11 @@ function flattenBlocks(blocks, opts) {
|
|
|
21520
21594
|
}
|
|
21521
21595
|
|
|
21522
21596
|
// ../dsl-builders/src/apps/pages.ts
|
|
21597
|
+
function setPageVisibility(slugConfig, visibility) {
|
|
21598
|
+
if (visibility && visibility !== "public") {
|
|
21599
|
+
slugConfig.visibility = visibility;
|
|
21600
|
+
}
|
|
21601
|
+
}
|
|
21523
21602
|
var STATIC_SEGMENT_RE = /^[a-z0-9-]+$/;
|
|
21524
21603
|
var PARAM_SEGMENT_RE = /^\[([a-zA-Z][a-zA-Z0-9_]*)\]$/;
|
|
21525
21604
|
function isParamSegment(slug) {
|
|
@@ -21548,11 +21627,27 @@ function page(opts) {
|
|
|
21548
21627
|
slug: opts.slug,
|
|
21549
21628
|
parent: opts.parent,
|
|
21550
21629
|
params,
|
|
21551
|
-
defaultLocalization:
|
|
21630
|
+
defaultLocalization: mergeMetaIntoLocalization(
|
|
21631
|
+
opts.defaultLocalization,
|
|
21632
|
+
opts.meta
|
|
21633
|
+
),
|
|
21552
21634
|
localizedConfig: opts.localizedConfig,
|
|
21635
|
+
...opts.visibility ? { visibility: opts.visibility } : {},
|
|
21553
21636
|
blocks: opts.blocks ?? []
|
|
21554
21637
|
};
|
|
21555
21638
|
}
|
|
21639
|
+
function mergeMetaIntoLocalization(defaultLocalization, meta3) {
|
|
21640
|
+
if (!meta3) return defaultLocalization;
|
|
21641
|
+
const mergedMeta = {};
|
|
21642
|
+
const existingMeta = defaultLocalization?.meta;
|
|
21643
|
+
if (existingMeta && typeof existingMeta === "object" && !Array.isArray(existingMeta)) {
|
|
21644
|
+
Object.assign(mergedMeta, existingMeta);
|
|
21645
|
+
}
|
|
21646
|
+
for (const [key, value] of Object.entries(meta3)) {
|
|
21647
|
+
if (value !== void 0) mergedMeta[key] = value;
|
|
21648
|
+
}
|
|
21649
|
+
return { ...defaultLocalization, meta: mergedMeta };
|
|
21650
|
+
}
|
|
21556
21651
|
var SLUG_FIELD_VALID_TYPES = /* @__PURE__ */ new Set([
|
|
21557
21652
|
"String" /* String */,
|
|
21558
21653
|
"Email" /* Email */,
|
|
@@ -21713,6 +21808,7 @@ function buildPages(pages, opts) {
|
|
|
21713
21808
|
}
|
|
21714
21809
|
}
|
|
21715
21810
|
const slugConfig = { paramsCollectionMap };
|
|
21811
|
+
setPageVisibility(slugConfig, p.visibility);
|
|
21716
21812
|
for (const loc of locales) {
|
|
21717
21813
|
slugConfig[loc] = { slug: computeFullPath(p, loc) };
|
|
21718
21814
|
}
|
|
@@ -21769,7 +21865,8 @@ function buildApp(opts) {
|
|
|
21769
21865
|
pages,
|
|
21770
21866
|
blockTypes,
|
|
21771
21867
|
slugConfig: opts.slugConfig,
|
|
21772
|
-
...i18n ? { i18n } : {}
|
|
21868
|
+
...i18n ? { i18n } : {},
|
|
21869
|
+
...opts.auth ? { auth: opts.auth } : {}
|
|
21773
21870
|
};
|
|
21774
21871
|
}
|
|
21775
21872
|
function resolveI18n(opts) {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const AUTH_ENABLED = false;
|
|
2
|
+
export declare const DEFAULT_LOCALE = "en";
|
|
3
|
+
export declare const LOCALES: string[];
|
|
4
|
+
export declare const DEFAULT_REDIRECT_BY_LOCALE: Record<string, string>;
|
|
5
|
+
export declare const LOGIN_PATH_BY_LOCALE: Record<string, string>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface IAuthResult {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
error?: string;
|
|
4
|
+
/** Signup only: the account was created but needs email confirmation. */
|
|
5
|
+
needsConfirmation?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const login: (email: string, password: string) => Promise<IAuthResult>;
|
|
8
|
+
export declare const signup: (params: {
|
|
9
|
+
email: string;
|
|
10
|
+
password: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
}) => Promise<IAuthResult>;
|
|
13
|
+
export declare const confirmSignup: (email: string, code: string) => Promise<IAuthResult>;
|
|
14
|
+
export declare const logout: () => Promise<IAuthResult>;
|
|
15
|
+
/**
|
|
16
|
+
* Restrict post-auth redirects to same-site relative paths, rejecting
|
|
17
|
+
* protocol-relative URLs (e.g. //attacker.com) which also start with "/".
|
|
18
|
+
* Without a valid `next`, fall back to the app's configured post-login page for
|
|
19
|
+
* the current locale, then the locale home, then the site root.
|
|
20
|
+
*/
|
|
21
|
+
export declare function safeNextPath(next: string | undefined): string;
|