@zenstackhq/language 3.0.0 → 3.1.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.
package/dist/index.cjs CHANGED
@@ -7021,6 +7021,20 @@ var FunctionInvocationValidator = class {
7021
7021
  });
7022
7022
  }
7023
7023
  }
7024
+ if ([
7025
+ "uuid",
7026
+ "ulid",
7027
+ "cuid",
7028
+ "nanoid"
7029
+ ].includes(funcDecl.name)) {
7030
+ const formatParamIdx = funcDecl.params.findIndex((param) => param.name === "format");
7031
+ const formatArg = getLiteral(expr.args[formatParamIdx]?.value);
7032
+ if (formatArg !== void 0 && !/(?<!\\)%s/g.test(formatArg)) {
7033
+ accept("error", 'argument must include "%s"', {
7034
+ node: expr.args[formatParamIdx]
7035
+ });
7036
+ }
7037
+ }
7024
7038
  const checker = invocationCheckers.get(expr.function.$refText);
7025
7039
  if (checker) {
7026
7040
  checker.value.call(this, expr, accept);
@@ -7098,6 +7112,39 @@ var FunctionInvocationValidator = class {
7098
7112
  }
7099
7113
  return true;
7100
7114
  }
7115
+ _checkUuid(expr, accept) {
7116
+ const versionArg = expr.args[0]?.value;
7117
+ if (versionArg) {
7118
+ const version = getLiteral(versionArg);
7119
+ if (version !== void 0 && version !== 4 && version !== 7) {
7120
+ accept("error", "first argument must be 4 or 7", {
7121
+ node: expr.args[0]
7122
+ });
7123
+ }
7124
+ }
7125
+ }
7126
+ _checkCuid(expr, accept) {
7127
+ const versionArg = expr.args[0]?.value;
7128
+ if (versionArg) {
7129
+ const version = getLiteral(versionArg);
7130
+ if (version !== void 0 && version !== 1 && version !== 2) {
7131
+ accept("error", "first argument must be 1 or 2", {
7132
+ node: expr.args[0]
7133
+ });
7134
+ }
7135
+ }
7136
+ }
7137
+ _checkNanoid(expr, accept) {
7138
+ const lengthArg = expr.args[0]?.value;
7139
+ if (lengthArg) {
7140
+ const length = getLiteral(lengthArg);
7141
+ if (length !== void 0 && length <= 0) {
7142
+ accept("error", "first argument must be a positive number", {
7143
+ node: expr.args[0]
7144
+ });
7145
+ }
7146
+ }
7147
+ }
7101
7148
  _checkAuth(expr, accept) {
7102
7149
  if (!expr.$resolvedType) {
7103
7150
  accept("error", 'cannot resolve `auth()` - make sure you have a model or type with `@auth` attribute or named "User"', {
@@ -7214,6 +7261,33 @@ var FunctionInvocationValidator = class {
7214
7261
  }
7215
7262
  }
7216
7263
  };
7264
+ _ts_decorate2([
7265
+ func("uuid"),
7266
+ _ts_metadata2("design:type", Function),
7267
+ _ts_metadata2("design:paramtypes", [
7268
+ typeof InvocationExpr === "undefined" ? Object : InvocationExpr,
7269
+ typeof ValidationAcceptor === "undefined" ? Object : ValidationAcceptor
7270
+ ]),
7271
+ _ts_metadata2("design:returntype", void 0)
7272
+ ], FunctionInvocationValidator.prototype, "_checkUuid", null);
7273
+ _ts_decorate2([
7274
+ func("cuid"),
7275
+ _ts_metadata2("design:type", Function),
7276
+ _ts_metadata2("design:paramtypes", [
7277
+ typeof InvocationExpr === "undefined" ? Object : InvocationExpr,
7278
+ typeof ValidationAcceptor === "undefined" ? Object : ValidationAcceptor
7279
+ ]),
7280
+ _ts_metadata2("design:returntype", void 0)
7281
+ ], FunctionInvocationValidator.prototype, "_checkCuid", null);
7282
+ _ts_decorate2([
7283
+ func("nanoid"),
7284
+ _ts_metadata2("design:type", Function),
7285
+ _ts_metadata2("design:paramtypes", [
7286
+ typeof InvocationExpr === "undefined" ? Object : InvocationExpr,
7287
+ typeof ValidationAcceptor === "undefined" ? Object : ValidationAcceptor
7288
+ ]),
7289
+ _ts_metadata2("design:returntype", void 0)
7290
+ ], FunctionInvocationValidator.prototype, "_checkNanoid", null);
7217
7291
  _ts_decorate2([
7218
7292
  func("auth"),
7219
7293
  _ts_metadata2("design:type", Function),