@turbofy-ai/app-runtime 0.0.9 → 0.0.11-alpha.0

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.
@@ -159,6 +159,12 @@ export type IWsSubscribePayload = {
159
159
  export type IWsEvent = {
160
160
  operation: IWsOperation;
161
161
  record: Record<string, unknown>;
162
+ /**
163
+ * The record's type, named on the envelope. Blocks receive events already
164
+ * routed by subscription id, so this is informational for them — the parent
165
+ * frame is what filters by type.
166
+ */
167
+ ofType?: string;
162
168
  };
163
169
  export type IWsEventPayload = {
164
170
  subscriptionId: string;
package/dist/src/dsl.d.ts CHANGED
@@ -1639,8 +1639,30 @@ export interface ITableDataChangeTrigger<TName extends string, TOperation extend
1639
1639
  new: ITriggerData;
1640
1640
  } : ITriggerData;
1641
1641
  }
1642
+ export type IScheduleRateUnit = "minutes" | "hours" | "days";
1643
+ export interface IScheduleRate {
1644
+ value: number;
1645
+ unit: IScheduleRateUnit;
1646
+ }
1642
1647
  export interface IScheduledTrigger<TName extends string> extends ISharedTriggerDeclaration<TName> {
1643
1648
  variant: TriggerVariantEnum.SCHEDULE;
1649
+ /**
1650
+ * AWS 6-field cron expression: minutes hours day-of-month month
1651
+ * day-of-week year (e.g. "0 9 * * ? *" — daily at 9:00).
1652
+ * Exactly one of `cron` and `rate` must be set for the trigger to fire.
1653
+ */
1654
+ cron?: string;
1655
+ /** Fixed-interval alternative to `cron` (e.g. every 10 minutes). */
1656
+ rate?: IScheduleRate;
1657
+ /** IANA timezone the cron expression is evaluated in. Defaults to UTC. */
1658
+ timezone?: string;
1659
+ /**
1660
+ * ISO 8601 date (e.g. "2026-08-01") or datetime before which the schedule
1661
+ * does not fire. Date-only values are interpreted as midnight UTC.
1662
+ */
1663
+ startDate?: string;
1664
+ /** ISO 8601 date or datetime after which the schedule no longer fires. */
1665
+ endDate?: string;
1644
1666
  _tsTriggerData: unknown;
1645
1667
  }
1646
1668
  export interface IManualTrigger<TName extends string> extends ISharedTriggerDeclaration<TName> {
@@ -1685,6 +1707,8 @@ export interface IFlowDeclaration<TName extends string, TSteps extends Record<st
1685
1707
  steps: TSteps;
1686
1708
  debug?: boolean;
1687
1709
  disabled?: boolean;
1710
+ /** Dashboard accent color id (e.g. "blue"). UI-only; ignored by the runtime. */
1711
+ color?: string;
1688
1712
  }
1689
1713
  export type INonGenericIFlowDeclaration = IFlowDeclaration<string, Record<string, IStep>>;
