@malloydata/malloyyo 0.2.36 → 0.2.38

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.
Files changed (2) hide show
  1. package/dist/index.js +35 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -558,6 +558,9 @@ function stripScalarArrayValue(parent, groups) {
558
558
  if (!isScalarArray(parent)) return groups;
559
559
  return { ...groups, dimensions: groups.dimensions.filter((f) => f.name !== "value") };
560
560
  }
561
+ function rawDef(structDefFields, name) {
562
+ return structDefFields.find((x) => (x.as ?? x.name) === name);
563
+ }
561
564
  function fieldKind(af, structDefFields) {
562
565
  const raw = structDefFields.find((x) => x.name === af.name);
563
566
  const et = raw?.expressionType;
@@ -617,6 +620,7 @@ function walkFields(fields, structDefFields, depth, ctx, anon) {
617
620
  const mLoc = f.location;
618
621
  const local = isLocal(mLoc, ctx.rootUri);
619
622
  const loc = local ? toLoc(mLoc) : void 0;
623
+ const access = rawDef(structDefFields, f.name)?.accessModifier;
620
624
  if (f.isExploreField()) {
621
625
  const ef = f;
622
626
  const cls = classifyJoinTarget(ef, ctx.knownSources);
@@ -630,6 +634,7 @@ function walkFields(fields, structDefFields, depth, ctx, anon) {
630
634
  if (needsQuote(f.name)) join5.must_quote = true;
631
635
  if (annotations.length > 0) join5.annotations = annotations;
632
636
  if (loc) join5.location = loc;
637
+ if (access) join5.access = access;
633
638
  const synthetic = isScalarArray(ef) || isRepeatedRecord(ef) || isAnonymousRecord(ef);
634
639
  if (isScalarArray(ef)) join5.column_shape = "scalar_array";
635
640
  else if (isRepeatedRecord(ef)) join5.column_shape = "record_array";
@@ -653,6 +658,7 @@ function walkFields(fields, structDefFields, depth, ctx, anon) {
653
658
  if (needsQuote(f.name)) view.must_quote = true;
654
659
  if (annotations.length > 0) view.annotations = annotations;
655
660
  if (loc) view.location = loc;
661
+ if (access) view.access = access;
656
662
  if (mLoc) {
657
663
  const body = sliceSource(ctx.readSource(mLoc.url), mLoc);
658
664
  if (body) view.body = body;
@@ -669,6 +675,7 @@ function walkFields(fields, structDefFields, depth, ctx, anon) {
669
675
  if (expr && expr !== f.name) info.expression = expr;
670
676
  if (annotations.length > 0) info.annotations = annotations;
671
677
  if (loc) info.location = loc;
678
+ if (access) info.access = access;
672
679
  if (fieldKind(af, structDefFields) === "measure") groups.measures.push(info);
673
680
  else groups.dimensions.push(info);
674
681
  }
@@ -840,6 +847,31 @@ async function compile(runtime, entry, opts = {}) {
840
847
  return { ok: false, problems: [errorProblem(e, entry.href)] };
841
848
  }
842
849
  }
850
+ var isPublic = (m) => m.access === void 0;
851
+ function publicGroups(g) {
852
+ return {
853
+ dimensions: g.dimensions.filter(isPublic),
854
+ measures: g.measures.filter(isPublic),
855
+ views: g.views.filter(isPublic),
856
+ joins: g.joins.filter(isPublic).map(
857
+ (j) => j.fields ? { ...j, fields: publicGroups(j.fields) } : j
858
+ )
859
+ };
860
+ }
861
+ function publicSource(s) {
862
+ const groups = publicGroups(s);
863
+ const out = { ...s, ...groups };
864
+ if (out.primary_key && !groups.dimensions.some((d) => d.name === out.primary_key)) {
865
+ out.primary_key = null;
866
+ }
867
+ if (s.anon_srcs) out.anon_srcs = s.anon_srcs.map(publicSource);
868
+ return out;
869
+ }
870
+ function publicOnlyModel(m) {
871
+ const sources = {};
872
+ for (const [name, s] of Object.entries(m.sources)) sources[name] = publicSource(s);
873
+ return { ...m, sources };
874
+ }
843
875
  var EMPTY_GROUPS = { dimensions: [], measures: [], views: [], joins: [] };
844
876
  var seg = (m) => m.must_quote ? `\`${m.name}\`` : m.name;
845
877
  var barePath = (prefix, j) => prefix ? `${prefix}.${j.name}` : j.name;
@@ -986,7 +1018,8 @@ function emitSourceJoin(j, bare, quoted, anonScope, fans, namedOnPath, anonOnPat
986
1018
  );
987
1019
  }
988
1020
  }
989
- function buildSourceDescribe(model, name) {
1021
+ function buildSourceDescribe(compiled, name) {
1022
+ const model = publicOnlyModel(compiled);
990
1023
  const root = model.sources[name];
991
1024
  if (!root) return void 0;
992
1025
  const ctx = { model, joins: /* @__PURE__ */ Object.create(null), map: /* @__PURE__ */ Object.create(null) };
@@ -2847,7 +2880,7 @@ function clearCreds(url6) {
2847
2880
  }
2848
2881
 
2849
2882
  // package.json
2850
- var version = "0.2.36";
2883
+ var version = "0.2.38";
2851
2884
 
2852
2885
  // src/http.ts
2853
2886
  var USER_AGENT = `malloyyo/${version}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloyyo",
3
- "version": "0.2.36",
3
+ "version": "0.2.38",
4
4
  "description": "Publish Malloy models to a Malloyyo instance",
5
5
  "license": "MIT",
6
6
  "repository": {