@turbofy-ai/app-runtime 0.0.24 → 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 +24 -8
- package/dist/src/dsl.js +89 -24
- package/package.json +1 -1
package/dist/src/dsl.d.ts
CHANGED
|
@@ -2086,8 +2086,30 @@ export interface FlattenBlocksOptions {
|
|
|
2086
2086
|
fallbackLocale?: string;
|
|
2087
2087
|
}
|
|
2088
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
|
+
}
|
|
2089
2100
|
export interface IPageParamConfig {
|
|
2090
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>;
|
|
2091
2113
|
}
|
|
2092
2114
|
export interface IPageOptions {
|
|
2093
2115
|
id?: string;
|
|
@@ -2137,16 +2159,10 @@ export interface IPageDefinition {
|
|
|
2137
2159
|
blocks: IBlockDefinition[];
|
|
2138
2160
|
}
|
|
2139
2161
|
export interface IPageSlugConfig {
|
|
2140
|
-
paramsCollectionMap: Record<string,
|
|
2141
|
-
ofType: string;
|
|
2142
|
-
slugField?: string;
|
|
2143
|
-
}>;
|
|
2162
|
+
paramsCollectionMap: Record<string, PageParamCollectionMapping>;
|
|
2144
2163
|
[locale: string]: {
|
|
2145
2164
|
slug: string;
|
|
2146
|
-
} | Record<string,
|
|
2147
|
-
ofType: string;
|
|
2148
|
-
slugField?: string;
|
|
2149
|
-
}>;
|
|
2165
|
+
} | Record<string, PageParamCollectionMapping>;
|
|
2150
2166
|
}
|
|
2151
2167
|
export interface IPageOutput {
|
|
2152
2168
|
id?: string;
|
package/dist/src/dsl.js
CHANGED
|
@@ -16253,7 +16253,7 @@ var getFlowStepTargets = (step2) => {
|
|
|
16253
16253
|
var getBranchOwnershipErrors = (declaration) => {
|
|
16254
16254
|
const owners = /* @__PURE__ */ new Map();
|
|
16255
16255
|
const errors = [];
|
|
16256
|
-
const
|
|
16256
|
+
const visit2 = (name, scope) => {
|
|
16257
16257
|
const step2 = declaration.steps[name];
|
|
16258
16258
|
if (!Object.hasOwn(declaration.steps, name)) return;
|
|
16259
16259
|
const owner = JSON.stringify(scope);
|
|
@@ -16270,18 +16270,18 @@ var getBranchOwnershipErrors = (declaration) => {
|
|
|
16270
16270
|
owners.set(name, owner);
|
|
16271
16271
|
if (step2.type === "forEach" /* forEach */) {
|
|
16272
16272
|
const body = getForEachBodyTarget(step2);
|
|
16273
|
-
if (body !== null)
|
|
16274
|
-
if (step2.nextStep !== null)
|
|
16273
|
+
if (body !== null) visit2(body, [...scope, name, body]);
|
|
16274
|
+
if (step2.nextStep !== null) visit2(step2.nextStep, scope);
|
|
16275
16275
|
return;
|
|
16276
16276
|
}
|
|
16277
16277
|
for (const target of getFlowStepTargets(step2)) {
|
|
16278
|
-
|
|
16278
|
+
visit2(
|
|
16279
16279
|
target,
|
|
16280
16280
|
step2.type === "branch" /* branch */ ? [...scope, name, target] : scope
|
|
16281
16281
|
);
|
|
16282
16282
|
}
|
|
16283
16283
|
};
|
|
16284
|
-
if (declaration.startStep)
|
|
16284
|
+
if (declaration.startStep) visit2(declaration.startStep, []);
|
|
16285
16285
|
const names = Object.keys(declaration.steps);
|
|
16286
16286
|
const targets = new Set(
|
|
16287
16287
|
Object.values(declaration.steps).flatMap(getFlowStepTargets)
|
|
@@ -16290,7 +16290,7 @@ var getBranchOwnershipErrors = (declaration) => {
|
|
|
16290
16290
|
...names.filter((name2) => !targets.has(name2)),
|
|
16291
16291
|
...names
|
|
16292
16292
|
]) {
|
|
16293
|
-
if (!owners.has(name))
|
|
16293
|
+
if (!owners.has(name)) visit2(name, []);
|
|
16294
16294
|
}
|
|
16295
16295
|
return errors;
|
|
16296
16296
|
};
|
|
@@ -16324,7 +16324,7 @@ var getFlowCycleErrors = (declaration) => {
|
|
|
16324
16324
|
const visiting = /* @__PURE__ */ new Set();
|
|
16325
16325
|
const visited = /* @__PURE__ */ new Set();
|
|
16326
16326
|
const errors = [];
|
|
16327
|
-
const
|
|
16327
|
+
const visit2 = (name) => {
|
|
16328
16328
|
if (visiting.has(name)) {
|
|
16329
16329
|
errors.push({
|
|
16330
16330
|
stepName: name,
|
|
@@ -16335,11 +16335,11 @@ var getFlowCycleErrors = (declaration) => {
|
|
|
16335
16335
|
if (visited.has(name) || !Object.hasOwn(declaration.steps, name)) return;
|
|
16336
16336
|
visiting.add(name);
|
|
16337
16337
|
for (const target of getFlowStepTargets(declaration.steps[name]))
|
|
16338
|
-
|
|
16338
|
+
visit2(target);
|
|
16339
16339
|
visiting.delete(name);
|
|
16340
16340
|
visited.add(name);
|
|
16341
16341
|
};
|
|
16342
|
-
for (const name of Object.keys(declaration.steps))
|
|
16342
|
+
for (const name of Object.keys(declaration.steps)) visit2(name);
|
|
16343
16343
|
return errors;
|
|
16344
16344
|
};
|
|
16345
16345
|
var getFlowGraphErrors = (declaration) => [
|
|
@@ -22216,6 +22216,48 @@ function flattenBlocks(blocks, opts) {
|
|
|
22216
22216
|
return result;
|
|
22217
22217
|
}
|
|
22218
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
|
+
|
|
22219
22261
|
// ../dsl-builders/src/apps/slug-validation.ts
|
|
22220
22262
|
function assertNoLegacySlugField(mapping, pageName, paramName, collectionId) {
|
|
22221
22263
|
if (!("slugField" in mapping)) return;
|
|
@@ -22226,6 +22268,12 @@ function assertNoLegacySlugField(mapping, pageName, paramName, collectionId) {
|
|
|
22226
22268
|
}
|
|
22227
22269
|
|
|
22228
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
|
+
}
|
|
22229
22277
|
function setPageVisibility(slugConfig, visibility) {
|
|
22230
22278
|
if (visibility && visibility !== "public") {
|
|
22231
22279
|
slugConfig.visibility = visibility;
|
|
@@ -22422,6 +22470,23 @@ function buildPages(pages, opts) {
|
|
|
22422
22470
|
);
|
|
22423
22471
|
}
|
|
22424
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
|
+
}
|
|
22425
22490
|
}
|
|
22426
22491
|
}
|
|
22427
22492
|
const locales = opts?.locales ?? (opts?.locale ? [opts.locale] : ["en"]);
|
|
@@ -22429,7 +22494,7 @@ function buildPages(pages, opts) {
|
|
|
22429
22494
|
const mergedParams = collectMergedParams(p);
|
|
22430
22495
|
const paramsCollectionMap = {};
|
|
22431
22496
|
for (const [key, config2] of Object.entries(mergedParams)) {
|
|
22432
|
-
paramsCollectionMap[key] = config2
|
|
22497
|
+
paramsCollectionMap[key] = toParamCollectionMapping(config2);
|
|
22433
22498
|
}
|
|
22434
22499
|
const slugConfig = { paramsCollectionMap };
|
|
22435
22500
|
setPageVisibility(slugConfig, p.visibility);
|
|
@@ -22543,7 +22608,7 @@ function validatePageLocalizations(pages, supportedLocales) {
|
|
|
22543
22608
|
}
|
|
22544
22609
|
function validateBlockLocalizations(pages, supportedLocales) {
|
|
22545
22610
|
const supported = new Set(supportedLocales);
|
|
22546
|
-
const
|
|
22611
|
+
const visit2 = (blocks, pageName) => {
|
|
22547
22612
|
for (const b of blocks) {
|
|
22548
22613
|
if (b.localizations) {
|
|
22549
22614
|
for (const locale of Object.keys(b.localizations)) {
|
|
@@ -22555,12 +22620,12 @@ function validateBlockLocalizations(pages, supportedLocales) {
|
|
|
22555
22620
|
}
|
|
22556
22621
|
}
|
|
22557
22622
|
if (b.blocks.length > 0) {
|
|
22558
|
-
|
|
22623
|
+
visit2(b.blocks, pageName);
|
|
22559
22624
|
}
|
|
22560
22625
|
}
|
|
22561
22626
|
};
|
|
22562
22627
|
for (const p of pages) {
|
|
22563
|
-
|
|
22628
|
+
visit2(p.blocks, p.name);
|
|
22564
22629
|
}
|
|
22565
22630
|
}
|
|
22566
22631
|
|
|
@@ -22644,7 +22709,7 @@ function isSecretParam(value) {
|
|
|
22644
22709
|
function isFlowParamMarker(value) {
|
|
22645
22710
|
return isJsParam(value) || isSecretParam(value);
|
|
22646
22711
|
}
|
|
22647
|
-
function
|
|
22712
|
+
function isPlainObject3(value) {
|
|
22648
22713
|
return typeof value === "object" && value !== null && !Array.isArray(value) && !isFlowParamMarker(value);
|
|
22649
22714
|
}
|
|
22650
22715
|
function containsMarker(value) {
|
|
@@ -22670,7 +22735,7 @@ function lowerParamValue(value, path) {
|
|
|
22670
22735
|
}
|
|
22671
22736
|
return { value, config: { type: "logic", language: "static" } };
|
|
22672
22737
|
}
|
|
22673
|
-
if (
|
|
22738
|
+
if (isPlainObject3(value)) {
|
|
22674
22739
|
if (!containsMarker(value)) {
|
|
22675
22740
|
return { value, config: { type: "logic", language: "static" } };
|
|
22676
22741
|
}
|
|
@@ -22779,7 +22844,7 @@ function collectNonStaticPaths(paramsConfig, prefix = "") {
|
|
|
22779
22844
|
}
|
|
22780
22845
|
return paths;
|
|
22781
22846
|
}
|
|
22782
|
-
function walkSecretLeaves(params, paramsConfig,
|
|
22847
|
+
function walkSecretLeaves(params, paramsConfig, visit2, prefix = "") {
|
|
22783
22848
|
if (!paramsConfig) return;
|
|
22784
22849
|
for (const [key, config2] of Object.entries(paramsConfig)) {
|
|
22785
22850
|
const path = prefix ? `${prefix}.${key}` : key;
|
|
@@ -22788,11 +22853,11 @@ function walkSecretLeaves(params, paramsConfig, visit, prefix = "") {
|
|
|
22788
22853
|
walkSecretLeaves(
|
|
22789
22854
|
value ?? {},
|
|
22790
22855
|
config2.subParams,
|
|
22791
|
-
|
|
22856
|
+
visit2,
|
|
22792
22857
|
path
|
|
22793
22858
|
);
|
|
22794
22859
|
} else if (config2.type === "secret") {
|
|
22795
|
-
|
|
22860
|
+
visit2(path, value);
|
|
22796
22861
|
}
|
|
22797
22862
|
}
|
|
22798
22863
|
}
|
|
@@ -22866,12 +22931,12 @@ function tableIdsMatch(a, b) {
|
|
|
22866
22931
|
}
|
|
22867
22932
|
function collectReachableSteps(startStep, steps) {
|
|
22868
22933
|
const reachable = /* @__PURE__ */ new Set();
|
|
22869
|
-
const
|
|
22934
|
+
const visit2 = (name) => {
|
|
22870
22935
|
if (reachable.has(name) || !Object.hasOwn(steps, name)) return;
|
|
22871
22936
|
reachable.add(name);
|
|
22872
|
-
getFlowStepTargets(steps[name]).forEach(
|
|
22937
|
+
getFlowStepTargets(steps[name]).forEach(visit2);
|
|
22873
22938
|
};
|
|
22874
|
-
if (startStep !== null)
|
|
22939
|
+
if (startStep !== null) visit2(startStep);
|
|
22875
22940
|
return reachable;
|
|
22876
22941
|
}
|
|
22877
22942
|
function validateControlStep(step2, issue2, errors) {
|
|
@@ -23101,7 +23166,7 @@ function validateFlowGraph(flows) {
|
|
|
23101
23166
|
const visiting = /* @__PURE__ */ new Set();
|
|
23102
23167
|
const done = /* @__PURE__ */ new Set();
|
|
23103
23168
|
const stack = [];
|
|
23104
|
-
const
|
|
23169
|
+
const visit2 = (id) => {
|
|
23105
23170
|
if (done.has(id)) return;
|
|
23106
23171
|
visiting.add(id);
|
|
23107
23172
|
stack.push(id);
|
|
@@ -23127,7 +23192,7 @@ function validateFlowGraph(flows) {
|
|
|
23127
23192
|
continue;
|
|
23128
23193
|
}
|
|
23129
23194
|
if (!done.has(edge.toId)) {
|
|
23130
|
-
|
|
23195
|
+
visit2(edge.toId);
|
|
23131
23196
|
}
|
|
23132
23197
|
}
|
|
23133
23198
|
stack.pop();
|
|
@@ -23135,7 +23200,7 @@ function validateFlowGraph(flows) {
|
|
|
23135
23200
|
done.add(id);
|
|
23136
23201
|
};
|
|
23137
23202
|
for (const flow of flows) {
|
|
23138
|
-
|
|
23203
|
+
visit2(flow.id);
|
|
23139
23204
|
}
|
|
23140
23205
|
return { errors, warnings: [] };
|
|
23141
23206
|
}
|