@calcit/procs 0.13.1 → 0.13.4

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 (67) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/RFCs/08-08-cross-backend-host-ffi-contracts-rfc.md +584 -0
  3. package/RFCs/README.md +2 -1
  4. package/build.rs +24 -23
  5. package/editing-history/202608061714-struct-enum-data-model-v2.md +39 -0
  6. package/editing-history/202608061731-release-0.13.2.md +18 -0
  7. package/editing-history/20260807-1030-doc-struct-enum-rename-followup.md +9 -0
  8. package/editing-history/20260807-1130-rename-record-tuple-doc-files.md +6 -0
  9. package/editing-history/20260807-1200-rename-record-tuple-test-and-rust.md +41 -0
  10. package/editing-history/202608071809-preserve-targeted-schema-edits.md +11 -0
  11. package/editing-history/202608071848-static-method-generic-validation.md +5 -0
  12. package/editing-history/20260808-0913-continue-struct-naming-cleanup.md +21 -0
  13. package/editing-history/20260808-0917-struct-enum-terminology-cleanup.md +17 -0
  14. package/editing-history/20260808-0926-deprecated-record-api-analysis.md +16 -0
  15. package/editing-history/20260808-0939-pr-review-ci-remediation.md +10 -0
  16. package/editing-history/20260808-0959-canonical-edn-fixture-expectations.md +10 -0
  17. package/editing-history/20260808-1004-align-js-canonical-edn-format.md +10 -0
  18. package/editing-history/20260808-1008-deprecated-analysis-review-fixes.md +10 -0
  19. package/editing-history/20260808-1012-document-deprecated-api-cleanup.md +7 -0
  20. package/editing-history/20260808-1020-release-0.13.3.md +7 -0
  21. package/editing-history/20260808-1117-option-result-method-api.md +7 -0
  22. package/editing-history/20260808-1126-format-cirru-snapshots.md +6 -0
  23. package/editing-history/20260808-1300-record-tuple-naming-cleanup.md +62 -0
  24. package/editing-history/20260808-1418-cross-backend-host-ffi-contract-rfc.md +7 -0
  25. package/editing-history/20260808-1439-host-ffi-type-foundation.md +7 -0
  26. package/editing-history/20260808-1523-ffi-schema-redesign-and-cirru-edn-check.md +7 -0
  27. package/editing-history/20260808-1532-external-object-trait-refinement.md +6 -0
  28. package/editing-history/20260808-1632-host-ffi.md +6 -0
  29. package/editing-history/20260808-1734-pr-review-ffi-followups.md +7 -0
  30. package/editing-history/20260808-1745-es-module-typed-adapters.md +6 -0
  31. package/editing-history/20260808-1817-release-0.13.4.md +4 -0
  32. package/editing-history/202608080132-pr-309-review-fixes.md +5 -0
  33. package/editing-history/202608080202-js-example-checks.md +5 -0
  34. package/editing-history/202608080206-quote-shell-special-example.md +4 -0
  35. package/editing-history/202608080854-edn-0.8-integration.md +6 -0
  36. package/history/202608061433-required-record-field-access.md +32 -0
  37. package/history/202608062004-wasm-ffi-declarations.md +7 -0
  38. package/history/202608071500-wasm-ffi-review-fixes.md +6 -0
  39. package/lib/calcit-data.mjs +24 -24
  40. package/lib/calcit.procs.d.mts +43 -43
  41. package/lib/calcit.procs.mjs +165 -168
  42. package/lib/custom-formatter.mjs +23 -38
  43. package/lib/js-cirru.mjs +33 -33
  44. package/lib/js-enum-def.d.mts +11 -0
  45. package/lib/{js-enum.mjs → js-enum-def.mjs} +3 -3
  46. package/lib/{js-tuple.d.mts → js-enum-value.d.mts} +6 -7
  47. package/lib/{js-tuple.mjs → js-enum-value.mjs} +8 -15
  48. package/lib/js-list.mjs +6 -6
  49. package/lib/js-primes.d.mts +5 -5
  50. package/lib/js-primes.mjs +16 -16
  51. package/lib/{js-struct.d.mts → js-struct-def.d.mts} +2 -2
  52. package/lib/{js-struct.mjs → js-struct-def.mjs} +6 -6
  53. package/lib/{js-record.d.mts → js-struct-value.d.mts} +16 -15
  54. package/lib/{js-record.mjs → js-struct-value.mjs} +67 -59
  55. package/lib/package.json +1 -1
  56. package/package.json +1 -1
  57. package/ts-src/calcit-data.mts +24 -24
  58. package/ts-src/calcit.procs.mts +165 -168
  59. package/ts-src/custom-formatter.mts +28 -56
  60. package/ts-src/js-cirru.mts +34 -34
  61. package/ts-src/{js-enum.mts → js-enum-def.mts} +7 -7
  62. package/ts-src/{js-tuple.mts → js-enum-value.mts} +12 -19
  63. package/ts-src/js-list.mts +6 -6
  64. package/ts-src/js-primes.mts +16 -16
  65. package/ts-src/{js-struct.mts → js-struct-def.mts} +7 -7
  66. package/ts-src/{js-record.mts → js-struct-value.mts} +72 -66
  67. package/lib/js-enum.d.mts +0 -11
