@turbofy-ai/app-runtime 0.0.23 → 0.0.25

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 CHANGED
@@ -1798,6 +1798,20 @@ declare const webhookConfigSchema: z.ZodObject<{
1798
1798
  z.ZodObject<{
1799
1799
  type: z.ZodLiteral<"stripe">;
1800
1800
  secretId: z.ZodString;
1801
+ }, z.core.$strict>,
1802
+ z.ZodObject<{
1803
+ type: z.ZodLiteral<"payload-checksum">;
1804
+ secretId: z.ZodString;
1805
+ checksumField: z.ZodString;
1806
+ fields: z.ZodArray<z.ZodString>;
1807
+ secretPosition: z.ZodOptional<z.ZodEnum<{
1808
+ append: "append";
1809
+ prepend: "prepend";
1810
+ }>>;
1811
+ secretTransform: z.ZodOptional<z.ZodEnum<{
1812
+ reverse: "reverse";
1813
+ none: "none";
1814
+ }>>;
1801
1815
  }, z.core.$strict>
1802
1816
  ], "type">;
1803
1817
  bodyFormat: z.ZodOptional<z.ZodEnum<{
@@ -2072,8 +2086,30 @@ export interface FlattenBlocksOptions {
2072
2086
  fallbackLocale?: string;
2073
2087
  }
2074
2088
  declare function flattenBlocks(blocks: IBlockDefinition[], opts?: FlattenBlocksOptions): IBlockOutput[];
2089
+ /**
2090
+ * One `slugConfig.paramsCollectionMap` entry. Code-created pages store the bare
2091
+ * table id; the dashboard stores `{ ofType: tableId }`.
2092
+ */
2093
+ export type PageParamCollectionMapping = string | IPageParamCollectionObject;
2094
+ export interface IPageParamCollectionObject {
2095
+ ofType: string;
2096
+ /** Legacy; push rejects it. Kept in the type so pull can surface it. */
2097
+ slugField?: string;
2098
+ [key: string]: unknown;
2099
+ }
2075
2100
  export interface IPageParamConfig {
2076
2101
  collection: IObjectTypeDeclaration;
2102
+ /**
2103
+ * How `slugConfig.paramsCollectionMap` stores this param. `"object"` writes
2104
+ * `{ ofType: <table id> }`, the form the dashboard's page settings save.
2105
+ * Omitted writes the bare table id. Pull sets it so a round trip is lossless.
2106
+ */
2107
+ mappingFormat?: "object";
2108
+ /**
2109
+ * Extra keys stored next to `ofType` in the object form. Requires
2110
+ * `mappingFormat: "object"`; pull emits it so unknown keys survive a push.
2111
+ */
2112
+ mappingExtras?: Record<string, unknown>;
2077
2113
  }
2078
2114
  export interface IPageOptions {
2079
2115
  id?: string;
@@ -2123,16 +2159,10 @@ export interface IPageDefinition {
2123
2159
  blocks: IBlockDefinition[];
2124
2160
  }
2125
2161
  export interface IPageSlugConfig {
2126
- paramsCollectionMap: Record<string, string | {
2127
- ofType: string;
2128
- slugField?: string;
2129
- }>;
2162
+ paramsCollectionMap: Record<string, PageParamCollectionMapping>;
2130
2163
  [locale: string]: {
2131
2164
  slug: string;
2132
- } | Record<string, string | {
2133
- ofType: string;
2134
- slugField?: string;
2135
- }>;
2165
+ } | Record<string, PageParamCollectionMapping>;
2136
2166
  }
2137
2167
  export interface IPageOutput {
2138
2168
  id?: string;
package/dist/src/dsl.js CHANGED
@@ -16162,6 +16162,7 @@ function hasScheduleExpression(config2) {
16162
16162
  // ../declarations/src/flows/webhook.ts
16163
16163
  var secretId = external_exports.string().regex(/^[A-Za-z0-9_-]{1,128}$/);
16164
16164
  var headerName = external_exports.string().regex(/^[a-z0-9-]{1,64}$/);
16165
+ var jsonPath = external_exports.string().regex(/^[A-Za-z0-9_-]{1,64}(\.[A-Za-z0-9_-]{1,64}){0,9}$/);
16165
16166
  var webhookConfigSchema = external_exports.object({
16166
16167
  verification: external_exports.discriminatedUnion("type", [
16167
16168
  external_exports.object({ type: external_exports.literal("bearer"), secretId }).strict(),
@@ -16171,7 +16172,22 @@ var webhookConfigSchema = external_exports.object({
16171
16172
  header: headerName,
16172
16173
  prefix: external_exports.string().max(32).optional()
16173
16174
  }).strict(),
16174
- external_exports.object({ type: external_exports.literal("stripe"), secretId }).strict()
16175
+ external_exports.object({ type: external_exports.literal("stripe"), secretId }).strict(),
16176
+ external_exports.object({
16177
+ type: external_exports.literal("payload-checksum"),
16178
+ secretId,
16179
+ /** Dot path of the checksum inside the JSON body, e.g. "event.checksum". */
16180
+ checksumField: jsonPath,
16181
+ /**
16182
+ * Dot paths concatenated in order. A missing or null field fails
16183
+ * verification unless the path ends with "?", which skips it.
16184
+ */
16185
+ fields: external_exports.array(
16186
+ external_exports.string().regex(/^[A-Za-z0-9_-]{1,64}(\.[A-Za-z0-9_-]{1,64}){0,9}\??$/)
16187
+ ).min(1).max(20),
16188
+ secretPosition: external_exports.enum(["append", "prepend"]).optional(),
16189
+ secretTransform: external_exports.enum(["none", "reverse"]).optional()
16190
+ }).strict()
16175
16191
  ]),
16176
16192
  bodyFormat: external_exports.enum(["json", "text"]).optional(),
16177
16193
  forwardHeaders: external_exports.array(headerName).max(20).optional()
@@ -16197,6 +16213,21 @@ var webhookConfigSchema = external_exports.object({
16197
16213
  message: "Stripe requires JSON"
16198
16214
  });
16199
16215
  }
16216
+ if (config2.verification.type === "payload-checksum") {
16217
+ if (config2.bodyFormat === "text") {
16218
+ ctx.addIssue({
16219
+ code: "custom",
16220
+ message: "Payload checksum requires JSON"
16221
+ });
16222
+ }
16223
+ const { checksumField, fields: fields2 } = config2.verification;
16224
+ if (fields2.some((field2) => field2.replace(/\?$/, "") === checksumField)) {
16225
+ ctx.addIssue({
16226
+ code: "custom",
16227
+ message: "The checksum field cannot be part of the signed fields"
16228
+ });
16229
+ }
16230
+ }
16200
16231
  });
16201
16232
 
16202
16233
  // ../declarations/src/flows/branch.ts
@@ -16222,7 +16253,7 @@ var getFlowStepTargets = (step2) => {
16222
16253
  var getBranchOwnershipErrors = (declaration) => {
16223
16254
  const owners = /* @__PURE__ */ new Map();
16224
16255
  const errors = [];
16225
- const visit = (name, scope) => {
16256
+ const visit2 = (name, scope) => {
16226
16257
  const step2 = declaration.steps[name];
16227
16258
  if (!Object.hasOwn(declaration.steps, name)) return;
16228
16259
  const owner = JSON.stringify(scope);
@@ -16239,18 +16270,18 @@ var getBranchOwnershipErrors = (declaration) => {
16239
16270
  owners.set(name, owner);
16240
16271
  if (step2.type === "forEach" /* forEach */) {
16241
16272
  const body = getForEachBodyTarget(step2);
16242
- if (body !== null) visit(body, [...scope, name, body]);
16243
- if (step2.nextStep !== null) visit(step2.nextStep, scope);
16273
+ if (body !== null) visit2(body, [...scope, name, body]);
16274
+ if (step2.nextStep !== null) visit2(step2.nextStep, scope);
16244
16275
  return;
16245
16276
  }
16246
16277
  for (const target of getFlowStepTargets(step2)) {
16247
- visit(
16278
+ visit2(
16248
16279
  target,
16249
16280
  step2.type === "branch" /* branch */ ? [...scope, name, target] : scope
16250
16281
  );
16251
16282
  }
16252
16283
  };
16253
- if (declaration.startStep) visit(declaration.startStep, []);
16284
+ if (declaration.startStep) visit2(declaration.startStep, []);
16254
16285
  const names = Object.keys(declaration.steps);
16255
16286
  const targets = new Set(
16256
16287
  Object.values(declaration.steps).flatMap(getFlowStepTargets)
@@ -16259,7 +16290,7 @@ var getBranchOwnershipErrors = (declaration) => {
16259
16290
  ...names.filter((name2) => !targets.has(name2)),
16260
16291
  ...names
16261
16292
  ]) {
16262
- if (!owners.has(name)) visit(name, []);
16293
+ if (!owners.has(name)) visit2(name, []);
16263
16294
  }
16264
16295
  return errors;
16265
16296
  };
@@ -16293,7 +16324,7 @@ var getFlowCycleErrors = (declaration) => {
16293
16324
  const visiting = /* @__PURE__ */ new Set();
16294
16325
  const visited = /* @__PURE__ */ new Set();
16295
16326
  const errors = [];
16296
- const visit = (name) => {
16327
+ const visit2 = (name) => {
16297
16328
  if (visiting.has(name)) {
16298
16329
  errors.push({
16299
16330
  stepName: name,
@@ -16304,11 +16335,11 @@ var getFlowCycleErrors = (declaration) => {
16304
16335
  if (visited.has(name) || !Object.hasOwn(declaration.steps, name)) return;
16305
16336
  visiting.add(name);
16306
16337
  for (const target of getFlowStepTargets(declaration.steps[name]))
16307
- visit(target);
16338
+ visit2(target);
16308
16339
  visiting.delete(name);
16309
16340
  visited.add(name);
16310
16341
  };
16311
- for (const name of Object.keys(declaration.steps)) visit(name);
16342
+ for (const name of Object.keys(declaration.steps)) visit2(name);
16312
16343
  return errors;
16313
16344
  };
16314
16345
  var getFlowGraphErrors = (declaration) => [
@@ -22185,6 +22216,48 @@ function flattenBlocks(blocks, opts) {
22185
22216
  return result;
22186
22217
  }
22187
22218
 
22219
+ // ../dsl-builders/src/apps/json-safe.ts
22220
+ function assertJsonSafe(value, path = "value") {
22221
+ visit(value, path, /* @__PURE__ */ new Set());
22222
+ }
22223
+ function visit(value, path, ancestors) {
22224
+ if (value === null || typeof value === "boolean" || typeof value === "string") {
22225
+ return;
22226
+ }
22227
+ if (typeof value === "number") {
22228
+ if (!Number.isFinite(value)) {
22229
+ throw new Error(`${path} is not JSON-safe: ${String(value)}`);
22230
+ }
22231
+ return;
22232
+ }
22233
+ const isArray2 = Array.isArray(value);
22234
+ if (!isArray2 && !isPlainObject2(value)) {
22235
+ throw new Error(`${path} is not JSON-safe: ${typeof value}`);
22236
+ }
22237
+ if (ancestors.has(value)) {
22238
+ throw new Error(`${path} is not JSON-safe: circular reference`);
22239
+ }
22240
+ ancestors.add(value);
22241
+ if (isArray2) {
22242
+ for (let i = 0; i < value.length; i++) {
22243
+ if (!(i in value)) {
22244
+ throw new Error(`${path}[${i}] is not JSON-safe: array hole`);
22245
+ }
22246
+ visit(value[i], `${path}[${i}]`, ancestors);
22247
+ }
22248
+ } else {
22249
+ for (const [key, item] of Object.entries(value)) {
22250
+ visit(item, `${path}.${key}`, ancestors);
22251
+ }
22252
+ }
22253
+ ancestors.delete(value);
22254
+ }
22255
+ function isPlainObject2(value) {
22256
+ if (typeof value !== "object" || value === null) return false;
22257
+ const proto = Object.getPrototypeOf(value);
22258
+ return proto === Object.prototype || proto === null;
22259
+ }
22260
+
22188
22261
  // ../dsl-builders/src/apps/slug-validation.ts
22189
22262
  function assertNoLegacySlugField(mapping, pageName, paramName, collectionId) {
22190
22263
  if (!("slugField" in mapping)) return;
@@ -22195,6 +22268,12 @@ function assertNoLegacySlugField(mapping, pageName, paramName, collectionId) {
22195
22268
  }
22196
22269
 
22197
22270
  // ../dsl-builders/src/apps/pages.ts
22271
+ function toParamCollectionMapping(config2) {
22272
+ if (config2.mappingFormat !== "object") {
22273
+ return config2.collection.id;
22274
+ }
22275
+ return { ...config2.mappingExtras ?? {}, ofType: config2.collection.id };
22276
+ }
22198
22277
  function setPageVisibility(slugConfig, visibility) {
22199
22278
  if (visibility && visibility !== "public") {
22200
22279
  slugConfig.visibility = visibility;
@@ -22391,6 +22470,23 @@ function buildPages(pages, opts) {
22391
22470
  );
22392
22471
  }
22393
22472
  assertNoLegacySlugField(paramConfig, p.name, paramKey, collection.id);
22473
+ if (paramConfig.mappingExtras !== void 0) {
22474
+ if (paramConfig.mappingFormat !== "object") {
22475
+ throw new Error(
22476
+ `buildPages: page "${p.name}" param "${paramKey}" sets mappingExtras, which requires mappingFormat: "object"`
22477
+ );
22478
+ }
22479
+ assertJsonSafe(
22480
+ paramConfig.mappingExtras,
22481
+ `buildPages: page "${p.name}" param "${paramKey}" mappingExtras`
22482
+ );
22483
+ assertNoLegacySlugField(
22484
+ paramConfig.mappingExtras,
22485
+ p.name,
22486
+ paramKey,
22487
+ collection.id
22488
+ );
22489
+ }
22394
22490
  }
22395
22491
  }
22396
22492
  const locales = opts?.locales ?? (opts?.locale ? [opts.locale] : ["en"]);
@@ -22398,7 +22494,7 @@ function buildPages(pages, opts) {
22398
22494
  const mergedParams = collectMergedParams(p);
22399
22495
  const paramsCollectionMap = {};
22400
22496
  for (const [key, config2] of Object.entries(mergedParams)) {
22401
- paramsCollectionMap[key] = config2.collection.id;
22497
+ paramsCollectionMap[key] = toParamCollectionMapping(config2);
22402
22498
  }
22403
22499
  const slugConfig = { paramsCollectionMap };
22404
22500
  setPageVisibility(slugConfig, p.visibility);
@@ -22512,7 +22608,7 @@ function validatePageLocalizations(pages, supportedLocales) {
22512
22608
  }
22513
22609
  function validateBlockLocalizations(pages, supportedLocales) {
22514
22610
  const supported = new Set(supportedLocales);
22515
- const visit = (blocks, pageName) => {
22611
+ const visit2 = (blocks, pageName) => {
22516
22612
  for (const b of blocks) {
22517
22613
  if (b.localizations) {
22518
22614
  for (const locale of Object.keys(b.localizations)) {
@@ -22524,12 +22620,12 @@ function validateBlockLocalizations(pages, supportedLocales) {
22524
22620
  }
22525
22621
  }
22526
22622
  if (b.blocks.length > 0) {
22527
- visit(b.blocks, pageName);
22623
+ visit2(b.blocks, pageName);
22528
22624
  }
22529
22625
  }
22530
22626
  };
22531
22627
  for (const p of pages) {
22532
- visit(p.blocks, p.name);
22628
+ visit2(p.blocks, p.name);
22533
22629
  }
22534
22630
  }
22535
22631
 
@@ -22613,7 +22709,7 @@ function isSecretParam(value) {
22613
22709
  function isFlowParamMarker(value) {
22614
22710
  return isJsParam(value) || isSecretParam(value);
22615
22711
  }
22616
- function isPlainObject2(value) {
22712
+ function isPlainObject3(value) {
22617
22713
  return typeof value === "object" && value !== null && !Array.isArray(value) && !isFlowParamMarker(value);
22618
22714
  }
22619
22715
  function containsMarker(value) {
@@ -22639,7 +22735,7 @@ function lowerParamValue(value, path) {
22639
22735
  }
22640
22736
  return { value, config: { type: "logic", language: "static" } };
22641
22737
  }
22642
- if (isPlainObject2(value)) {
22738
+ if (isPlainObject3(value)) {
22643
22739
  if (!containsMarker(value)) {
22644
22740
  return { value, config: { type: "logic", language: "static" } };
22645
22741
  }
@@ -22748,7 +22844,7 @@ function collectNonStaticPaths(paramsConfig, prefix = "") {
22748
22844
  }
22749
22845
  return paths;
22750
22846
  }
22751
- function walkSecretLeaves(params, paramsConfig, visit, prefix = "") {
22847
+ function walkSecretLeaves(params, paramsConfig, visit2, prefix = "") {
22752
22848
  if (!paramsConfig) return;
22753
22849
  for (const [key, config2] of Object.entries(paramsConfig)) {
22754
22850
  const path = prefix ? `${prefix}.${key}` : key;
@@ -22757,11 +22853,11 @@ function walkSecretLeaves(params, paramsConfig, visit, prefix = "") {
22757
22853
  walkSecretLeaves(
22758
22854
  value ?? {},
22759
22855
  config2.subParams,
22760
- visit,
22856
+ visit2,
22761
22857
  path
22762
22858
  );
22763
22859
  } else if (config2.type === "secret") {
22764
- visit(path, value);
22860
+ visit2(path, value);
22765
22861
  }
22766
22862
  }
22767
22863
  }
@@ -22835,12 +22931,12 @@ function tableIdsMatch(a, b) {
22835
22931
  }
22836
22932
  function collectReachableSteps(startStep, steps) {
22837
22933
  const reachable = /* @__PURE__ */ new Set();
22838
- const visit = (name) => {
22934
+ const visit2 = (name) => {
22839
22935
  if (reachable.has(name) || !Object.hasOwn(steps, name)) return;
22840
22936
  reachable.add(name);
22841
- getFlowStepTargets(steps[name]).forEach(visit);
22937
+ getFlowStepTargets(steps[name]).forEach(visit2);
22842
22938
  };
22843
- if (startStep !== null) visit(startStep);
22939
+ if (startStep !== null) visit2(startStep);
22844
22940
  return reachable;
22845
22941
  }
22846
22942
  function validateControlStep(step2, issue2, errors) {
@@ -23070,7 +23166,7 @@ function validateFlowGraph(flows) {
23070
23166
  const visiting = /* @__PURE__ */ new Set();
23071
23167
  const done = /* @__PURE__ */ new Set();
23072
23168
  const stack = [];
23073
- const visit = (id) => {
23169
+ const visit2 = (id) => {
23074
23170
  if (done.has(id)) return;
23075
23171
  visiting.add(id);
23076
23172
  stack.push(id);
@@ -23096,7 +23192,7 @@ function validateFlowGraph(flows) {
23096
23192
  continue;
23097
23193
  }
23098
23194
  if (!done.has(edge.toId)) {
23099
- visit(edge.toId);
23195
+ visit2(edge.toId);
23100
23196
  }
23101
23197
  }
23102
23198
  stack.pop();
@@ -23104,7 +23200,7 @@ function validateFlowGraph(flows) {
23104
23200
  done.add(id);
23105
23201
  };
23106
23202
  for (const flow of flows) {
23107
- visit(flow.id);
23203
+ visit2(flow.id);
23108
23204
  }
23109
23205
  return { errors, warnings: [] };
23110
23206
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turbofy-ai/app-runtime",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {