@magmonium/cli 0.8.23 → 0.8.24

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/codegen/index.js +23 -9
  2. package/package.json +1 -1
package/codegen/index.js CHANGED
@@ -16122,7 +16122,11 @@ function landingGate(method, op, codes, subject, cast, roots, shapes, functions,
16122
16122
  }
16123
16123
  };
16124
16124
  }
16125
- function patchLiteral(mappings, properties, shapes, functions, subject, cast = false, roots = properties, taken = /* @__PURE__ */ new Set(), receiverOf = OWN_STORE, gate = NO_GATE, stateType, oneFunctionNames = /* @__PURE__ */ new Set()) {
16125
+ function patchLiteral(mappings, properties, shapes, functions, subject, cast = false, roots = properties, taken = /* @__PURE__ */ new Set(), receiverOf = OWN_STORE, gate = NO_GATE, stateType, oneFunctionNames = /* @__PURE__ */ new Set(), spelledShapes = /* @__PURE__ */ new Set()) {
16126
+ const spell = (dataType, cardinality) => {
16127
+ if (dataType?.type === "shape") spelledShapes.add(dataType.shapeId);
16128
+ return tsTypeExpression(shapes, dataType, cardinality);
16129
+ };
16126
16130
  const declarations = [];
16127
16131
  if (gate.declaration) declarations.push(gate.declaration);
16128
16132
  const hoisted = /* @__PURE__ */ new Map();
@@ -16137,8 +16141,7 @@ function patchLiteral(mappings, properties, shapes, functions, subject, cast = f
16137
16141
  functions
16138
16142
  );
16139
16143
  if (!fn) return void 0;
16140
- const typeArgs = mapping.transform.oneFunction ? `<${tsTypeExpression(
16141
- shapes,
16144
+ const typeArgs = mapping.transform.oneFunction ? `<${spell(
16142
16145
  property.dataType,
16143
16146
  property.cardinality === "map-many" ? "many" : "one"
16144
16147
  )}>` : "";
@@ -16231,15 +16234,14 @@ function patchLiteral(mappings, properties, shapes, functions, subject, cast = f
16231
16234
  const element = property.dataType.type === "shape" ? shapes[property.dataType.shapeId] : void 0;
16232
16235
  const keyKey = element?.keys.find((k) => k.name === mapping.keyBy);
16233
16236
  const keyRead = keyKey ? `item${memberAccess(element, keyKey)}` : `item.${mapping.keyBy}`;
16234
- const keyed = mapping.keyBy ? property.cardinality === "map-many" ? `(${castRead(read, cast, "unknown[]")} ?? []).reduce<${tsTypeExpression(
16235
- shapes,
16237
+ const keyed = mapping.keyBy ? property.cardinality === "map-many" ? `(${castRead(read, cast, "unknown[]")} ?? []).reduce<${spell(
16236
16238
  property.dataType,
16237
16239
  property.cardinality
16238
16240
  )}>((acc, item) => { (acc[${keyRead}] ??= []).push(item); return acc; }, {})` : `Object.fromEntries((${castRead(read, cast, "unknown[]")} ?? []).map((item) => [${keyRead}, item]))` : void 0;
16239
16241
  const value = keyed ?? castRead(
16240
16242
  read,
16241
16243
  cast,
16242
- tsTypeExpression(shapes, property.dataType, property.cardinality)
16244
+ cast ? spell(property.dataType, property.cardinality) : ""
16243
16245
  );
16244
16246
  return { receiver, key: property.name, value };
16245
16247
  };
@@ -16743,7 +16745,8 @@ function generateStoreMethods(methods, operationOf, properties, shapes, function
16743
16745
  receiverOf,
16744
16746
  okGate,
16745
16747
  stateType,
16746
- oneFunctionNames
16748
+ oneFunctionNames,
16749
+ argShapes
16747
16750
  );
16748
16751
  const beforePersists = persistStatements(
16749
16752
  method,
@@ -16807,7 +16810,8 @@ function generateStoreMethods(methods, operationOf, properties, shapes, function
16807
16810
  receiverOf,
16808
16811
  gate,
16809
16812
  stateType,
16810
- oneFunctionNames
16813
+ oneFunctionNames,
16814
+ argShapes
16811
16815
  );
16812
16816
  if (!patch.statements.length) continue;
16813
16817
  const { type, shapeId } = errorBodyType(
@@ -26742,7 +26746,7 @@ __export(package_exports2, {
26742
26746
  version: () => version2
26743
26747
  });
26744
26748
  var name2 = "@magmonium/cli";
26745
- var version2 = "0.8.23";
26749
+ var version2 = "0.8.24";
26746
26750
  var description2 = "A powerful and extensible asset compilation tool that can be shared across multiple projects";
26747
26751
  var bin = {
26748
26752
  "mag-cli": "bin/cli.js"
@@ -28203,6 +28207,16 @@ var valueFits = (value, dataType, cardinality, shapes) => {
28203
28207
  case "shape": {
28204
28208
  const shape = shapes[dataType.shapeId];
28205
28209
  if (!shape) return void 0;
28210
+ if (shape.positional) {
28211
+ if (!Array.isArray(value) || value.length !== shape.keys.length) {
28212
+ return false;
28213
+ }
28214
+ return everyFit(
28215
+ shape.keys.map(
28216
+ (key2, at) => valueFits(value[at], key2.dataType, key2.cardinality, shapes)
28217
+ )
28218
+ );
28219
+ }
28206
28220
  if (Array.isArray(value) || typeof value !== "object" || value === null) {
28207
28221
  return false;
28208
28222
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magmonium/cli",
3
- "version": "0.8.23",
3
+ "version": "0.8.24",
4
4
  "description": "A powerful and extensible asset compilation tool that can be shared across multiple projects",
5
5
  "bin": {
6
6
  "mag-cli": "bin/cli.js"