@@ -2,35 +2,36 @@ import { Hash } from "@calcit/ternary-tree";
2
2
  import { CalcitValue } from "./js-primes.mjs";
3
3
  import { CalcitImpl } from "./js-impl.mjs";
4
4
  import { CalcitTag } from "./calcit-data.mjs";
5
- import { CalcitStruct } from "./js-struct.mjs";
6
- export declare class CalcitRecord {
5
+ import { CalcitStructDef } from "./js-struct-def.mjs";
6
+ export declare class CalcitStructValue {
7
7
  name: CalcitTag;
8
8
  fields: Array<CalcitTag>;
9
9
  values: Array<CalcitValue>;
10
- structRef: CalcitStruct;
10
+ structRef: CalcitStructDef;
11
11
  cachedHash: Hash;
12
- constructor(name: CalcitTag, fields: Array<CalcitTag>, values?: Array<CalcitValue>, structRef?: CalcitStruct);
12
+ constructor(name: CalcitTag, fields: Array<CalcitTag>, values?: Array<CalcitValue>, structRef?: CalcitStructDef);
13
13
  get(k: CalcitValue): CalcitValue;
14
+ getRequired(k: CalcitValue): CalcitValue;
14
15
  getOrNil(k: CalcitValue): CalcitValue;
15
- assoc(k: CalcitValue, v: CalcitValue): CalcitRecord;
16
+ assoc(k: CalcitValue, v: CalcitValue): CalcitStructValue;
16
17
  /** return -1 for missing */
17
18
  findIndex(k: CalcitValue): number;
18
19
  contains(k: CalcitValue): boolean;
19
20
  toString(disableJsDataWarning?: boolean): string;
20
- withImpls(impl: CalcitValue | CalcitImpl[]): CalcitRecord;
21
+ withImpls(impl: CalcitValue | CalcitImpl[]): CalcitStructValue;
21
22
  }
22
- export declare let new_record: (name: CalcitValue, ...fields: Array<CalcitValue>) => CalcitValue;
23
- export declare let new_impl_record: (impl: CalcitImpl, name: CalcitValue, ...fields: Array<CalcitValue>) => CalcitValue;
23
+ export declare let new_struct_value: (name: CalcitValue, ...fields: Array<CalcitValue>) => CalcitValue;
24
+ export declare let new_impl_struct_value: (impl: CalcitImpl, name: CalcitValue, ...fields: Array<CalcitValue>) => CalcitValue;
24
25
  /** Loose record: `?{} :field1 val1 :field2 val2` – record without a declared struct.
25
26
  * Fields are sorted by tag index. The record name is "?" (sentinel). */
26
27
  export declare let _$q__$M_: (...xs: Array<CalcitValue>) => CalcitValue;
27
28
  export declare let fieldsEqual: (xs: Array<CalcitTag>, ys: Array<CalcitTag>) => boolean;
28
29
  export declare let _$n__PCT__$M_: (proto: CalcitValue, ...xs: Array<CalcitValue>) => CalcitValue;
29
30
  export declare let _$n__PCT__$M__$q_: (proto: CalcitValue, ...xs: Array<CalcitValue>) => CalcitValue;
30
- export declare let _$n_record_$o_with: (proto: CalcitValue, ...xs: Array<CalcitValue>) => CalcitValue;
31
- export declare let _$n_record_$o_get_name: (x: CalcitValue) => CalcitTag;
32
- export declare let _$n_record_$o_struct: (x: CalcitValue) => CalcitValue;
33
- export declare let _$n_record_$o_from_map: (proto: CalcitValue, data: CalcitValue) => CalcitValue;
34
- export declare let _$n_record_$o_to_map: (x: CalcitValue) => CalcitValue;
35
- export declare let _$n_record_$o_matches_$q_: (x: CalcitValue, y: CalcitValue) => boolean;
36
- export declare function _$n_record_$o_extend_as(obj: CalcitValue, new_name: CalcitValue, new_key: CalcitValue, new_value: CalcitValue): CalcitRecord;
31
+ export declare let _$n_struct_$o_with: (proto: CalcitValue, ...xs: Array<CalcitValue>) => CalcitValue;
32
+ export declare let _$n_struct_$o_get_name: (x: CalcitValue) => CalcitTag;
33
+ export declare let _$n_struct_$o_definition: (x: CalcitValue) => CalcitValue;
34
+ export declare let _$n_struct_$o_from_map: (proto: CalcitValue, data: CalcitValue) => CalcitValue;
35
+ export declare let _$n_struct_$o_to_map: (x: CalcitValue) => CalcitValue;
36
+ export declare let _$n_struct_$o_matches_$q_: (x: CalcitValue, y: CalcitValue) => boolean;
37
+ export declare function _$n_struct_$o_extend_as(obj: CalcitValue, new_name: CalcitValue, new_key: CalcitValue, new_value: CalcitValue): CalcitStructValue;
@@ -1,8 +1,8 @@
1
1
  import { CalcitImpl } from "./js-impl.mjs";
2
2
  import { newTag, castTag, toString, getStringName, findInFields } from "./calcit-data.mjs";
3
3
  import { CalcitMap, CalcitSliceMap } from "./js-map.mjs";
4
- import { CalcitStruct } from "./js-struct.mjs";
5
- export class CalcitRecord {
4
+ import { CalcitStructDef } from "./js-struct-def.mjs";
5
+ export class CalcitStructValue {
6
6
  constructor(name, fields, values, structRef) {
7
7
  this.name = name;
8
8
  let fieldNames = fields.map(castTag);
@@ -17,7 +17,7 @@ export class CalcitRecord {
17
17
  this.values = new Array(fieldNames.length);
18
18
  }
19
19
  this.cachedHash = null;
20
- this.structRef = structRef || new CalcitStruct(name, fields, new Array(fields.length).fill(null));
20
+ this.structRef = structRef || new CalcitStructDef(name, fields, new Array(fields.length).fill(null));
21
21
  }
22
22
  get(k) {
23
23
  let field = castTag(k);
@@ -29,6 +29,12 @@ export class CalcitRecord {
29
29
  return undefined;
30
30
  }
31
31
  }
32
+ getRequired(k) {
33
+ const value = this.get(k);
34
+ if (value !== undefined)
35
+ return value;
36
+ throw new Error(`struct '${this.name.value}' does not define field ${castTag(k).toString()}`);
37
+ }
32
38
  getOrNil(k) {
33
39
  let field = castTag(k);
34
40
  let idx = findInFields(this.fields, field);
@@ -50,7 +56,7 @@ export class CalcitRecord {
50
56
  values[idx] = this.values[idx];
51
57
  }
52
58
  }
53
- return new CalcitRecord(this.name, this.fields, values, this.structRef);
59
+ return new CalcitStructValue(this.name, this.fields, values, this.structRef);
54
60
  }
55
61
  /** return -1 for missing */
56
62
  findIndex(k) {
@@ -64,7 +70,7 @@ export class CalcitRecord {
64
70
  }
65
71
  toString(disableJsDataWarning = false) {
66
72
  // Optimize string building using array join instead of concatenation
67
- const parts = ["(%{} '", this.name.value];
73
+ const parts = this.name.value === "_" ? ["(%{} _"] : ["(%{} '", this.name.value];
68
74
  for (let idx = 0; idx < this.fields.length; idx++) {
69
75
  parts.push(" (", this.fields[idx].toString(), " ", toString(this.values[idx], true, disableJsDataWarning), ")");
70
76
  }
@@ -82,11 +88,11 @@ export class CalcitRecord {
82
88
  else {
83
89
  throw new Error("Expected an impl or array of impls");
84
90
  }
85
- let nextStruct = new CalcitStruct(this.name, this.fields, this.structRef.fieldTypes, this.structRef.impls.concat(nextImpls));
86
- return new CalcitRecord(this.name, this.fields, this.values, nextStruct);
91
+ let nextStruct = new CalcitStructDef(this.name, this.fields, this.structRef.fieldTypes, this.structRef.impls.concat(nextImpls));
92
+ return new CalcitStructValue(this.name, this.fields, this.values, nextStruct);
87
93
  }
88
94
  }
89
- export let new_record = (name, ...fields) => {
95
+ export let new_struct_value = (name, ...fields) => {
90
96
  let fieldNames = fields.map(castTag).sort((x, y) => {
91
97
  if (x.idx < y.idx) {
92
98
  return -1;
@@ -95,12 +101,12 @@ export let new_record = (name, ...fields) => {
95
101
  return 1;
96
102
  }
97
103
  else {
98
- throw new Error(`Unexpected duplication in record fields: ${x.toString()}`);
104
+ throw new Error(`Unexpected duplication in struct fields: ${x.toString()}`);
99
105
  }
100
106
  });
101
- return new CalcitRecord(castTag(name), fieldNames);
107
+ return new CalcitStructValue(castTag(name), fieldNames);
102
108
  };
103
- export let new_impl_record = (impl, name, ...fields) => {
109
+ export let new_impl_struct_value = (impl, name, ...fields) => {
104
110
  let fieldNames = fields.map(castTag).sort((x, y) => {
105
111
  if (x.idx < y.idx) {
106
112
  return -1;
@@ -109,12 +115,12 @@ export let new_impl_record = (impl, name, ...fields) => {
109
115
  return 1;
110
116
  }
111
117
  else {
112
- throw new Error(`Unexpected duplication in record fields: ${x.toString()}`);
118
+ throw new Error(`Unexpected duplication in struct fields: ${x.toString()}`);
113
119
  }
114
120
  });
115
121
  let nameTag = castTag(name);
116
- let structRef = new CalcitStruct(nameTag, fieldNames, new Array(fieldNames.length).fill(null), [impl]);
117
- return new CalcitRecord(nameTag, fieldNames, undefined, structRef);
122
+ let structRef = new CalcitStructDef(nameTag, fieldNames, new Array(fieldNames.length).fill(null), [impl]);
123
+ return new CalcitStructValue(nameTag, fieldNames, undefined, structRef);
118
124
  };
119
125
  /** Loose record: `?{} :field1 val1 :field2 val2` – record without a declared struct.
120
126
  * Fields are sorted by tag index. The record name is "?" (sentinel). */
@@ -135,8 +141,8 @@ export let _$q__$M_ = (...xs) => {
135
141
  }
136
142
  let fieldNames = pairs.map((p) => p[0]);
137
143
  let values = pairs.map((p) => p[1]);
138
- let looseTag = newTag("?");
139
- return new CalcitRecord(looseTag, fieldNames, values);
144
+ let looseTag = newTag("_");
145
+ return new CalcitStructValue(looseTag, fieldNames, values);
140
146
  };
141
147
  export let fieldsEqual = (xs, ys) => {
142
148
  if (xs === ys) {
@@ -154,14 +160,14 @@ export let fieldsEqual = (xs, ys) => {
154
160
  };
155
161
  export let _$n__PCT__$M_ = (proto, ...xs) => {
156
162
  let recordProto;
157
- if (proto instanceof CalcitRecord) {
163
+ if (proto instanceof CalcitStructValue) {
158
164
  recordProto = proto;
159
165
  }
160
- else if (proto instanceof CalcitStruct) {
161
- recordProto = new CalcitRecord(proto.name, proto.fields, new Array(proto.fields.length).fill(null), proto);
166
+ else if (proto instanceof CalcitStructDef) {
167
+ recordProto = new CalcitStructValue(proto.name, proto.fields, new Array(proto.fields.length).fill(null), proto);
162
168
  }
163
169
  else {
164
- throw new Error("Expected prototype to be a record");
170
+ throw new Error("Expected prototype to be a StructDef");
165
171
  }
166
172
  {
167
173
  if (xs.length % 2 !== 0) {
@@ -181,21 +187,21 @@ export let _$n__PCT__$M_ = (proto, ...xs) => {
181
187
  }
182
188
  }
183
189
  if (idx < 0) {
184
- throw new Error("invalid field name for this record");
190
+ throw new Error("invalid field name for this struct");
185
191
  }
186
192
  if (values[i] != null) {
187
- throw new Error("record field already has value, probably duplicated key");
193
+ throw new Error("struct field already has value, probably duplicated key");
188
194
  }
189
195
  values[i] = xs[idx * 2 + 1];
190
196
  }
191
- return new CalcitRecord(recordProto.name, recordProto.fields, values, recordProto.structRef);
197
+ return new CalcitStructValue(recordProto.name, recordProto.fields, values, recordProto.structRef);
192
198
  }
193
199
  };
194
200
  export let _$n__PCT__$M__$q_ = (proto, ...xs) => {
195
201
  let recordProto;
196
202
  let values;
197
- if (proto instanceof CalcitStruct) {
198
- recordProto = new CalcitRecord(proto.name, proto.fields, new Array(proto.fields.length).fill(null), proto);
203
+ if (proto instanceof CalcitStructDef) {
204
+ recordProto = new CalcitStructValue(proto.name, proto.fields, new Array(proto.fields.length).fill(null), proto);
199
205
  values = recordProto.values.slice();
200
206
  }
201
207
  else {
@@ -212,16 +218,16 @@ export let _$n__PCT__$M__$q_ = (proto, ...xs) => {
212
218
  throw new Error(`Cannot find field ${k} among ${recordProto.fields}`);
213
219
  }
214
220
  if (touched.has(idx)) {
215
- throw new Error(`record field already has value, probably duplicated key: ${k}`);
221
+ throw new Error(`struct field already has value, probably duplicated key: ${k}`);
216
222
  }
217
223
  touched.add(idx);
218
224
  values[idx] = xs[i + 1];
219
225
  }
220
- return new CalcitRecord(recordProto.name, recordProto.fields, values, recordProto.structRef);
226
+ return new CalcitStructValue(recordProto.name, recordProto.fields, values, recordProto.structRef);
221
227
  };
222
228
  /// update record with new values
223
- export let _$n_record_$o_with = (proto, ...xs) => {
224
- if (proto instanceof CalcitRecord) {
229
+ export let _$n_struct_$o_with = (proto, ...xs) => {
230
+ if (proto instanceof CalcitStructValue) {
225
231
  if (xs.length % 2 !== 0) {
226
232
  throw new Error("Expected even number of key/value");
227
233
  }
@@ -235,39 +241,41 @@ export let _$n_record_$o_with = (proto, ...xs) => {
235
241
  }
236
242
  values[idx] = v;
237
243
  }
238
- return new CalcitRecord(proto.name, proto.fields, values, proto.structRef);
244
+ return new CalcitStructValue(proto.name, proto.fields, values, proto.structRef);
239
245
  }
240
246
  else {
241
- throw new Error("Expected prototype to be a record");
247
+ throw new Error("Expected prototype to be a StructDef");
242
248
  }
243
249
  };
244
- export let _$n_record_$o_get_name = (x) => {
245
- if (x instanceof CalcitRecord) {
250
+ export let _$n_struct_$o_get_name = (x) => {
251
+ if (x instanceof CalcitStructValue) {
246
252
  return x.name;
247
253
  }
248
254
  else {
249
- throw new Error("Expected a record");
255
+ throw new Error("Expected a struct value");
250
256
  }
251
257
  };
252
- export let _$n_record_$o_struct = (x) => {
253
- if (x instanceof CalcitRecord) {
258
+ export let _$n_struct_$o_definition = (x) => {
259
+ if (x instanceof CalcitStructValue) {
260
+ if (x.name.value === "_")
261
+ return null;
254
262
  return x.structRef ?? null;
255
263
  }
256
264
  else {
257
- throw new Error("Expected a record");
265
+ throw new Error("Expected a struct value");
258
266
  }
259
267
  };
260
- export let _$n_record_$o_from_map = (proto, data) => {
268
+ export let _$n_struct_$o_from_map = (proto, data) => {
261
269
  let recordProto;
262
- if (proto instanceof CalcitStruct) {
263
- recordProto = new CalcitRecord(proto.name, proto.fields, new Array(proto.fields.length).fill(null), proto);
270
+ if (proto instanceof CalcitStructDef) {
271
+ recordProto = new CalcitStructValue(proto.name, proto.fields, new Array(proto.fields.length).fill(null), proto);
264
272
  }
265
273
  else {
266
274
  throw new Error("Expected prototype to be struct");
267
275
  }
268
- if (data instanceof CalcitRecord) {
276
+ if (data instanceof CalcitStructValue) {
269
277
  if (fieldsEqual(recordProto.fields, data.fields)) {
270
- return new CalcitRecord(recordProto.name, recordProto.fields, data.values, recordProto.structRef);
278
+ return new CalcitStructValue(recordProto.name, recordProto.fields, data.values, recordProto.structRef);
271
279
  }
272
280
  else {
273
281
  let values = [];
@@ -279,7 +287,7 @@ export let _$n_record_$o_from_map = (proto, data) => {
279
287
  }
280
288
  values.push(data.values[idx]);
281
289
  }
282
- return new CalcitRecord(recordProto.name, recordProto.fields, values, recordProto.structRef);
290
+ return new CalcitStructValue(recordProto.name, recordProto.fields, values, recordProto.structRef);
283
291
  }
284
292
  }
285
293
  else if (data instanceof CalcitMap || data instanceof CalcitSliceMap) {
@@ -304,14 +312,14 @@ export let _$n_record_$o_from_map = (proto, data) => {
304
312
  }
305
313
  throw new Error(`Cannot find field ${field} among ${pairs_buffer}`);
306
314
  }
307
- return new CalcitRecord(recordProto.name, recordProto.fields, values, recordProto.structRef);
315
+ return new CalcitStructValue(recordProto.name, recordProto.fields, values, recordProto.structRef);
308
316
  }
309
317
  else {
310
- throw new Error("Expected record or data for making a record");
318
+ throw new Error("Expected a struct value or data for making a struct");
311
319
  }
312
320
  };
313
- export let _$n_record_$o_to_map = (x) => {
314
- if (x instanceof CalcitRecord) {
321
+ export let _$n_struct_$o_to_map = (x) => {
322
+ if (x instanceof CalcitStructValue) {
315
323
  var dict = [];
316
324
  for (let idx = 0; idx < x.fields.length; idx++) {
317
325
  dict.push(x.fields[idx], x.values[idx]);
@@ -319,35 +327,35 @@ export let _$n_record_$o_to_map = (x) => {
319
327
  return new CalcitSliceMap(dict);
320
328
  }
321
329
  else {
322
- throw new Error("Expected record");
330
+ throw new Error("Expected a struct value");
323
331
  }
324
332
  };
325
- export let _$n_record_$o_matches_$q_ = (x, y) => {
333
+ export let _$n_struct_$o_matches_$q_ = (x, y) => {
326
334
  let targetStruct;
327
- if (y instanceof CalcitRecord) {
335
+ if (y instanceof CalcitStructValue) {
328
336
  targetStruct = y.structRef;
329
337
  }
330
- else if (y instanceof CalcitStruct) {
338
+ else if (y instanceof CalcitStructDef) {
331
339
  targetStruct = y;
332
340
  }
333
341
  else {
334
- throw new Error("Expected second argument to be record or struct");
342
+ throw new Error("Expected second argument to be a struct value or StructDef");
335
343
  }
336
- if (x instanceof CalcitRecord) {
344
+ if (x instanceof CalcitStructValue) {
337
345
  if (x.name !== targetStruct.name) {
338
346
  return false;
339
347
  }
340
348
  return fieldsEqual(x.fields, targetStruct.fields);
341
349
  }
342
350
  else {
343
- throw new Error("Expected first argument to be record");
351
+ throw new Error("Expected first argument to be a struct value");
344
352
  }
345
353
  };
346
- export function _$n_record_$o_extend_as(obj, new_name, new_key, new_value) {
354
+ export function _$n_struct_$o_extend_as(obj, new_name, new_key, new_value) {
347
355
  if (arguments.length !== 4)
348
356
  throw new Error(`Expected 4 arguments, got ${arguments.length}`);
349
- if (!(obj instanceof CalcitRecord))
350
- throw new Error("Expected record");
357
+ if (!(obj instanceof CalcitStructValue))
358
+ throw new Error("Expected a struct value");
351
359
  let field = castTag(new_key);
352
360
  let new_name_tag = castTag(new_name);
353
361
  let new_fields = [];
@@ -372,7 +380,7 @@ export function _$n_record_$o_extend_as(obj, new_name, new_key, new_value) {
372
380
  new_values.push(obj.values[i]);
373
381
  }
374
382
  else {
375
- throw new Error("Does not extend existed record field");
383
+ throw new Error("Cannot extend an existing struct field");
376
384
  }
377
385
  }
378
386
  }
@@ -380,5 +388,5 @@ export function _$n_record_$o_extend_as(obj, new_name, new_key, new_value) {
380
388
  new_fields.push(field);
381
389
  new_values.push(new_value);
382
390
  }
383
- return new CalcitRecord(new_name_tag, new_fields, new_values);
391
+ return new CalcitStructValue(new_name_tag, new_fields, new_values);
384
392
  }
package/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calcit/procs",
3
- "version": "0.13.1",
3
+ "version": "0.13.4",
4
4
  "main": "./lib/calcit.procs.mjs",
5
5
  "devDependencies": {
6
6
  "@types/node": "^25.7.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calcit/procs",
3
- "version": "0.13.1",
3
+ "version": "0.13.4",
4
4
  "main": "./lib/calcit.procs.mjs",
5
5
  "devDependencies": {
6
6
  "@types/node": "^25.7.0",
@@ -3,16 +3,16 @@ import { overwriteComparator, initTernaryTreeMap } from "@calcit/ternary-tree";
3
3
  import { overwriteMapComparator } from "./js-map.mjs";
4
4
  import { disableListStructureCheck } from "@calcit/ternary-tree";
5
5
 
6
- import { CalcitRecord, fieldsEqual } from "./js-record.mjs";
6
+ import { CalcitStructValue, fieldsEqual } from "./js-struct-value.mjs";
7
7
  import { CalcitImpl } from "./js-impl.mjs";
8
- import { CalcitStruct } from "./js-struct.mjs";
9
- import { CalcitEnum } from "./js-enum.mjs";
8
+ import { CalcitStructDef } from "./js-struct-def.mjs";
9
+ import { CalcitEnumDef } from "./js-enum-def.mjs";
10
10
  import { CalcitMap, CalcitSliceMap } from "./js-map.mjs";
11
11
 
12
12
  import { CalcitValue, _$n_compare } from "./js-primes.mjs";
13
13
  import { CalcitList, CalcitSliceList } from "./js-list.mjs";
14
14
  import { CalcitSet, overwriteSetComparator } from "./js-set.mjs";
15
- import { CalcitTuple } from "./js-tuple.mjs";
15
+ import { CalcitEnumValue } from "./js-enum-value.mjs";
16
16
  import { CalcitTrait } from "./js-trait.mjs";
17
17
  import { CalcitCirruQuote, cirru_deep_equal } from "./js-cirru.mjs";
18
18
  import { CirruWriterNode } from "@cirru/writer.ts";
@@ -80,7 +80,7 @@ export let isNestedCalcitData = (x: CalcitValue): boolean => {
80
80
  if (x instanceof CalcitMap || x instanceof CalcitSliceMap) {
81
81
  return x.len() > 0;
82
82
  }
83
- if (x instanceof CalcitRecord) {
83
+ if (x instanceof CalcitStructValue) {
84
84
  return x.fields.length > 0;
85
85
  }
86
86
  if (x instanceof CalcitImpl) {
@@ -99,7 +99,7 @@ export let tipNestedCalcitData = (x: CalcitValue): string => {
99
99
  if (x instanceof CalcitMap || x instanceof CalcitSliceMap) {
100
100
  return "'{}...";
101
101
  }
102
- if (x instanceof CalcitRecord) {
102
+ if (x instanceof CalcitStructValue) {
103
103
  return "'%{}...";
104
104
  }
105
105
  if (x instanceof CalcitImpl) {
@@ -256,7 +256,7 @@ export let hashFunction = (x: CalcitValue): Hash => {
256
256
  x.cachedHash = h;
257
257
  return h;
258
258
  }
259
- if (x instanceof CalcitTuple) {
259
+ if (x instanceof CalcitEnumValue) {
260
260
  let base = defaultHash_tuple;
261
261
  base = mergeValueHash(base, hashFunction(x.tag));
262
262
  for (let idx = 0; idx < x.extra.length; idx++) {
@@ -322,7 +322,7 @@ export let hashFunction = (x: CalcitValue): Hash => {
322
322
  x.cachedHash = base;
323
323
  return base;
324
324
  }
325
- if (x instanceof CalcitRecord) {
325
+ if (x instanceof CalcitStructValue) {
326
326
  let base = defaultHash_record;
327
327
  for (let idx = 0; idx < x.fields.length; idx++) {
328
328
  base = mergeValueHash(base, hashFunction(x.fields[idx]));
@@ -344,7 +344,7 @@ export let hashFunction = (x: CalcitValue): Hash => {
344
344
  x.cachedHash = base;
345
345
  return base;
346
346
  }
347
- if (x instanceof CalcitStruct) {
347
+ if (x instanceof CalcitStructDef) {
348
348
  let base = defaultHash_struct;
349
349
  base = mergeValueHash(base, hashFunction(x.name));
350
350
  for (let idx = 0; idx < x.fields.length; idx++) {
@@ -357,7 +357,7 @@ export let hashFunction = (x: CalcitValue): Hash => {
357
357
  x.cachedHash = base;
358
358
  return base;
359
359
  }
360
- if (x instanceof CalcitEnum) {
360
+ if (x instanceof CalcitEnumDef) {
361
361
  let base = defaultHash_enum;
362
362
  base = mergeValueHash(base, hashFunction(x.prototype));
363
363
  for (let impl of x.impls) {
@@ -441,16 +441,16 @@ export let toString = (x: CalcitValue, escaped: boolean, disableJsDataWarning: b
441
441
  if (x instanceof CalcitSet) {
442
442
  return x.toString(disableJsDataWarning);
443
443
  }
444
- if (x instanceof CalcitRecord) {
444
+ if (x instanceof CalcitStructValue) {
445
445
  return x.toString(disableJsDataWarning);
446
446
  }
447
447
  if (x instanceof CalcitImpl) {
448
448
  return x.toString(disableJsDataWarning);
449
449
  }
450
- if (x instanceof CalcitStruct) {
450
+ if (x instanceof CalcitStructDef) {
451
451
  return x.toString(disableJsDataWarning);
452
452
  }
453
- if (x instanceof CalcitEnum) {
453
+ if (x instanceof CalcitEnumDef) {
454
454
  return x.toString();
455
455
  }
456
456
  if (x instanceof CalcitTrait) {
@@ -459,7 +459,7 @@ export let toString = (x: CalcitValue, escaped: boolean, disableJsDataWarning: b
459
459
  if (x instanceof CalcitRef) {
460
460
  return x.toString();
461
461
  }
462
- if (x instanceof CalcitTuple) {
462
+ if (x instanceof CalcitEnumValue) {
463
463
  return x.toString(disableJsDataWarning);
464
464
  }
465
465
  if (x instanceof CalcitCirruQuote) {
@@ -532,7 +532,7 @@ let to_js_data_inner = (x: CalcitValue, addColon: boolean): any => {
532
532
  }
533
533
  return Symbol(x.value);
534
534
  }
535
- if (x instanceof CalcitTuple) {
535
+ if (x instanceof CalcitEnumValue) {
536
536
  var result: any[] = [to_js_data_inner(x.tag, false)];
537
537
  for (let i = 0; i < x.extra.length; i++) {
538
538
  let item = x.extra[i];
@@ -565,7 +565,7 @@ let to_js_data_inner = (x: CalcitValue, addColon: boolean): any => {
565
565
  });
566
566
  return result;
567
567
  }
568
- if (x instanceof CalcitRecord) {
568
+ if (x instanceof CalcitStructValue) {
569
569
  let result: Record<string, CalcitValue> = {};
570
570
  for (let idx = 0; idx < x.fields.length; idx++) {
571
571
  result[x.fields[idx].value] = to_js_data_inner(x.values[idx], false);
@@ -693,8 +693,8 @@ export let _$n__$e_ = (x: CalcitValue, y: CalcitValue): boolean => {
693
693
  }
694
694
  return false;
695
695
  }
696
- if (x instanceof CalcitTuple) {
697
- if (y instanceof CalcitTuple) {
696
+ if (x instanceof CalcitEnumValue) {
697
+ if (y instanceof CalcitEnumValue) {
698
698
  return x.eq(y);
699
699
  }
700
700
  return false;
@@ -743,8 +743,8 @@ export let _$n__$e_ = (x: CalcitValue, y: CalcitValue): boolean => {
743
743
  }
744
744
  return false;
745
745
  }
746
- if (x instanceof CalcitRecord) {
747
- if (y instanceof CalcitRecord) {
746
+ if (x instanceof CalcitStructValue) {
747
+ if (y instanceof CalcitStructValue) {
748
748
  if (x.name !== y.name) {
749
749
  return false;
750
750
  }
@@ -789,14 +789,14 @@ export let _$n__$e_ = (x: CalcitValue, y: CalcitValue): boolean => {
789
789
  }
790
790
  return false;
791
791
  }
792
- if (x instanceof CalcitStruct) {
793
- if (y instanceof CalcitStruct) {
792
+ if (x instanceof CalcitStructDef) {
793
+ if (y instanceof CalcitStructDef) {
794
794
  return x.name === y.name && fieldsEqual(x.fields, y.fields);
795
795
  }
796
796
  return false;
797
797
  }
798
- if (x instanceof CalcitEnum) {
799
- if (y instanceof CalcitEnum) {
798
+ if (x instanceof CalcitEnumDef) {
799
+ if (y instanceof CalcitEnumDef) {
800
800
  return x.name === y.name;
801
801
  }
802
802
  return false;