1690
1714
  export type II18nSettings = {
@@ -1834,6 +1858,12 @@ export interface IPageOptions {
1834
1858
  param?: IPageParamConfig;
1835
1859
  /** Default English localization dictionary for this page. */
1836
1860
  defaultLocalization?: LocalizationDictionary;
1861
+ /**
1862
+ * Per-locale page copies / SEO meta, keyed by locale. Takes precedence over
1863
+ * `defaultLocalization` and `meta`; embed each locale's `meta` entries in
1864
+ * its dictionary.
1865
+ */
1866
+ localizations?: ILocalizationsByLocale;
1837
1867
  /** SEO metadata (title, description, og:* and twitter:* tags) rendered as `<meta>` tags */
1838
1868
  meta?: IPageMetaDictionary;
1839
1869
  /** Localized config (e.g. canonicalPath, notFound). Preserved through pull/push. */
@@ -1854,6 +1884,7 @@ export interface IPageDefinition {
1854
1884
  parent?: IPageDefinition;
1855
1885
  params: Record<string, IPageParamConfig>;
1856
1886
  defaultLocalization?: LocalizationDictionary;
1887
+ localizations?: ILocalizationsByLocale;
1857
1888
  localizedConfig?: string;
1858
1889
  visibility?: PageVisibility;
1859
1890
  blocks: IBlockDefinition[];
@@ -1946,6 +1977,33 @@ export interface ITableDataChangeTriggerOptions {
1946
1977
  export interface ISharedTriggerOptions {
1947
1978
  condition?: string;
1948
1979
  }
1980
+ export type IScheduleTriggerOptions = ISharedTriggerOptions & {
1981
+ /**
1982
+ * ISO 8601 date (e.g. "2026-08-01") or datetime before which the schedule
1983
+ * does not fire. Date-only values are interpreted as midnight UTC.
1984
+ */
1985
+ startDate?: string;
1986
+ /** ISO 8601 date or datetime after which the schedule no longer fires. */
1987
+ endDate?: string;
1988
+ } & ({
1989
+ /**
1990
+ * AWS 6-field cron expression: minutes hours day-of-month month
1991
+ * day-of-week year (e.g. "0 9 * * ? *" — daily at 9:00).
1992
+ */
1993
+ cron: string;
1994
+ /** IANA timezone the cron expression is evaluated in. Defaults to UTC. */
1995
+ timezone?: string;
1996
+ rate?: never;
1997
+ } | {
1998
+ /** Fixed interval, e.g. { value: 10, unit: "minutes" }. */
1999
+ rate: IScheduleRate;
2000
+ cron?: never;
2001
+ timezone?: never;
2002
+ } | {
2003
+ cron?: never;
2004
+ rate?: never;
2005
+ timezone?: never;
2006
+ });
1949
2007
  export type IFlowTriggerDefinition = {
1950
2008
  variant: TriggerVariantEnum.TABLE_DATA_CHANGE;
1951
2009
  tableId: string;
@@ -1953,6 +2011,11 @@ export type IFlowTriggerDefinition = {
1953
2011
  condition?: string;
1954
2012
  } | {
1955
2013
  variant: TriggerVariantEnum.SCHEDULE;
2014
+ cron?: string;
2015
+ rate?: IScheduleRate;
2016
+ timezone?: string;
2017
+ startDate?: string;
2018
+ endDate?: string;
1956
2019
  condition?: string;
1957
2020
  } | {
1958
2021
  variant: TriggerVariantEnum.MANUAL;
@@ -1960,7 +2023,7 @@ export type IFlowTriggerDefinition = {
1960
2023
  };
1961
2024
  declare const trigger: {
1962
2025
  tableDataChange(opts: ITableDataChangeTriggerOptions): IFlowTriggerDefinition;
1963
- schedule(opts?: ISharedTriggerOptions): IFlowTriggerDefinition;
2026
+ schedule(opts?: IScheduleTriggerOptions): IFlowTriggerDefinition;
1964
2027
  manual(opts?: ISharedTriggerOptions): IFlowTriggerDefinition;
1965
2028
  };
1966
2029
  export type DeepParamObject<P> = P extends object ? {
@@ -2031,6 +2094,8 @@ export interface IFlowOptions {
2031
2094
  detachedSteps?: IFlowStepDefinition[];
2032
2095
  debug?: boolean;
2033
2096
  disabled?: boolean;
2097
+ /** Dashboard accent color id. UI-only; ignored by the runtime. */
2098
+ color?: string;
2034
2099
  }
2035
2100
  export interface IFlowOutput {
2036
2101
  name?: string;
@@ -2089,7 +2154,7 @@ export interface IValidateFlowsOptions {
2089
2154
  export declare function validateFlows(flows: IValidatableFlow[], opts?: IValidateFlowsOptions): IFlowValidationResult;
2090
2155
 
2091
2156
  declare namespace flowBuilder {
2092
- export { IFlowOptions, IFlowOutput, IFlowStepDefinition, IFlowStepOptions, IFlowTriggerDefinition, ISharedTriggerOptions, IStepParamsInput, ITableDataChangeTriggerOptions, TABLE_ID_PARAM_NAMES, buildFlow, js, secret, step, trigger };
2157
+ export { IFlowOptions, IFlowOutput, IFlowStepDefinition, IFlowStepOptions, IFlowTriggerDefinition, IScheduleTriggerOptions, ISharedTriggerOptions, IStepParamsInput, ITableDataChangeTriggerOptions, TABLE_ID_PARAM_NAMES, buildFlow, js, secret, step, trigger };
2093
2158
  }
2094
2159
  declare namespace dataBuilder {
2095
2160
  export { TableDef, TableOpts, TableSearchConfig, build, enumType, fields, table };
package/dist/src/dsl.js CHANGED
@@ -16641,6 +16641,112 @@ var schemas = {
16641
16641
  genericAI: genericAIStepSchema
16642
16642
  };
16643
16643
 
16644
+ // ../declarations/src/flows/schedule.ts
16645
+ var SCHEDULE_RATE_UNITS = [
16646
+ "minutes",
16647
+ "hours",
16648
+ "days"
16649
+ ];
16650
+ var CRON_MINUTES_PATTERN = /^[\d,\-*/]+$/;
16651
+ var CRON_HOURS_PATTERN = /^[\d,\-*/]+$/;
16652
+ var CRON_DAY_OF_MONTH_PATTERN = /^[\d,\-*/?LW]+$/i;
16653
+ var CRON_MONTH_PATTERN = /^(?:[\d,\-*/]|JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)+$/i;
16654
+ var CRON_DAY_OF_WEEK_PATTERN = /^(?:[\d,\-*/?L#]|SUN|MON|TUE|WED|THU|FRI|SAT)+$/i;
16655
+ var CRON_YEAR_PATTERN = /^[\d,\-*/]+$/;
16656
+ var CRON_FIELDS = [
16657
+ { label: "minutes", pattern: CRON_MINUTES_PATTERN },
16658
+ { label: "hours", pattern: CRON_HOURS_PATTERN },
16659
+ { label: "day-of-month", pattern: CRON_DAY_OF_MONTH_PATTERN },
16660
+ { label: "month", pattern: CRON_MONTH_PATTERN },
16661
+ { label: "day-of-week", pattern: CRON_DAY_OF_WEEK_PATTERN },
16662
+ { label: "year", pattern: CRON_YEAR_PATTERN }
16663
+ ];
16664
+ function validateCronExpression(cron) {
16665
+ const fields2 = cron.trim().split(/\s+/);
16666
+ if (fields2.length !== 6) {
16667
+ return [
16668
+ `Cron expression "${cron}" must have 6 fields (minutes hours day-of-month month day-of-week year), got ${fields2.length}`
16669
+ ];
16670
+ }
16671
+ const errors = [];
16672
+ fields2.forEach((field, index) => {
16673
+ if (!CRON_FIELDS[index].pattern.test(field)) {
16674
+ errors.push(
16675
+ `Cron expression "${cron}": invalid ${CRON_FIELDS[index].label} field "${field}"`
16676
+ );
16677
+ }
16678
+ });
16679
+ const dayOfMonth = fields2[2];
16680
+ const dayOfWeek = fields2[4];
16681
+ if (dayOfMonth !== "?" && dayOfWeek !== "?") {
16682
+ errors.push(
16683
+ `Cron expression "${cron}": one of day-of-month and day-of-week must be "?"`
16684
+ );
16685
+ }
16686
+ return errors;
16687
+ }
16688
+ function isValidScheduleDate(date5) {
16689
+ return !Number.isNaN(Date.parse(date5));
16690
+ }
16691
+ function isValidTimezone(timezone) {
16692
+ try {
16693
+ new Intl.DateTimeFormat("en-US", { timeZone: timezone });
16694
+ return true;
16695
+ } catch {
16696
+ return false;
16697
+ }
16698
+ }
16699
+ function validateRate(rate) {
16700
+ const errors = [];
16701
+ if (!Number.isInteger(rate.value) || rate.value < 1) {
16702
+ errors.push(
16703
+ `Schedule rate value must be a positive integer, got ${rate.value}`
16704
+ );
16705
+ }
16706
+ if (!SCHEDULE_RATE_UNITS.includes(rate.unit)) {
16707
+ errors.push(
16708
+ `Schedule rate unit must be one of ${SCHEDULE_RATE_UNITS.join(", ")}, got "${rate.unit}"`
16709
+ );
16710
+ }
16711
+ return errors;
16712
+ }
16713
+ function validateScheduleConfig(config2) {
16714
+ if (config2.cron !== void 0 && config2.rate !== void 0) {
16715
+ return ['Schedule triggers must set either "cron" or "rate", not both'];
16716
+ }
16717
+ const errors = [];
16718
+ if (config2.cron !== void 0) {
16719
+ errors.push(...validateCronExpression(config2.cron));
16720
+ }
16721
+ if (config2.rate !== void 0) {
16722
+ errors.push(...validateRate(config2.rate));
16723
+ }
16724
+ if (config2.timezone !== void 0) {
16725
+ if (config2.cron === void 0) {
16726
+ errors.push('Schedule "timezone" is only supported with "cron"');
16727
+ } else if (!isValidTimezone(config2.timezone)) {
16728
+ errors.push(`Unknown timezone "${config2.timezone}"`);
16729
+ }
16730
+ }
16731
+ if (config2.startDate !== void 0 && !isValidScheduleDate(config2.startDate)) {
16732
+ errors.push(
16733
+ `Schedule "startDate" must be an ISO 8601 date, got "${config2.startDate}"`
16734
+ );
16735
+ }
16736
+ if (config2.endDate !== void 0 && !isValidScheduleDate(config2.endDate)) {
16737
+ errors.push(
16738
+ `Schedule "endDate" must be an ISO 8601 date, got "${config2.endDate}"`
16739
+ );
16740
+ }
16741
+ if (config2.startDate !== void 0 && config2.endDate !== void 0 && isValidScheduleDate(config2.startDate) && isValidScheduleDate(config2.endDate) && Date.parse(config2.endDate) <= Date.parse(config2.startDate)) {
16742
+ errors.push('Schedule "endDate" must be after "startDate"');
16743
+ }
16744
+ return errors;
16745
+ }
16746
+ function hasScheduleExpression(config2) {
16747
+ return config2.cron !== void 0 || config2.rate !== void 0;
16748
+ }
16749
+
16644
16750
  // ../dsl-builders/src/apps/app-builder.ts
16645
16751
  var app_builder_exports = {};
16646
16752
  __export(app_builder_exports, {
@@ -22546,6 +22652,7 @@ function page(opts) {
22546
22652
  opts.defaultLocalization,
22547
22653
  opts.meta
22548
22654
  ),
22655
+ ...opts.localizations ? { localizations: opts.localizations } : {},
22549
22656
  localizedConfig: opts.localizedConfig,
22550
22657
  ...opts.visibility ? { visibility: opts.visibility } : {},
22551
22658
  blocks: opts.blocks ?? []
@@ -22732,6 +22839,7 @@ function buildPages(pages, opts) {
22732
22839
  name: p.name,
22733
22840
  slugConfig,
22734
22841
  ...p.defaultLocalization ? { defaultLocalization: p.defaultLocalization } : {},
22842
+ ...p.localizations ? { localizations: p.localizations } : {},
22735
22843
  ...p.localizedConfig ? { localizedConfig: p.localizedConfig } : {},
22736
22844
  blocks: flattenBlocks(p.blocks, {
22737
22845
  fallbackLocale: opts?.fallbackLocale
@@ -22772,6 +22880,7 @@ function buildApp(opts) {
22772
22880
  if (i18n) {
22773
22881
  validateBlockTypeLocalizations(appBlockTypes, i18n.locales);
22774
22882
  validateBlockLocalizations(opts.pages, i18n.locales);
22883
+ validatePageLocalizations(opts.pages, i18n.locales);
22775
22884
  }
22776
22885
  const pages = buildPages(opts.pages, buildPagesOpts);
22777
22886
  const blockTypes = buildBlockTypes(appBlockTypes, { fallbackLocale });
@@ -22813,6 +22922,19 @@ function validateBlockTypeLocalizations(blockTypes, supportedLocales) {
22813
22922
  }
22814
22923
  }
22815
22924
  }
22925
+ function validatePageLocalizations(pages, supportedLocales) {
22926
+ const supported = new Set(supportedLocales);
22927
+ for (const p of pages) {
22928
+ if (!p.localizations) continue;
22929
+ for (const locale of Object.keys(p.localizations)) {
22930
+ if (!supported.has(locale)) {
22931
+ throw new Error(
22932
+ `Page "${p.name}": localizations contain unsupported locale "${locale}". Supported: ${supportedLocales.join(", ")}`
22933
+ );
22934
+ }
22935
+ }
22936
+ }
22937
+ }
22816
22938
  function validateBlockLocalizations(pages, supportedLocales) {
22817
22939
  const supported = new Set(supportedLocales);
22818
22940
  const visit = (blocks, pageName) => {
@@ -22963,7 +23085,11 @@ function collectWriteSteps(declaration) {
22963
23085
  const params = step2.params;
22964
23086
  const ofTypeConfig = step2.paramsConfig?.ofType;
22965
23087
  if (isStaticParamConfig(ofTypeConfig) && typeof params.ofType === "string") {
22966
- staticWrites.push({ stepName: step2.name, ofType: params.ofType, operation });
23088
+ staticWrites.push({
23089
+ stepName: step2.name,
23090
+ ofType: params.ofType,
23091
+ operation
23092
+ });
22967
23093
  } else {
22968
23094
  dynamicWrites.push({
22969
23095
  stepName: step2.name,
@@ -23163,6 +23289,28 @@ function validateFlow(declaration, ctx) {
23163
23289
  for (const step2 of Object.values(steps)) {
23164
23290
  validateStepParams(step2, issue2, errors, warnings);
23165
23291
  }
23292
+ for (const [triggerName, trigger2] of Object.entries(
23293
+ declaration.triggers ?? {}
23294
+ )) {
23295
+ if (trigger2.variant !== "SCHEDULE" /* SCHEDULE */) continue;
23296
+ const scheduleErrors = validateScheduleConfig(trigger2);
23297
+ for (const message of scheduleErrors) {
23298
+ errors.push(
23299
+ issue2(
23300
+ `triggers.${triggerName}`,
23301
+ `Trigger "${triggerName}": ${message}`
23302
+ )
23303
+ );
23304
+ }
23305
+ if (scheduleErrors.length === 0 && !hasScheduleExpression(trigger2)) {
23306
+ warnings.push(
23307
+ issue2(
23308
+ `triggers.${triggerName}`,
23309
+ `Trigger "${triggerName}": schedule trigger has neither "cron" nor "rate" and will never fire`
23310
+ )
23311
+ );
23312
+ }
23313
+ }
23166
23314
  const { staticWrites, dynamicWrites } = collectWriteSteps(declaration);
23167
23315
  const tableTriggers = collectTableDataChangeTriggers(declaration);
23168
23316
  for (const write of staticWrites) {
@@ -23313,9 +23461,19 @@ var trigger = {
23313
23461
  ...opts.condition !== void 0 ? { condition: opts.condition } : {}
23314
23462
  };
23315
23463
  },
23464
+ // opts stays optional for round-trip fidelity: legacy declarations may
23465
+ // hold a schedule trigger without an expression (it never fires and is
23466
+ // reported as a validation warning).
23316
23467
  schedule(opts) {
23317
23468
  return {
23318
23469
  variant: "SCHEDULE" /* SCHEDULE */,
23470
+ ...opts && "cron" in opts ? {
23471
+ cron: opts.cron,
23472
+ ...opts.timezone !== void 0 ? { timezone: opts.timezone } : {}
23473
+ } : {},
23474
+ ...opts && "rate" in opts ? { rate: opts.rate } : {},
23475
+ ...opts?.startDate !== void 0 ? { startDate: opts.startDate } : {},
23476
+ ...opts?.endDate !== void 0 ? { endDate: opts.endDate } : {},
23319
23477
  ...opts?.condition !== void 0 ? { condition: opts.condition } : {}
23320
23478
  };
23321
23479
  },
@@ -23440,7 +23598,8 @@ function buildFlow(opts) {
23440
23598
  startStep: chainSteps.length > 0 ? chainSteps[0].name : null,
23441
23599
  steps,
23442
23600
  ...opts.debug !== void 0 ? { debug: opts.debug } : {},
23443
- ...opts.disabled !== void 0 ? { disabled: opts.disabled } : {}
23601
+ ...opts.disabled !== void 0 ? { disabled: opts.disabled } : {},
23602
+ ...opts.color !== void 0 ? { color: opts.color } : {}
23444
23603
  };
23445
23604
  const validation = validateFlow(declaration, { name: opts.name });
23446
23605
  errors.push(...validation.errors.map((issue2) => issue2.message));
@@ -0,0 +1,3 @@
1
+ export declare const contentHash: (content: string) => Promise<string>;
2
+ export declare const fileMapHash: (files: Record<string, string>) => Promise<string>;
3
+ export declare const withContentHash: (url: string, hash: string) => string;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,4 @@
1
1
  export { Link } from "./link";
2
- export { navigate } from "./navigate";
2
+ export { type INavigateOptions, navigate } from "./navigate";
3
3
  export { prefetch } from "./prefetch";
4
+ export { useSearchParams } from "./search-params";
@@ -1 +1,7 @@
1
- export declare const navigate: (path: string) => void;
1
+ export type INavigateOptions = {
2
+ /** Update the URL without re-resolving the page or re-rendering blocks. */
3
+ shallow?: boolean;
4
+ /** Replace the current history entry instead of pushing a new one. */
5
+ replace?: boolean;
6
+ };
7
+ export declare const navigate: (path: string, options?: INavigateOptions) => void;
@@ -0,0 +1,5 @@
1
+ export declare const SEARCH_PARAMS_GLOBAL = "__APP_SEARCH_PARAMS__";
2
+ export declare const SEARCH_PARAMS_EVENT = "app:search-params-update";
3
+ export declare const publishSearchParams: (next: Record<string, string>) => void;
4
+ export declare const parseSearchParamsFromPath: (path: string) => Record<string, string>;
5
+ export declare const useSearchParams: () => Record<string, string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turbofy-ai/app-runtime",
3
- "version": "0.0.9",
3
+ "version": "0.0.11-alpha.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -30,6 +30,7 @@
30
30
  ],
31
31
  "scripts": {
32
32
  "build": "npm run generate && tsc && tsx scripts/bundle-dsl.ts",
33
+ "prepublishOnly": "npm run build",
33
34
  "generate": "tsx scripts/write-ui-reexports.ts",
34
35
  "pretypecheck": "npm run generate",
35
36
  "typecheck": "tsc --noEmit"