@velastack/patterns 0.0.48 → 0.0.49

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.
@@ -0,0 +1,32 @@
1
+ //#region src/parse/env.preview.ts
2
+ function e(e) {
3
+ let t = [];
4
+ return e.features.auth && t.push({
5
+ id: "users_preview",
6
+ name: "users",
7
+ type: "auth",
8
+ fields: [{
9
+ name: "email",
10
+ type: "email"
11
+ }, {
12
+ name: "name",
13
+ type: "text"
14
+ }]
15
+ }), e.features.teams && t.push({
16
+ id: "teams_preview",
17
+ name: "teams",
18
+ type: "base",
19
+ fields: [{
20
+ name: "name",
21
+ type: "text"
22
+ }, {
23
+ name: "owner",
24
+ type: "relation",
25
+ collectionId: "users_preview"
26
+ }]
27
+ }), t;
28
+ }
29
+ //#endregion
30
+ export { e as getPreviewCollections };
31
+
32
+ //# sourceMappingURL=env.preview-DoY1CJwL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.preview-DoY1CJwL.js","names":[],"sources":["../../src/parse/env.preview.ts"],"sourcesContent":["import type { Options } from \"../core/types\";\nimport type { Collection } from \"./types\";\n\nexport function getPreviewCollections(\n options: Pick<Options, \"features\">,\n): Collection[] {\n const collections: Collection[] = [];\n if (options.features.auth) {\n collections.push({\n id: \"users_preview\",\n name: \"users\",\n type: \"auth\",\n fields: [\n { name: \"email\", type: \"email\" },\n { name: \"name\", type: \"text\" },\n ],\n });\n }\n if (options.features.teams) {\n collections.push({\n id: \"teams_preview\",\n name: \"teams\",\n type: \"base\",\n fields: [\n { name: \"name\", type: \"text\" },\n { name: \"owner\", type: \"relation\", collectionId: \"users_preview\" },\n ],\n });\n }\n return collections;\n}\n"],"mappings":";AAGA,SAAgB,EACd,GACc;CACd,IAAM,IAA4B,EAAE;AAuBpC,QAtBI,EAAQ,SAAS,QACnB,EAAY,KAAK;EACf,IAAI;EACJ,MAAM;EACN,MAAM;EACN,QAAQ,CACN;GAAE,MAAM;GAAS,MAAM;GAAS,EAChC;GAAE,MAAM;GAAQ,MAAM;GAAQ,CAC/B;EACF,CAAC,EAEA,EAAQ,SAAS,SACnB,EAAY,KAAK;EACf,IAAI;EACJ,MAAM;EACN,MAAM;EACN,QAAQ,CACN;GAAE,MAAM;GAAQ,MAAM;GAAQ,EAC9B;GAAE,MAAM;GAAS,MAAM;GAAY,cAAc;GAAiB,CACnE;EACF,CAAC,EAEG"}
package/dist/index.js CHANGED
@@ -26,7 +26,7 @@ var ue = Object.create, de = Object.defineProperty, fe = Object.getOwnPropertyDe
26
26
  throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
27
27
  }), be = {
28
28
  name: "@velastack/patterns",
29
- version: "0.0.48",
29
+ version: "0.0.49",
30
30
  description: "Registry of VelaStack patterns: generators and modifications applied to SvelteKit projects by the VelaStack CLI.",
31
31
  type: "module",
32
32
  private: !1,
@@ -1282,36 +1282,40 @@ function M(e, t, n, r, i, a) {
1282
1282
  }
1283
1283
  function Ot(t, n, r, i, a) {
1284
1284
  let o = et(t), { type: s, required: c, selectOptions: l } = n, u = ht(i), d = gt(i), f = _t(i), p = u.map((e) => k.default.singular(e));
1285
- if (a.features.auth && s === "current_user" && d.users) {
1286
- let e = M(t, "users", r, d, f, a);
1285
+ if (s === "current_user") {
1286
+ if (!a.features.auth) throw new e("Field type \"current_user\" requires the auth feature. Run `vela enable auth` to enable it.");
1287
+ if (!d.users) throw new e("Field type \"current_user\" requires a \"users\" collection but none was found.");
1288
+ let n = M(t, "users", r, d, f, a);
1287
1289
  return {
1288
1290
  type: "relation",
1289
1291
  name: t,
1290
1292
  title: o,
1291
1293
  required: c,
1292
- collectionId: e.collectionId,
1294
+ collectionId: n.collectionId,
1293
1295
  maxSelect: 1,
1294
- displayField: e.displayField,
1295
- relatedModel: e.relatedModel,
1296
- singularRelationName: e.singularRelationName,
1297
- pluralRelationName: e.pluralRelationName,
1296
+ displayField: n.displayField,
1297
+ relatedModel: n.relatedModel,
1298
+ singularRelationName: n.singularRelationName,
1299
+ pluralRelationName: n.pluralRelationName,
1298
1300
  isCurrentUser: !0,
1299
1301
  isCurrentTeam: !1
1300
1302
  };
1301
1303
  }
1302
- if (a.features.teams && s === "current_team" && d.teams) {
1303
- let e = M(t, "teams", r, d, f, a);
1304
+ if (s === "current_team") {
1305
+ if (!a.features.teams) throw new e("Field type \"current_team\" requires the teams feature. Run `vela enable teams` to enable it.");
1306
+ if (!d.teams) throw new e("Field type \"current_team\" requires a \"teams\" collection but none was found.");
1307
+ let n = M(t, "teams", r, d, f, a);
1304
1308
  return {
1305
1309
  type: "relation",
1306
1310
  name: t,
1307
1311
  title: o,
1308
1312
  required: c,
1309
- collectionId: e.collectionId,
1313
+ collectionId: n.collectionId,
1310
1314
  maxSelect: 1,
1311
- displayField: e.displayField,
1312
- relatedModel: e.relatedModel,
1313
- singularRelationName: e.singularRelationName,
1314
- pluralRelationName: e.pluralRelationName,
1315
+ displayField: n.displayField,
1316
+ relatedModel: n.relatedModel,
1317
+ singularRelationName: n.singularRelationName,
1318
+ pluralRelationName: n.pluralRelationName,
1315
1319
  isCurrentUser: !1,
1316
1320
  isCurrentTeam: !0
1317
1321
  };
@@ -1914,7 +1918,7 @@ async function Kt(e) {
1914
1918
  let { getCollections: e } = await import("./chunks/env.runtime-D46GCIKe.js");
1915
1919
  return await e();
1916
1920
  }
1917
- let { getPreviewCollections: t } = await import("./chunks/env.preview-u7rnWI2E.js");
1921
+ let { getPreviewCollections: t } = await import("./chunks/env.preview-DoY1CJwL.js");
1918
1922
  return t(e);
1919
1923
  }
1920
1924
  async function z(t, n, r) {