@dbml/parse 8.1.0 → 8.2.1-alpha.0

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.
@@ -43,7 +43,7 @@ var Report = class r {
43
43
  let ElementKind = /* @__PURE__ */ function(r) {
44
44
  return r.Table = "table", r.Enum = "enum", r.Ref = "ref", r.Note = "note", r.Project = "project", r.Indexes = "indexes", r.TableGroup = "tablegroup", r.TablePartial = "tablepartial", r.Checks = "checks", r.Records = "records", r.DiagramView = "diagramview", r.DiagramViewTables = "tables", r.DiagramViewNotes = "notes", r.DiagramViewTableGroups = "tablegroups", r.DiagramViewSchemas = "schemas", r;
45
45
  }({}), SettingName = /* @__PURE__ */ function(r) {
46
- return r.Color = "color", r.HeaderColor = "headercolor", r.Note = "note", r.PK = "pk", r.PrimaryKey = "primary key", r.Unique = "unique", r.Ref = "ref", r.NotNull = "not null", r.Null = "null", r.Increment = "increment", r.Default = "default", r.Name = "name", r.Type = "type", r.Check = "check", r.Update = "update", r.Delete = "delete", r;
46
+ return r.Color = "color", r.HeaderColor = "headercolor", r.Note = "note", r.PK = "pk", r.PrimaryKey = "primary key", r.Unique = "unique", r.Ref = "ref", r.NotNull = "not null", r.Null = "null", r.Increment = "increment", r.Default = "default", r.Name = "name", r.Type = "type", r.Check = "check", r.Update = "update", r.Delete = "delete", r.Inactive = "inactive", r;
47
47
  }({});
48
48
  var _freeGlobal_default = typeof global == "object" && global && global.Object === Object && global, freeSelf = typeof self == "object" && self && self.Object === Object && self, _root_default = _freeGlobal_default || freeSelf || Function("return this")(), _Symbol_default = _root_default.Symbol, objectProto$3 = Object.prototype, hasOwnProperty$12 = objectProto$3.hasOwnProperty, nativeObjectToString$1 = objectProto$3.toString, symToStringTag$1 = _Symbol_default ? _Symbol_default.toStringTag : void 0;
49
49
  function getRawTag(r) {
@@ -1440,6 +1440,13 @@ function isEqualTupleOperands(r) {
1440
1440
  function isValidIndexName(r) {
1441
1441
  return r instanceof PrimaryExpressionNode && r.expression instanceof VariableNode || r instanceof FunctionExpressionNode;
1442
1442
  }
1443
+ function getRightmostVariable(r) {
1444
+ if (isExpressionAVariableNode(r)) return r;
1445
+ if (isAccessExpression(r)) {
1446
+ let j = r.rightExpression;
1447
+ if (j && isExpressionAVariableNode(j)) return j;
1448
+ }
1449
+ }
1443
1450
  function isTerminalAccessFragment(r) {
1444
1451
  let j = r.parentNode;
1445
1452
  return !isAccessExpression(j) || j.rightExpression !== r ? !1 : !(isAccessExpression(j.parentNode) && j.parentNode.leftExpression === j);
@@ -2478,6 +2485,11 @@ var NodeMetadata = class r {
2478
2485
  return r instanceof PrefixExpressionNode ? r.op?.value : void 0;
2479
2486
  }
2480
2487
  }
2488
+ active(r) {
2489
+ if (!(this.declaration instanceof ElementDeclarationNode)) return !0;
2490
+ let M = getBody(this.declaration)[0];
2491
+ return M ? !r.nodeSettings(M).getFiltered(UNHANDLED)?.[SettingName.Inactive]?.length : !0;
2492
+ }
2481
2493
  leftToken() {
2482
2494
  if (this.declaration instanceof ElementDeclarationNode) {
2483
2495
  let r = getBody(this.declaration)[0];
@@ -2893,24 +2905,24 @@ var DiagramViewBinder = class {
2893
2905
  let P = [];
2894
2906
  for (let M of r.body) {
2895
2907
  if (!(M instanceof FunctionApplicationNode)) continue;
2896
- let r = M.callee && this.compiler.nodeReferee(M.callee).getFiltered(UNHANDLED);
2897
- if (r?.declaration instanceof ElementDeclarationNode) {
2898
- let j = destructureComplexVariable(r.declaration.name) ?? [];
2899
- if (j.length > 0) {
2900
- let r = j[j.length - 1], M = j.length > 1 ? j.slice(0, -1).join(".") : DEFAULT_SCHEMA_NAME;
2908
+ let r = M.callee && getRightmostVariable(M.callee), N = r && this.compiler.nodeReferee(r).getFiltered(UNHANDLED);
2909
+ if (N?.declaration instanceof ElementDeclarationNode) {
2910
+ let r = destructureComplexVariable(N.declaration.name) ?? [];
2911
+ if (r.length > 0) {
2912
+ let j = r[r.length - 1], M = r.length > 1 ? r.slice(0, -1).join(".") : DEFAULT_SCHEMA_NAME;
2901
2913
  P.push({
2902
- name: r,
2914
+ name: j,
2903
2915
  schemaName: M
2904
2916
  });
2905
2917
  continue;
2906
2918
  }
2907
2919
  }
2908
- let N = destructureComplexVariable(M.callee) ?? [];
2909
- if (N.length === 0) continue;
2910
- let F = N[N.length - 1], I = N.length > 1 ? N[0] : DEFAULT_SCHEMA_NAME;
2920
+ let F = destructureComplexVariable(M.callee) ?? [];
2921
+ if (F.length === 0) continue;
2922
+ let I = F[F.length - 1], L = F.length > 1 ? F[0] : DEFAULT_SCHEMA_NAME;
2911
2923
  P.push({
2912
- name: F,
2913
- schemaName: I
2924
+ name: I,
2925
+ schemaName: L
2914
2926
  });
2915
2927
  }
2916
2928
  switch (M) {
@@ -8127,7 +8139,7 @@ var RefBinder = class {
8127
8139
  let r = aggregateSettingList(B.args[0]).getValue(), j = r.delete?.at(0)?.value;
8128
8140
  this.ref.onDelete = j instanceof IdentifierStreamNode ? extractStringFromIdentifierStream(j) : extractVariableFromExpression(j);
8129
8141
  let M = r.update?.at(0)?.value;
8130
- this.ref.onUpdate = M instanceof IdentifierStreamNode ? extractStringFromIdentifierStream(M) : extractVariableFromExpression(M), this.ref.color = r.color?.length ? extractColor(r.color?.at(0)?.value) : void 0;
8142
+ this.ref.onUpdate = M instanceof IdentifierStreamNode ? extractStringFromIdentifierStream(M) : extractVariableFromExpression(M), this.ref.color = r.color?.length ? extractColor(r.color?.at(0)?.value) : void 0, this.ref.inactive = r.inactive?.length ? !0 : void 0;
8131
8143
  }
8132
8144
  return [];
8133
8145
  }
@@ -10494,6 +10506,11 @@ function validateFieldSettings(r) {
10494
10506
  isValidColor(r.value) || N.push(new CompileError(CompileErrorCode.INVALID_REF_SETTING_VALUE, "'color' must be a color literal", r));
10495
10507
  }), I[r] = j;
10496
10508
  break;
10509
+ case SettingName.Inactive:
10510
+ j.length > 1 && N.push(...j.map((r) => new CompileError(CompileErrorCode.DUPLICATE_REF_SETTING, "'inactive' can only appear once", r))), j.forEach((r) => {
10511
+ r.value && N.push(new CompileError(CompileErrorCode.INVALID_REF_SETTING_VALUE, "'inactive' cannot have a value", r));
10512
+ }), I[r] = j;
10513
+ break;
10497
10514
  default: j.forEach((j) => N.push(new CompileError(CompileErrorCode.UNKNOWN_REF_SETTING, `Unknown ref setting '${r}'`, j)));
10498
10515
  }
10499
10516
  return new Report(I, N);
@@ -12619,7 +12636,13 @@ function suggestAttributeName(r, j, M) {
12619
12636
  insertTextRules: CompletionItemInsertTextRule.KeepWhitespace,
12620
12637
  range: void 0
12621
12638
  }))] };
12622
- case ScopeKind.REF: return { suggestions: [
12639
+ case ScopeKind.REF: return { suggestions: [{
12640
+ label: SettingName.Inactive,
12641
+ insertText: SettingName.Inactive,
12642
+ kind: CompletionItemKind.Property,
12643
+ insertTextRules: CompletionItemInsertTextRule.KeepWhitespace,
12644
+ range: void 0
12645
+ }, ...[
12623
12646
  SettingName.Update,
12624
12647
  SettingName.Delete,
12625
12648
  SettingName.Color
@@ -12629,7 +12652,7 @@ function suggestAttributeName(r, j, M) {
12629
12652
  kind: CompletionItemKind.Property,
12630
12653
  insertTextRules: CompletionItemInsertTextRule.KeepWhitespace,
12631
12654
  range: void 0
12632
- })) };
12655
+ }))] };
12633
12656
  case ScopeKind.CHECKS: return { suggestions: [SettingName.Name].map((r) => ({
12634
12657
  label: r,
12635
12658
  insertText: `${r}: `,
@@ -13032,7 +13055,8 @@ var dbmlMonarchTokensProvider = {
13032
13055
  "tables",
13033
13056
  "tablegroups",
13034
13057
  "notes",
13035
- "schemas"
13058
+ "schemas",
13059
+ "inactive"
13036
13060
  ],
13037
13061
  symbols: /[=><!~?:&|+\-/^%]+/,
13038
13062
  escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
@@ -14444,13 +14468,6 @@ function symbolAliases(r) {
14444
14468
  let j = r.originalSymbol;
14445
14469
  return allVisibleMembers(this).map((M) => M.filter((M) => M instanceof AliasSymbol && M.originalSymbol === j && M !== r));
14446
14470
  }
14447
- function getRightmostVariable(r) {
14448
- if (isExpressionAVariableNode(r)) return r;
14449
- if (isAccessExpression(r)) {
14450
- let j = r.rightExpression;
14451
- if (j && isExpressionAVariableNode(j)) return j;
14452
- }
14453
- }
14454
14471
  function resolutionIndex() {
14455
14472
  let r = /* @__PURE__ */ new Map(), M = /* @__PURE__ */ new Map(), N = this.parseProject();
14456
14473
  this.bindProject();
@@ -31,5 +31,6 @@ export declare enum SettingName {
31
31
  Type = "type",
32
32
  Check = "check",
33
33
  Update = "update",
34
- Delete = "delete"
34
+ Delete = "delete",
35
+ Inactive = "inactive"
35
36
  }
@@ -157,6 +157,7 @@ export interface Ref {
157
157
  color?: string;
158
158
  onDelete?: string;
159
159
  onUpdate?: string;
160
+ inactive?: boolean;
160
161
  token: TokenPosition;
161
162
  }
162
163
  export type RefEndpointPair = [RefEndpoint, RefEndpoint];
@@ -37,6 +37,7 @@ export declare class RefMetadata extends NodeMetadata {
37
37
  leftTable(compiler: Compiler): TableSymbol | undefined;
38
38
  rightTable(compiler: Compiler): TableSymbol | undefined;
39
39
  op(_compiler: Compiler): '>' | '<' | '-' | '<>' | undefined;
40
+ active(compiler: Compiler): boolean;
40
41
  leftToken(): SyntaxNode;
41
42
  rightToken(): SyntaxNode;
42
43
  owners(compiler: Compiler): NodeSymbol[];
@@ -99,5 +99,6 @@ export declare function isEqualTupleOperands(value: InfixExpressionNode): boolea
99
99
  export declare function isValidIndexName(value?: SyntaxNode): value is (PrimaryExpressionNode & {
100
100
  expression: VariableNode;
101
101
  }) | FunctionExpressionNode;
102
+ export declare function getRightmostVariable(node: SyntaxNode): SyntaxNode | undefined;
102
103
  export declare function isTerminalAccessFragment(node: SyntaxNode): boolean;
103
104
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@dbml/parse",
4
- "version": "8.1.0",
4
+ "version": "8.2.1-alpha.0",
5
5
  "description": "DBML parser v2",
6
6
  "author": "Holistics <dev@holistics.io>",
7
7
  "license": "Apache-2.0",
@@ -46,5 +46,5 @@
46
46
  "engines": {
47
47
  "node": ">=18"
48
48
  },
49
- "gitHead": "deb659b7650a4204ad0a82e9d4e5e94f1d565465"
49
+ "gitHead": "2132b2eb2c1c5e0d9bb0efd9a617becd44c39032"
50
50
  }