@atscript/typescript 0.1.98 → 0.1.99

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/cli.cjs CHANGED
@@ -2242,8 +2242,28 @@ var JsRenderer = class extends BaseRenderer {
2242
2242
  emitArgValue(aSpec, argToken) {
2243
2243
  if (aSpec.type === "ref") return this.emitRefValue(argToken.text);
2244
2244
  if (aSpec.type === "query" && argToken.queryNode) return this.emitQueryTree(argToken.queryNode);
2245
+ if (aSpec.type === "expr" && argToken.exprNode) return this.emitExprNode(argToken.exprNode.expression);
2246
+ if (aSpec.type === "order" && argToken.orderNode) return `[${argToken.orderNode.items.map((item) => `{ ref: ${this.emitQueryFieldRef(item.ref)}${item.desc ? ", desc: true" : ""} }`).join(", ")}]`;
2245
2247
  return aSpec.type === "string" ? `"${escapeQuotes(argToken.text)}"` : argToken.text;
2246
2248
  }
2249
+ emitExprNode(node) {
2250
+ switch (node.entity) {
2251
+ case "query-expr-number": return String(node.value);
2252
+ case "query-expr-binary": {
2253
+ const { op, left, right } = node;
2254
+ return `{ op: "${op}", args: [${this.emitExprNode(left)}, ${this.emitExprNode(right)}] }`;
2255
+ }
2256
+ case "query-expr-unary": {
2257
+ const { op, operand } = node;
2258
+ return `{ op: "${op}", args: [${this.emitExprNode(operand)}] }`;
2259
+ }
2260
+ case "query-expr-call": {
2261
+ const { fn, args } = node;
2262
+ return `{ op: "${fn}", args: [${args.map((a) => this.emitExprNode(a)).join(", ")}] }`;
2263
+ }
2264
+ default: return this.emitQueryFieldRef(node);
2265
+ }
2266
+ }
2247
2267
  emitQueryTree(queryNode) {
2248
2268
  return this.emitQueryExpr(queryNode.expression);
2249
2269
  }
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
- const require_plugin = require('./plugin-dcd-XTR-.cjs');
2
+ const require_plugin = require('./plugin-BG_encHp.cjs');
3
3
 
4
4
  exports.default = require_plugin.tsPlugin;
5
5
  exports.tsPlugin = require_plugin.tsPlugin;
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { t as tsPlugin } from "./plugin-BDjZ2rOT.mjs";
1
+ import { t as tsPlugin } from "./plugin-CVvPRB8q.mjs";
2
2
 
3
3
  export { tsPlugin as default, tsPlugin };
@@ -1325,8 +1325,28 @@ var JsRenderer = class extends BaseRenderer {
1325
1325
  emitArgValue(aSpec, argToken) {
1326
1326
  if (aSpec.type === "ref") return this.emitRefValue(argToken.text);
1327
1327
  if (aSpec.type === "query" && argToken.queryNode) return this.emitQueryTree(argToken.queryNode);
1328
+ if (aSpec.type === "expr" && argToken.exprNode) return this.emitExprNode(argToken.exprNode.expression);
1329
+ if (aSpec.type === "order" && argToken.orderNode) return `[${argToken.orderNode.items.map((item) => `{ ref: ${this.emitQueryFieldRef(item.ref)}${item.desc ? ", desc: true" : ""} }`).join(", ")}]`;
1328
1330
  return aSpec.type === "string" ? `"${escapeQuotes(argToken.text)}"` : argToken.text;
1329
1331
  }
1332
+ emitExprNode(node) {
1333
+ switch (node.entity) {
1334
+ case "query-expr-number": return String(node.value);
1335
+ case "query-expr-binary": {
1336
+ const { op, left, right } = node;
1337
+ return `{ op: "${op}", args: [${this.emitExprNode(left)}, ${this.emitExprNode(right)}] }`;
1338
+ }
1339
+ case "query-expr-unary": {
1340
+ const { op, operand } = node;
1341
+ return `{ op: "${op}", args: [${this.emitExprNode(operand)}] }`;
1342
+ }
1343
+ case "query-expr-call": {
1344
+ const { fn, args } = node;
1345
+ return `{ op: "${fn}", args: [${args.map((a) => this.emitExprNode(a)).join(", ")}] }`;
1346
+ }
1347
+ default: return this.emitQueryFieldRef(node);
1348
+ }
1349
+ }
1330
1350
  emitQueryTree(queryNode) {
1331
1351
  return this.emitQueryExpr(queryNode.expression);
1332
1352
  }
@@ -1297,8 +1297,28 @@ var JsRenderer = class extends BaseRenderer {
1297
1297
  emitArgValue(aSpec, argToken) {
1298
1298
  if (aSpec.type === "ref") return this.emitRefValue(argToken.text);
1299
1299
  if (aSpec.type === "query" && argToken.queryNode) return this.emitQueryTree(argToken.queryNode);
1300
+ if (aSpec.type === "expr" && argToken.exprNode) return this.emitExprNode(argToken.exprNode.expression);
1301
+ if (aSpec.type === "order" && argToken.orderNode) return `[${argToken.orderNode.items.map((item) => `{ ref: ${this.emitQueryFieldRef(item.ref)}${item.desc ? ", desc: true" : ""} }`).join(", ")}]`;
1300
1302
  return aSpec.type === "string" ? `"${escapeQuotes(argToken.text)}"` : argToken.text;
1301
1303
  }
1304
+ emitExprNode(node) {
1305
+ switch (node.entity) {
1306
+ case "query-expr-number": return String(node.value);
1307
+ case "query-expr-binary": {
1308
+ const { op, left, right } = node;
1309
+ return `{ op: "${op}", args: [${this.emitExprNode(left)}, ${this.emitExprNode(right)}] }`;
1310
+ }
1311
+ case "query-expr-unary": {
1312
+ const { op, operand } = node;
1313
+ return `{ op: "${op}", args: [${this.emitExprNode(operand)}] }`;
1314
+ }
1315
+ case "query-expr-call": {
1316
+ const { fn, args } = node;
1317
+ return `{ op: "${fn}", args: [${args.map((a) => this.emitExprNode(a)).join(", ")}] }`;
1318
+ }
1319
+ default: return this.emitQueryFieldRef(node);
1320
+ }
1321
+ }
1302
1322
  emitQueryTree(queryNode) {
1303
1323
  return this.emitQueryExpr(queryNode.expression);
1304
1324
  }
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_plugin = require('./plugin-dcd-XTR-.cjs');
2
+ const require_plugin = require('./plugin-BG_encHp.cjs');
3
3
  let path = require("path");
4
4
  path = require_plugin.__toESM(path);
5
5
  let _atscript_core = require("@atscript/core");
@@ -1,4 +1,4 @@
1
- import { t as tsPlugin } from "./plugin-BDjZ2rOT.mjs";
1
+ import { t as tsPlugin } from "./plugin-CVvPRB8q.mjs";
2
2
  import path from "path";
3
3
  import { build } from "@atscript/core";
4
4
  import { readFileSync, writeFileSync } from "fs";
package/dist/utils.d.ts CHANGED
@@ -515,6 +515,25 @@ type AtscriptQueryNode = AtscriptQueryComparison | {
515
515
  } | {
516
516
  $not: AtscriptQueryNode;
517
517
  };
518
+ /**
519
+ * Arithmetic expression tree (runtime shape of an `expr` annotation argument).
520
+ * Leaves are numeric literals or field references.
521
+ */
522
+ type AtscriptExprNode = number | AtscriptQueryFieldRef | {
523
+ op: '+' | '-' | '*' | '/';
524
+ args: [AtscriptExprNode, AtscriptExprNode];
525
+ } | {
526
+ op: 'neg';
527
+ args: [AtscriptExprNode];
528
+ } | {
529
+ op: 'coalesce';
530
+ args: AtscriptExprNode[];
531
+ };
532
+ /** One key of an ordering (runtime shape of an `order` annotation argument is an array of these). */
533
+ interface AtscriptOrderItem {
534
+ ref: AtscriptQueryFieldRef;
535
+ desc?: true;
536
+ }
518
537
 
519
538
  /** Current serialization format version. Bumped on breaking changes to the serialized shape. */
520
539
  declare const SERIALIZE_VERSION = 2;
@@ -683,4 +702,4 @@ type NavPropsOf<T> = T extends {
683
702
  } ? N : Record<string, never>;
684
703
 
685
704
  export { SERIALIZE_VERSION, Validator, ValidatorError, annotate, buildJsonSchema, cloneRefProp, coerceForType, coerceScalar, createAnnotatedTypeNode, createDataFromAnnotatedType, defineAnnotatedType, deserializeAnnotatedType, detectDiscriminator, flattenAnnotatedType, forAnnotatedType, fromJsonSchema, isAnnotatedType, isAnnotatedTypeOfPrimitive, isPhantomType, mergeJsonSchemas, serializeAnnotatedType, throwFeatureDisabled };
686
- export type { AtscriptQueryComparison, AtscriptQueryFieldRef, AtscriptQueryNode, AtscriptRef, FlatOf, InferDataType, NavPropsOf, OwnPropsOf, PrimaryKeyOf, TAnnotatedTypeHandle, TAtscriptAnnotatedType, TAtscriptAnnotatedTypeConstructor, TAtscriptDataType, TAtscriptTypeArray, TAtscriptTypeComplex, TAtscriptTypeDef, TAtscriptTypeFinal, TAtscriptTypeObject, TCreateDataOptions, TFlattenOptions, TJsonSchema, TMetadataMap, TProcessAnnotationContext, TSerializeOptions, TSerializedAnnotatedType, TSerializedAnnotatedTypeInner, TSerializedTypeArray, TSerializedTypeComplex, TSerializedTypeDef, TSerializedTypeFinal, TSerializedTypeObject, TUnionDiscriminator, TValidatorOptions, TValidatorPlugin, TValidatorPluginContext, TValueResolver };
705
+ export type { AtscriptExprNode, AtscriptOrderItem, AtscriptQueryComparison, AtscriptQueryFieldRef, AtscriptQueryNode, AtscriptRef, FlatOf, InferDataType, NavPropsOf, OwnPropsOf, PrimaryKeyOf, TAnnotatedTypeHandle, TAtscriptAnnotatedType, TAtscriptAnnotatedTypeConstructor, TAtscriptDataType, TAtscriptTypeArray, TAtscriptTypeComplex, TAtscriptTypeDef, TAtscriptTypeFinal, TAtscriptTypeObject, TCreateDataOptions, TFlattenOptions, TJsonSchema, TMetadataMap, TProcessAnnotationContext, TSerializeOptions, TSerializedAnnotatedType, TSerializedAnnotatedTypeInner, TSerializedTypeArray, TSerializedTypeComplex, TSerializedTypeDef, TSerializedTypeFinal, TSerializedTypeObject, TUnionDiscriminator, TValidatorOptions, TValidatorPlugin, TValidatorPluginContext, TValueResolver };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/typescript",
3
- "version": "0.1.98",
3
+ "version": "0.1.99",
4
4
  "description": "Atscript: typescript-gen support.",
5
5
  "keywords": [
6
6
  "annotations",
@@ -73,7 +73,7 @@
73
73
  },
74
74
  "peerDependencies": {
75
75
  "@atscript/db": "^0.1.97",
76
- "@atscript/core": "^0.1.98"
76
+ "@atscript/core": "^0.1.99"
77
77
  },
78
78
  "peerDependenciesMeta": {
79
79
  "@atscript/db": {