@dbml/parse 8.1.0 → 8.2.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) {
@@ -2478,6 +2478,11 @@ var NodeMetadata = class r {
2478
2478
  return r instanceof PrefixExpressionNode ? r.op?.value : void 0;
2479
2479
  }
2480
2480
  }
2481
+ active(r) {
2482
+ if (!(this.declaration instanceof ElementDeclarationNode)) return !0;
2483
+ let M = getBody(this.declaration)[0];
2484
+ return M ? !r.nodeSettings(M).getFiltered(UNHANDLED)?.[SettingName.Inactive]?.length : !0;
2485
+ }
2481
2486
  leftToken() {
2482
2487
  if (this.declaration instanceof ElementDeclarationNode) {
2483
2488
  let r = getBody(this.declaration)[0];
@@ -8127,7 +8132,7 @@ var RefBinder = class {
8127
8132
  let r = aggregateSettingList(B.args[0]).getValue(), j = r.delete?.at(0)?.value;
8128
8133
  this.ref.onDelete = j instanceof IdentifierStreamNode ? extractStringFromIdentifierStream(j) : extractVariableFromExpression(j);
8129
8134
  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;
8135
+ 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
8136
  }
8132
8137
  return [];
8133
8138
  }
@@ -10494,6 +10499,11 @@ function validateFieldSettings(r) {
10494
10499
  isValidColor(r.value) || N.push(new CompileError(CompileErrorCode.INVALID_REF_SETTING_VALUE, "'color' must be a color literal", r));
10495
10500
  }), I[r] = j;
10496
10501
  break;
10502
+ case SettingName.Inactive:
10503
+ j.length > 1 && N.push(...j.map((r) => new CompileError(CompileErrorCode.DUPLICATE_REF_SETTING, "'inactive' can only appear once", r))), j.forEach((r) => {
10504
+ r.value && N.push(new CompileError(CompileErrorCode.INVALID_REF_SETTING_VALUE, "'inactive' cannot have a value", r));
10505
+ }), I[r] = j;
10506
+ break;
10497
10507
  default: j.forEach((j) => N.push(new CompileError(CompileErrorCode.UNKNOWN_REF_SETTING, `Unknown ref setting '${r}'`, j)));
10498
10508
  }
10499
10509
  return new Report(I, N);
@@ -12619,7 +12629,13 @@ function suggestAttributeName(r, j, M) {
12619
12629
  insertTextRules: CompletionItemInsertTextRule.KeepWhitespace,
12620
12630
  range: void 0
12621
12631
  }))] };
12622
- case ScopeKind.REF: return { suggestions: [
12632
+ case ScopeKind.REF: return { suggestions: [{
12633
+ label: SettingName.Inactive,
12634
+ insertText: SettingName.Inactive,
12635
+ kind: CompletionItemKind.Property,
12636
+ insertTextRules: CompletionItemInsertTextRule.KeepWhitespace,
12637
+ range: void 0
12638
+ }, ...[
12623
12639
  SettingName.Update,
12624
12640
  SettingName.Delete,
12625
12641
  SettingName.Color
@@ -12629,7 +12645,7 @@ function suggestAttributeName(r, j, M) {
12629
12645
  kind: CompletionItemKind.Property,
12630
12646
  insertTextRules: CompletionItemInsertTextRule.KeepWhitespace,
12631
12647
  range: void 0
12632
- })) };
12648
+ }))] };
12633
12649
  case ScopeKind.CHECKS: return { suggestions: [SettingName.Name].map((r) => ({
12634
12650
  label: r,
12635
12651
  insertText: `${r}: `,
@@ -13032,7 +13048,8 @@ var dbmlMonarchTokensProvider = {
13032
13048
  "tables",
13033
13049
  "tablegroups",
13034
13050
  "notes",
13035
- "schemas"
13051
+ "schemas",
13052
+ "inactive"
13036
13053
  ],
13037
13054
  symbols: /[=><!~?:&|+\-/^%]+/,
13038
13055
  escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
@@ -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[];
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.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": "a4f2932e24a3d54b7c11d12710cd51e762a8442f"
50
50
  }