@ghentcdh/crouton-api 0.0.1-alpha.83 → 0.0.1-alpha.85
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/index.cjs +58 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +48 -32
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -70,7 +70,7 @@ __export(index_exports, {
|
|
|
70
70
|
});
|
|
71
71
|
module.exports = __toCommonJS(index_exports);
|
|
72
72
|
|
|
73
|
-
// ../../node_modules/.pnpm/tsup@8.5.1_@
|
|
73
|
+
// ../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.59.4_@types+node@26.6.5__@swc+core@1.16.13_@swc+h_a45e3cc9f94d7f903e8b7ce10c2308b8/node_modules/tsup/assets/cjs_shims.js
|
|
74
74
|
var getImportMetaUrl = /* @__PURE__ */ __name(() => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href, "getImportMetaUrl");
|
|
75
75
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
76
76
|
|
|
@@ -4381,7 +4381,13 @@ var CroutonConfigSchema = import_zod48.z.object({
|
|
|
4381
4381
|
rules: RulesetSchema.default(RulesetSchema.parse({})).describe("Optional overrides of the default visibility and behaviour ruleset applied to all resources."),
|
|
4382
4382
|
sidebarGroups: import_zod48.z.record(import_zod48.z.string(), SidebarGroupSchema).default({}).describe('Sidebar group definitions, keyed by group slug (e.g. "metadata"). Resources reference a group via sidebar.group in their resource.json.'),
|
|
4383
4383
|
autoSave: import_zod48.z.boolean().default(true).describe("Whether form fields are saved automatically as the user edits them. Default true."),
|
|
4384
|
-
i18n: I18nConfigSchema.optional().describe("Optional i18n / translation configuration. Omit if the app is single-language.")
|
|
4384
|
+
i18n: I18nConfigSchema.optional().describe("Optional i18n / translation configuration. Omit if the app is single-language."),
|
|
4385
|
+
agentFiles: import_zod48.z.object({
|
|
4386
|
+
targets: import_zod48.z.array(import_zod48.z.enum([
|
|
4387
|
+
"claude",
|
|
4388
|
+
"cursor"
|
|
4389
|
+
])).optional().describe("Which agent file sets to manage. Defaults to those already present in the project, or both on first run.")
|
|
4390
|
+
}).optional().describe("Agent file sync configuration for `crouton migrate`. Stored after the first run.")
|
|
4385
4391
|
});
|
|
4386
4392
|
|
|
4387
4393
|
// ../crouton-core/src/lib/config/readConfig.ts
|
|
@@ -9986,8 +9992,18 @@ var import_node_fs6 = require("fs");
|
|
|
9986
9992
|
var import_promises9 = require("fs/promises");
|
|
9987
9993
|
var import_node_path14 = require("path");
|
|
9988
9994
|
|
|
9989
|
-
// src/
|
|
9995
|
+
// ../crouton-codegen/src/agent-files/manifest.ts
|
|
9996
|
+
var import_node_crypto = require("crypto");
|
|
9997
|
+
var import_promises10 = require("fs/promises");
|
|
9990
9998
|
var import_node_path15 = require("path");
|
|
9999
|
+
|
|
10000
|
+
// ../crouton-codegen/src/agent-files/sync.ts
|
|
10001
|
+
var import_node_fs7 = require("fs");
|
|
10002
|
+
var import_promises11 = require("fs/promises");
|
|
10003
|
+
var import_node_path16 = require("path");
|
|
10004
|
+
|
|
10005
|
+
// src/lib/crud/resource/ResourceFlags.ts
|
|
10006
|
+
var import_node_path17 = require("path");
|
|
9991
10007
|
var applyResourceFlagPatch = /* @__PURE__ */ __name((raw, patch) => {
|
|
9992
10008
|
const result = {
|
|
9993
10009
|
...raw
|
|
@@ -10028,8 +10044,8 @@ var applyResourceFlagPatch = /* @__PURE__ */ __name((raw, patch) => {
|
|
|
10028
10044
|
return result;
|
|
10029
10045
|
}, "applyResourceFlagPatch");
|
|
10030
10046
|
var resolveResourcePath = /* @__PURE__ */ __name((resourcesDir, name) => {
|
|
10031
|
-
const resolved = (0,
|
|
10032
|
-
if (!resolved.startsWith((0,
|
|
10047
|
+
const resolved = (0, import_node_path17.resolve)(resourcesDir, name, "resource.json");
|
|
10048
|
+
if (!resolved.startsWith((0, import_node_path17.resolve)(resourcesDir) + "/")) {
|
|
10033
10049
|
throw new Error(`Invalid resource name: "${name}"`);
|
|
10034
10050
|
}
|
|
10035
10051
|
return resolved;
|
|
@@ -10612,27 +10628,27 @@ var EnumEntrySchema2 = import_zod62.z.object({
|
|
|
10612
10628
|
var EnumRegistrySchema2 = import_zod62.z.record(import_zod62.z.string(), import_zod62.z.array(EnumEntrySchema2)).default({});
|
|
10613
10629
|
|
|
10614
10630
|
// src/lib/crud/enum-registry/enum-registry.loader.ts
|
|
10615
|
-
var
|
|
10616
|
-
var
|
|
10631
|
+
var import_node_fs8 = require("fs");
|
|
10632
|
+
var import_node_path18 = require("path");
|
|
10617
10633
|
var ENUMS_FILE = "crouton.enums.json";
|
|
10618
10634
|
var loadEnumRegistry = /* @__PURE__ */ __name((startDir, enumsFile) => {
|
|
10619
10635
|
let file = enumsFile;
|
|
10620
10636
|
if (!file) {
|
|
10621
10637
|
let dir = startDir;
|
|
10622
10638
|
while (true) {
|
|
10623
|
-
const candidate = (0,
|
|
10624
|
-
if ((0,
|
|
10639
|
+
const candidate = (0, import_node_path18.join)(dir, ENUMS_FILE);
|
|
10640
|
+
if ((0, import_node_fs8.existsSync)(candidate)) {
|
|
10625
10641
|
file = candidate;
|
|
10626
10642
|
break;
|
|
10627
10643
|
}
|
|
10628
|
-
const parent = (0,
|
|
10644
|
+
const parent = (0, import_node_path18.dirname)(dir);
|
|
10629
10645
|
if (parent === dir) break;
|
|
10630
10646
|
dir = parent;
|
|
10631
10647
|
}
|
|
10632
10648
|
}
|
|
10633
|
-
if (!file || !(0,
|
|
10649
|
+
if (!file || !(0, import_node_fs8.existsSync)(file)) return EnumRegistrySchema2.parse(void 0);
|
|
10634
10650
|
try {
|
|
10635
|
-
return EnumRegistrySchema2.parse(JSON.parse((0,
|
|
10651
|
+
return EnumRegistrySchema2.parse(JSON.parse((0, import_node_fs8.readFileSync)(file, "utf-8")));
|
|
10636
10652
|
} catch {
|
|
10637
10653
|
return EnumRegistrySchema2.parse(void 0);
|
|
10638
10654
|
}
|
|
@@ -10787,13 +10803,13 @@ var enrichRelationTypes2 = /* @__PURE__ */ __name((columns, schema) => {
|
|
|
10787
10803
|
}, "enrichRelationTypes");
|
|
10788
10804
|
|
|
10789
10805
|
// src/lib/crud/resource/ReadResourceJson.ts
|
|
10790
|
-
var
|
|
10791
|
-
var
|
|
10806
|
+
var import_node_fs9 = require("fs");
|
|
10807
|
+
var import_node_path19 = require("path");
|
|
10792
10808
|
var readResourceJson = /* @__PURE__ */ __name((jsonPath) => {
|
|
10793
|
-
if (!(0,
|
|
10809
|
+
if (!(0, import_node_fs9.existsSync)(jsonPath)) return void 0;
|
|
10794
10810
|
let fileContent;
|
|
10795
10811
|
try {
|
|
10796
|
-
fileContent = JSON.parse((0,
|
|
10812
|
+
fileContent = JSON.parse((0, import_node_fs9.readFileSync)(jsonPath, "utf-8"));
|
|
10797
10813
|
} catch (err) {
|
|
10798
10814
|
return {
|
|
10799
10815
|
success: false,
|
|
@@ -10811,21 +10827,21 @@ var readResourceJson = /* @__PURE__ */ __name((jsonPath) => {
|
|
|
10811
10827
|
success: true,
|
|
10812
10828
|
data: {
|
|
10813
10829
|
json: resource.data,
|
|
10814
|
-
dir: (0,
|
|
10830
|
+
dir: (0, import_node_path19.dirname)(jsonPath)
|
|
10815
10831
|
}
|
|
10816
10832
|
};
|
|
10817
10833
|
}, "readResourceJson");
|
|
10818
10834
|
|
|
10819
10835
|
// src/lib/crud/adapter/resource-resolver.ts
|
|
10820
|
-
var
|
|
10821
|
-
var
|
|
10836
|
+
var import_node_fs10 = require("fs");
|
|
10837
|
+
var import_node_path20 = require("path");
|
|
10822
10838
|
var resolveChildResourceDetailed = /* @__PURE__ */ __name((resourcePath, parentDir) => {
|
|
10823
10839
|
const attempted = [];
|
|
10824
10840
|
try {
|
|
10825
10841
|
if (resourcePath.endsWith(".json")) {
|
|
10826
|
-
const directPath = (0,
|
|
10842
|
+
const directPath = (0, import_node_path20.resolve)(parentDir, resourcePath);
|
|
10827
10843
|
attempted.push(directPath);
|
|
10828
|
-
if ((0,
|
|
10844
|
+
if ((0, import_node_fs10.existsSync)(directPath)) {
|
|
10829
10845
|
const result2 = readResourceJson(directPath);
|
|
10830
10846
|
if (result2?.success) return {
|
|
10831
10847
|
ok: true,
|
|
@@ -10839,7 +10855,7 @@ var resolveChildResourceDetailed = /* @__PURE__ */ __name((resourcePath, parentD
|
|
|
10839
10855
|
}
|
|
10840
10856
|
}
|
|
10841
10857
|
const childName = resourcePath.replace(/^\.\//, "").replace(/\.resource$/, "");
|
|
10842
|
-
const childJsonPath = (0,
|
|
10858
|
+
const childJsonPath = (0, import_node_path20.resolve)((0, import_node_path20.dirname)(parentDir), childName, "resource.json");
|
|
10843
10859
|
attempted.push(childJsonPath);
|
|
10844
10860
|
const result = readResourceJson(childJsonPath);
|
|
10845
10861
|
if (result?.success) return {
|
|
@@ -11301,7 +11317,7 @@ var buildLookup = /* @__PURE__ */ __name((columns, dirPath, search) => {
|
|
|
11301
11317
|
}, "buildLookup");
|
|
11302
11318
|
|
|
11303
11319
|
// src/lib/crud/resource/MigrateResourceJson.ts
|
|
11304
|
-
var
|
|
11320
|
+
var import_node_fs11 = require("fs");
|
|
11305
11321
|
var migrateResourceJsonFile = /* @__PURE__ */ __name((jsonPath, opts) => {
|
|
11306
11322
|
let raw;
|
|
11307
11323
|
try {
|
|
@@ -11342,7 +11358,7 @@ var migrateResourceJsonFile = /* @__PURE__ */ __name((jsonPath, opts) => {
|
|
|
11342
11358
|
error: `migrated resource.json (v${from}\u2192v${result.to}) is invalid: ${validation.error.message}`
|
|
11343
11359
|
};
|
|
11344
11360
|
}
|
|
11345
|
-
(0,
|
|
11361
|
+
(0, import_node_fs11.writeFileSync)(jsonPath, serializeResourceJson(withResourceHeader(result.raw)), "utf-8");
|
|
11346
11362
|
return {
|
|
11347
11363
|
status: "migrated",
|
|
11348
11364
|
from: result.from,
|
|
@@ -11409,25 +11425,25 @@ var validateResourceConfig = /* @__PURE__ */ __name((config, opts) => {
|
|
|
11409
11425
|
}, "validateResourceConfig");
|
|
11410
11426
|
|
|
11411
11427
|
// src/lib/crud/loader/index.ts
|
|
11412
|
-
var
|
|
11413
|
-
var
|
|
11428
|
+
var import_node_fs12 = require("fs");
|
|
11429
|
+
var import_node_path21 = require("path");
|
|
11414
11430
|
var loadResourceConfigsFromDir = /* @__PURE__ */ __name(async (dirPath, baseUrl, enumsFile, onResourceDir) => {
|
|
11415
|
-
if (!(0,
|
|
11431
|
+
if (!(0, import_node_fs12.existsSync)(dirPath)) return [];
|
|
11416
11432
|
resourceLoadErrorsRegistry.clear();
|
|
11417
11433
|
resourceLoadReportRegistry.clear();
|
|
11418
11434
|
const enums = loadEnumRegistry(dirPath, enumsFile);
|
|
11419
|
-
const entries = (0,
|
|
11435
|
+
const entries = (0, import_node_fs12.readdirSync)(dirPath, {
|
|
11420
11436
|
withFileTypes: true
|
|
11421
11437
|
});
|
|
11422
11438
|
const dirs = entries.filter((e) => e.isDirectory()).map((e) => e.name);
|
|
11423
11439
|
const configs = [];
|
|
11424
11440
|
for (const dir of dirs) {
|
|
11425
|
-
const basePath = (0,
|
|
11441
|
+
const basePath = (0, import_node_path21.join)(dirPath, dir);
|
|
11426
11442
|
const schemaFile = findModule(basePath, "schema");
|
|
11427
11443
|
const schema = schemaFile ? await importDefault(schemaFile) : void 0;
|
|
11428
11444
|
const hooks = await loadResourceHooks(basePath);
|
|
11429
|
-
const jsonFile = (0,
|
|
11430
|
-
if ((0,
|
|
11445
|
+
const jsonFile = (0, import_node_path21.join)(basePath, "resource.json");
|
|
11446
|
+
if ((0, import_node_fs12.existsSync)(jsonFile)) {
|
|
11431
11447
|
const migration = migrateResourceJsonFile(jsonFile, {
|
|
11432
11448
|
isDev: IS_DEV
|
|
11433
11449
|
});
|
|
@@ -11600,22 +11616,22 @@ var FileSystemResourceConfigLoader = class extends ResourceConfigLoader2 {
|
|
|
11600
11616
|
};
|
|
11601
11617
|
|
|
11602
11618
|
// src/lib/crud/status/status.service.ts
|
|
11603
|
-
var
|
|
11604
|
-
var
|
|
11619
|
+
var import_node_fs13 = require("fs");
|
|
11620
|
+
var import_node_path22 = require("path");
|
|
11605
11621
|
var import_node_url2 = require("url");
|
|
11606
11622
|
var CONNECTION_STRING_PATTERN = /(?:postgresql|postgres|mysql|mongodb|sqlserver|sqlite):\/\/[^\s"')]+/gi;
|
|
11607
11623
|
var stripConnectionStrings = /* @__PURE__ */ __name((message) => message.replace(CONNECTION_STRING_PATTERN, "[REDACTED]"), "stripConnectionStrings");
|
|
11608
11624
|
var getCroutonVersion = /* @__PURE__ */ __name(() => {
|
|
11609
11625
|
try {
|
|
11610
|
-
const startDir = typeof __dirname !== "undefined" ? __dirname : (0,
|
|
11626
|
+
const startDir = typeof __dirname !== "undefined" ? __dirname : (0, import_node_path22.dirname)((0, import_node_url2.fileURLToPath)(importMetaUrl));
|
|
11611
11627
|
let dir = startDir;
|
|
11612
|
-
while (dir !== (0,
|
|
11613
|
-
const pkgPath = (0,
|
|
11614
|
-
if ((0,
|
|
11615
|
-
const pkg = JSON.parse((0,
|
|
11628
|
+
while (dir !== (0, import_node_path22.dirname)(dir)) {
|
|
11629
|
+
const pkgPath = (0, import_node_path22.join)(dir, "package.json");
|
|
11630
|
+
if ((0, import_node_fs13.existsSync)(pkgPath)) {
|
|
11631
|
+
const pkg = JSON.parse((0, import_node_fs13.readFileSync)(pkgPath, "utf-8"));
|
|
11616
11632
|
if (pkg.name === "@ghentcdh/crouton-api") return pkg.version;
|
|
11617
11633
|
}
|
|
11618
|
-
dir = (0,
|
|
11634
|
+
dir = (0, import_node_path22.dirname)(dir);
|
|
11619
11635
|
}
|
|
11620
11636
|
} catch {
|
|
11621
11637
|
}
|
|
@@ -11931,7 +11947,7 @@ var createStatusController = /* @__PURE__ */ __name((enumRegistry, translationRe
|
|
|
11931
11947
|
}, "createStatusController");
|
|
11932
11948
|
|
|
11933
11949
|
// src/lib/crouton-api.module.ts
|
|
11934
|
-
var
|
|
11950
|
+
var import_node_path23 = require("path");
|
|
11935
11951
|
var import_node_url3 = require("url");
|
|
11936
11952
|
function _ts_decorate11(decorators, target, key, desc2) {
|
|
11937
11953
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
@@ -11970,7 +11986,7 @@ var CroutonApiModule = class _CroutonApiModule {
|
|
|
11970
11986
|
const dataSourceRegistry = new DataSourceRegistry(dataSources);
|
|
11971
11987
|
const guardRegistry = new SecurityGuardRegistry(security?.guards ?? {});
|
|
11972
11988
|
const moduleDefaultSecurity = security?.default;
|
|
11973
|
-
const startDir = typeof __dirname !== "undefined" ? __dirname : (0,
|
|
11989
|
+
const startDir = typeof __dirname !== "undefined" ? __dirname : (0, import_node_path23.dirname)((0, import_node_url3.fileURLToPath)(importMetaUrl));
|
|
11974
11990
|
const enumRegistry = loadEnumRegistry(startDir, config.enumsFile);
|
|
11975
11991
|
const validConfigs = [];
|
|
11976
11992
|
for (const c of configs) {
|
|
@@ -12035,7 +12051,7 @@ var CroutonApiModule = class _CroutonApiModule {
|
|
|
12035
12051
|
const configRegistry = new ResourceConfigRegistry(loader, validConfigs);
|
|
12036
12052
|
let translationRegistry;
|
|
12037
12053
|
if (config.i18n) {
|
|
12038
|
-
const translationsDir = (0,
|
|
12054
|
+
const translationsDir = (0, import_node_path23.join)(config.configDir, config.i18n.translationsDir);
|
|
12039
12055
|
translationRegistry = new TranslationRegistry2(translationsDir, config.i18n);
|
|
12040
12056
|
configRegistry.setTranslationRegistry(translationRegistry);
|
|
12041
12057
|
}
|